forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit70b42f2
committed
Fix misbehavior of EvalPlanQual checks with multiple result relations.
The idea of EvalPlanQual is that we replace the query's scan of theresult relation with a single injected tuple, and see if we get atuple out, thereby implying that the injected tuple still passes thequery quals. (In join cases, other relations in the query are stillscanned normally.) This logic was not updated when commit86dc900made it possible for a single DML query plan to have multiple resultrelations, when the query target relation has inheritance or partitionchildren. We replaced the output for the current result relationsuccessfully, but other result relations were still scanned normally;thus, if any other result relation contained a tuple satisfying thequals, we'd think the EPQ check passed, even if it did not pass forthe injected tuple itself. This would lead to update or deleteactions getting performed when they should have been skipped due toa conflicting concurrent update in READ COMMITTED isolation mode.Fix by blocking all sibling result relations from emitting tuplesduring an EvalPlanQual recheck. In the back branches, the fix iscomplicated a bit by the need to not change the size of structEPQState (else we'd have ABI-breaking changes in offsets instruct ModifyTableState). Like the back-patches of3f7836fand4b3e379, add a separately palloc'd struct to avoid that.The logic is the same as in HEAD otherwise.This is only a live bug back to v14 where86dc900 came in.However, I chose to back-patch the test cases further, on thegrounds that this whole area is none too well tested. I skippeddoing so in v11 though because none of the test applied cleanly,and it didn't quite seem worth extra work for a branch with onlysix months to live.Per report from Ante Krešić (via Aleksander Alekseev)Discussion:https://postgr.es/m/CAJ7c6TMBTN3rcz4=AjYhLPD_w3FFT0Wq_C15jxCDn8U4tZnH1g@mail.gmail.com1 parented7e686 commit70b42f2
File tree
9 files changed
+221
-48
lines changed- src
- backend
- executor
- replication/logical
- include
- executor
- nodes
- test/isolation
- expected
- specs
9 files changed
+221
-48
lines changedLines changed: 46 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2469 | 2469 |
| |
2470 | 2470 |
| |
2471 | 2471 |
| |
2472 |
| - | |
| 2472 | + | |
2473 | 2473 |
| |
2474 | 2474 |
| |
2475 | 2475 |
| |
| |||
2503 | 2503 |
| |
2504 | 2504 |
| |
2505 | 2505 |
| |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
2506 | 2514 |
| |
2507 | 2515 |
| |
2508 | 2516 |
| |
| |||
2519 | 2527 |
| |
2520 | 2528 |
| |
2521 | 2529 |
| |
2522 |
| - | |
2523 |
| - | |
2524 |
| - | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
2525 | 2533 |
| |
2526 | 2534 |
| |
| 2535 | + | |
2527 | 2536 |
| |
2528 | 2537 |
| |
2529 | 2538 |
| |
| |||
2532 | 2541 |
| |
2533 | 2542 |
| |
2534 | 2543 |
| |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
2535 | 2550 |
| |
2536 | 2551 |
| |
2537 | 2552 |
| |
2538 | 2553 |
| |
2539 | 2554 |
| |
2540 |
| - | |
| 2555 | + | |
| 2556 | + | |
2541 | 2557 |
| |
2542 | 2558 |
| |
2543 | 2559 |
| |
2544 | 2560 |
| |
2545 | 2561 |
| |
2546 | 2562 |
| |
| 2563 | + | |
2547 | 2564 |
| |
2548 | 2565 |
| |
2549 | 2566 |
| |
| |||
2566 | 2583 |
| |
2567 | 2584 |
| |
2568 | 2585 |
| |
| 2586 | + | |
2569 | 2587 |
| |
2570 | 2588 |
| |
2571 | 2589 |
| |
| |||
2763 | 2781 |
| |
2764 | 2782 |
| |
2765 | 2783 |
| |
2766 |
| - | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
2767 | 2791 |
| |
2768 | 2792 |
| |
2769 | 2793 |
| |
| |||
2931 | 2955 |
| |
2932 | 2956 |
| |
2933 | 2957 |
| |
2934 |
| - | |
| 2958 | + | |
| 2959 | + | |
2935 | 2960 |
| |
2936 |
| - | |
2937 |
| - | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
2938 | 2974 |
| |
2939 | 2975 |
| |
2940 | 2976 |
| |
| |||
3010 | 3046 |
| |
3011 | 3047 |
| |
3012 | 3048 |
| |
| 3049 | + | |
3013 | 3050 |
|
Lines changed: 11 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 |
| - | |
73 |
| - | |
| 72 | + | |
| 73 | + | |
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
79 | 78 |
| |
80 | 79 |
| |
81 | 80 |
| |
| |||
88 | 87 |
| |
89 | 88 |
| |
90 | 89 |
| |
91 |
| - | |
| 90 | + | |
92 | 91 |
| |
93 | 92 |
| |
94 | 93 |
| |
| |||
306 | 305 |
| |
307 | 306 |
| |
308 | 307 |
| |
309 |
| - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
310 | 312 |
| |
311 | 313 |
| |
312 | 314 |
| |
313 | 315 |
| |
314 | 316 |
| |
315 | 317 |
| |
316 |
| - | |
| 318 | + | |
| 319 | + | |
317 | 320 |
| |
318 | 321 |
| |
319 | 322 |
| |
| |||
335 | 338 |
| |
336 | 339 |
| |
337 | 340 |
| |
338 |
| - | |
| 341 | + | |
| 342 | + | |
339 | 343 |
| |
340 | 344 |
| |
341 | 345 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
111 |
| - | |
112 | 111 |
| |
113 | 112 |
| |
114 | 113 |
| |
| |||
370 | 369 |
| |
371 | 370 |
| |
372 | 371 |
| |
373 |
| - | |
| 372 | + | |
374 | 373 |
| |
375 | 374 |
| |
376 | 375 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3985 | 3985 |
| |
3986 | 3986 |
| |
3987 | 3987 |
| |
3988 |
| - | |
| 3988 | + | |
| 3989 | + | |
3989 | 3990 |
| |
3990 | 3991 |
| |
3991 | 3992 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2674 | 2674 |
| |
2675 | 2675 |
| |
2676 | 2676 |
| |
2677 |
| - | |
| 2677 | + | |
2678 | 2678 |
| |
2679 | 2679 |
| |
2680 | 2680 |
| |
| |||
2827 | 2827 |
| |
2828 | 2828 |
| |
2829 | 2829 |
| |
2830 |
| - | |
| 2830 | + | |
2831 | 2831 |
| |
2832 | 2832 |
| |
2833 | 2833 |
| |
| |||
3054 | 3054 |
| |
3055 | 3055 |
| |
3056 | 3056 |
| |
3057 |
| - | |
| 3057 | + | |
3058 | 3058 |
| |
3059 | 3059 |
| |
3060 | 3060 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
236 |
| - | |
| 236 | + | |
| 237 | + | |
237 | 238 |
| |
238 | 239 |
| |
239 | 240 |
| |
|
Lines changed: 18 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1169 | 1169 |
| |
1170 | 1170 |
| |
1171 | 1171 |
| |
1172 |
| - | |
1173 |
| - | |
| 1172 | + | |
1174 | 1173 |
| |
1175 | 1174 |
| |
| 1175 | + | |
1176 | 1176 |
| |
1177 | 1177 |
| |
1178 |
| - | |
1179 |
| - | |
1180 |
| - | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
1181 | 1182 |
| |
1182 | 1183 |
| |
1183 | 1184 |
| |
| |||
1211 | 1212 |
| |
1212 | 1213 |
| |
1213 | 1214 |
| |
1214 |
| - | |
1215 |
| - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1216 | 1218 |
| |
1217 | 1219 |
| |
1218 | 1220 |
| |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1219 | 1230 |
| |
1220 | 1231 |
| |
1221 | 1232 |
| |
|
0 commit comments
Comments
(0)