forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit34ae54a
committed
Fix wrong varnullingrels error for MERGE WHEN NOT MATCHED BY SOURCE.
If a MERGE command contains WHEN NOT MATCHED BY SOURCE actions, thesource relation appears on the outer side of the join. Thus, any Varsreferring to the source in the merge join condition, actions, andRETURNING list should be marked as nullable by the join, since theyare used in the ModifyTable node above the join. Note that this onlyapplies to the copy of join condition used in the executor todistinguish MATCHED from NOT MATCHED BY SOURCE cases. Vars in theoriginal join condition, inside the join node itself, should not bemarked.Failure to correctly mark these Vars led to a "wrong varnullingrels"error in the final stage of query planning, in some circumstances. Wehappened to get away without this in all previous tests, since theyall involved a ModifyTable node directly on top of the join node, sothat the top plan targetlist coincided with the output of the join,and the varnullingrels check was more lax. However, if another plannode, such as a one-time filter Result node, gets inserted between theModifyTable node and the join node, then a stricter check is applied,which fails.Per bug #18634 from Alexander Lakhin. Thanks to Tom Lane and RichardGuo for review and analysis.Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was addedto MERGE.Discussion:https://postgr.es/m/18634-db5299c937877f2b%40postgresql.org1 parentd7d297f commit34ae54a
File tree
3 files changed
+89
-0
lines changed- src
- backend/optimizer/prep
- test/regress
- expected
- sql
3 files changed
+89
-0
lines changedLines changed: 39 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
285 | 324 |
| |
286 | 325 |
| |
287 | 326 |
| |
|
Lines changed: 29 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2711 | 2711 |
| |
2712 | 2712 |
| |
2713 | 2713 |
| |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
2714 | 2743 |
| |
2715 | 2744 |
| |
2716 | 2745 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1727 | 1727 |
| |
1728 | 1728 |
| |
1729 | 1729 |
| |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
1730 | 1751 |
| |
1731 | 1752 |
| |
1732 | 1753 |
| |
|
0 commit comments
Comments
(0)