forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit77d4d88
committed
Repair bogus EPQ plans generated for postgres_fdw foreign joins.
postgres_fdw's postgresGetForeignPlan() assumes without checking that theouter_plan it's given for a join relation must have a NestLoop, MergeJoin,or HashJoin node at the top. That's been wrong at least since commit4bbf6ed (which could cause insertion of a Sort node on top) and it seemslike a pretty unsafe thing to Just Assume even without that.Through blind good fortune, this doesn't seem to have any worseconsequences today than strange EXPLAIN output, but it's clearly troublewaiting to happen.To fix, test the node type explicitly before touching Join-specificfields, and avoid jamming the new tlist into a node type that can'tdo projection. Export a new support function from createplan.cto avoid building low-level knowledge about the latter into FDWs.Back-patch to 9.6 where the faulty coding was added. Note that theassociated regression test cases don't show any changes before v11,apparently because the tests back-patched with4bbf6ed don't actuallyexercise the problem case before then (there's no top-level Sortin those plans).Discussion:https://postgr.es/m/8946.1544644803@sss.pgh.pa.us1 parent0f7ec8d commit77d4d88
File tree
4 files changed
+140
-89
lines changed- contrib/postgres_fdw
- expected
- src
- backend/optimizer/plan
- include/optimizer
4 files changed
+140
-89
lines changedLines changed: 72 additions & 64 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1701 | 1701 |
| |
1702 | 1702 |
| |
1703 | 1703 |
| |
1704 |
| - | |
1705 |
| - | |
1706 |
| - | |
1707 |
| - | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
1708 | 1707 |
| |
1709 |
| - | |
1710 |
| - | |
1711 |
| - | |
1712 |
| - | |
1713 |
| - | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
1714 | 1713 |
| |
1715 |
| - | |
1716 |
| - | |
1717 |
| - | |
1718 |
| - | |
1719 |
| - | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
1720 | 1719 |
| |
1721 |
| - | |
1722 |
| - | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
1723 | 1725 |
| |
1724 | 1726 |
| |
1725 | 1727 |
| |
| |||
1748 | 1750 |
| |
1749 | 1751 |
| |
1750 | 1752 |
| |
1751 |
| - | |
1752 |
| - | |
1753 |
| - | |
1754 |
| - | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1755 | 1756 |
| |
1756 |
| - | |
1757 |
| - | |
1758 |
| - | |
1759 |
| - | |
1760 |
| - | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1761 | 1762 |
| |
1762 |
| - | |
1763 |
| - | |
1764 |
| - | |
1765 |
| - | |
1766 |
| - | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
1767 | 1768 |
| |
1768 |
| - | |
1769 |
| - | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1770 | 1774 |
| |
1771 | 1775 |
| |
1772 | 1776 |
| |
| |||
1796 | 1800 |
| |
1797 | 1801 |
| |
1798 | 1802 |
| |
1799 |
| - | |
1800 |
| - | |
1801 |
| - | |
1802 |
| - | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
1803 | 1806 |
| |
1804 |
| - | |
1805 |
| - | |
1806 |
| - | |
1807 |
| - | |
1808 |
| - | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
1809 | 1812 |
| |
1810 |
| - | |
1811 |
| - | |
1812 |
| - | |
1813 |
| - | |
1814 |
| - | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
1815 | 1818 |
| |
1816 |
| - | |
1817 |
| - | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
1818 | 1824 |
| |
1819 | 1825 |
| |
1820 | 1826 |
| |
| |||
1843 | 1849 |
| |
1844 | 1850 |
| |
1845 | 1851 |
| |
1846 |
| - | |
1847 |
| - | |
1848 |
| - | |
1849 |
| - | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
1850 | 1855 |
| |
1851 |
| - | |
1852 |
| - | |
1853 |
| - | |
1854 |
| - | |
1855 |
| - | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1856 | 1861 |
| |
1857 |
| - | |
1858 |
| - | |
1859 |
| - | |
1860 |
| - | |
1861 |
| - | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
1862 | 1867 |
| |
1863 |
| - | |
1864 |
| - | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
1865 | 1873 |
| |
1866 | 1874 |
| |
1867 | 1875 |
| |
|
Lines changed: 29 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1229 | 1229 |
| |
1230 | 1230 |
| |
1231 | 1231 |
| |
1232 |
| - | |
1233 |
| - | |
1234 |
| - | |
1235 |
| - | |
1236 |
| - | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1237 | 1235 |
| |
1238 | 1236 |
| |
1239 | 1237 |
| |
| |||
1246 | 1244 |
| |
1247 | 1245 |
| |
1248 | 1246 |
| |
1249 |
| - | |
1250 |
| - | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1251 | 1253 |
| |
1252 | 1254 |
| |
1253 |
| - | |
1254 | 1255 |
| |
1255 | 1256 |
| |
1256 | 1257 |
| |
1257 | 1258 |
| |
1258 | 1259 |
| |
1259 | 1260 |
| |
1260 |
| - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1261 | 1264 |
| |
1262 |
| - | |
1263 |
| - | |
1264 |
| - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
1265 | 1275 |
| |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
1266 | 1283 |
| |
1267 | 1284 |
| |
1268 | 1285 |
| |
|
Lines changed: 37 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1407 | 1407 |
| |
1408 | 1408 |
| |
1409 | 1409 |
| |
| 1410 | + | |
1410 | 1411 |
| |
1411 |
| - | |
1412 |
| - | |
1413 |
| - | |
1414 |
| - | |
1415 |
| - | |
1416 |
| - | |
1417 |
| - | |
1418 |
| - | |
1419 |
| - | |
1420 |
| - | |
1421 |
| - | |
1422 |
| - | |
1423 |
| - | |
| 1412 | + | |
| 1413 | + | |
1424 | 1414 |
| |
1425 | 1415 |
| |
1426 | 1416 |
| |
| |||
1762 | 1752 |
| |
1763 | 1753 |
| |
1764 | 1754 |
| |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
1765 | 1789 |
| |
1766 | 1790 |
| |
1767 | 1791 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
| 56 | + | |
| 57 | + | |
56 | 58 |
| |
57 | 59 |
| |
58 | 60 |
| |
|
0 commit comments
Comments
(0)