forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit326a33a
committed
Fix corner-case planner failure for MERGE.
MERGE planning could fail with "variable not found in subplan targetlist" if the target table is partitioned and all its partitions areexcluded at plan time, or in the case where it has no partitions butused to have some. This happened because distribute_row_identity_varsthought it didn't need to make the target table's reltarget listfully valid; but if we generate a join plan then that is requiredbecause the dummy Result node's tlist will be made from the reltarget.The same logic appears in distribute_row_identity_vars in v14,but AFAICS the problem is unreachable in that branch for lack ofMERGE. In other updating statements, the target table is alwaysinner-joined to any other tables, so if the target is known dummythen the whole plan reduces to dummy, so no join nodes are created.So I'll refrain from back-patching this code change to v14 for now.Per report from Alvaro Herrera.Discussion:https://postgr.es/m/20230328112248.6as34mlx5sr4kltg@alvherre.pgsql1 parentc1f1c1f commit326a33a
File tree
3 files changed
+45
-3
lines changed- src
- backend/optimizer/util
- test/regress
- expected
- sql
3 files changed
+45
-3
lines changedLines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| |||
994 | 995 |
| |
995 | 996 |
| |
996 | 997 |
| |
997 |
| - | |
998 |
| - | |
999 |
| - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
1000 | 1002 |
| |
1001 | 1003 |
| |
1002 | 1004 |
| |
| |||
1006 | 1008 |
| |
1007 | 1009 |
| |
1008 | 1010 |
| |
| 1011 | + | |
| 1012 | + | |
1009 | 1013 |
| |
1010 | 1014 |
| |
1011 | 1015 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1849 | 1849 |
| |
1850 | 1850 |
| |
1851 | 1851 |
| |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
1852 | 1878 |
| |
1853 | 1879 |
| |
1854 | 1880 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1169 | 1169 |
| |
1170 | 1170 |
| |
1171 | 1171 |
| |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1172 | 1184 |
| |
1173 | 1185 |
| |
1174 | 1186 |
| |
|
0 commit comments
Comments
(0)