forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdddb564
committed
Fix incorrect non-strict join recheck in MERGE WHEN NOT MATCHED BY SOURCE.
If a MERGE command contains WHEN NOT MATCHED BY SOURCE actions, themerge join condition is used by the executor to distinguish MATCHEDfrom NOT MATCHED BY SOURCE cases. However, this qual is executed usingthe output from the join subplan node, which nulls the output from thesource relation in the not matched case, and so the result may beincorrect if the join condition is "non-strict" -- for example,something like "src.col IS NOT DISTINCT FROM tgt.col".Fix this by enhancing the join recheck condition with an additional"src IS NOT NULL" check, so that it does the right thing whenevaluated using the output from the join subplan.Noted by Tom Lane while investigating bug #18634 from AlexanderLakhin.Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was addedto MERGE.Discussion:https://postgr.es/m/18634-db5299c937877f2b%40postgresql.org1 parent1953196 commitdddb564
File tree
3 files changed
+101
-5
lines changed- src
- backend/optimizer/prep
- test/regress
- expected
- sql
3 files changed
+101
-5
lines changedLines changed: 61 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
| 161 | + | |
| 162 | + | |
| 163 | + | |
161 | 164 |
| |
162 | 165 |
| |
163 | 166 |
| |
| |||
226 | 229 |
| |
227 | 230 |
| |
228 | 231 |
| |
| 232 | + | |
229 | 233 |
| |
230 | 234 |
| |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
231 | 257 |
| |
232 | 258 |
| |
233 | 259 |
| |
234 |
| - | |
235 |
| - | |
| 260 | + | |
| 261 | + | |
236 | 262 |
| |
237 | 263 |
| |
238 | 264 |
| |
| |||
261 | 287 |
| |
262 | 288 |
| |
263 | 289 |
| |
264 |
| - | |
265 |
| - | |
266 |
| - | |
| 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 | + | |
267 | 323 |
| |
268 | 324 |
| |
269 | 325 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2689 | 2689 |
| |
2690 | 2690 |
| |
2691 | 2691 |
| |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
2692 | 2714 |
| |
2693 | 2715 |
| |
2694 | 2716 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1710 | 1710 |
| |
1711 | 1711 |
| |
1712 | 1712 |
| |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1713 | 1731 |
| |
1714 | 1732 |
| |
1715 | 1733 |
| |
|
0 commit comments
Comments
(0)