forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita71cfc5
committed
Fix bugs in RETURNING in cross-partition UPDATE cases.
If the source and destination partitions don't have identicalrowtypes (for example, one has dropped columns the other lacks),then the planSlot contents will be different because of that.If the query has a RETURNING list that tries to return resjunkcolumns out of the planSlot, that is columns from tables thatwere joined to the target table, we'd get errors or wrong answers.That's because we used the RETURNING list generated for thedestination partition, which expects a planSlot matching thatpartition's subplan.The most practical fix seems to be to convert the updated destinationtuple back to the source partition's rowtype, and then apply theRETURNING list generated for the source partition. This avoids makingfragile assumptions about whether the per-subpartition subplansgenerated all the resjunk columns in the same order.This has been broken since v11 introduced cross-partition UPDATE.The lack of field complaints shows that non-identical partitionsaren't a common case; therefore, don't stress too hard aboutmaking the conversion efficient.There's no such bug in HEAD, because commit86dc900 got rid ofper-target-relation variance in the contents of the planSlot.Hence, patch v11-v13 only.Amit Langote and Etsuro Fujita, small changes by meDiscussion:https://postgr.es/m/CA+HiwqE_UK1jTSNrjb8mpTdivzd3dum6mK--xqKq0Y9VmfwWQA@mail.gmail.com1 parent574a1b8 commita71cfc5
File tree
3 files changed
+141
-12
lines changed- src
- backend/executor
- test/regress
- expected
- sql
3 files changed
+141
-12
lines changedLines changed: 76 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
152 |
| - | |
| 152 | + | |
| 153 | + | |
153 | 154 |
| |
154 | 155 |
| |
155 | 156 |
| |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
156 | 161 |
| |
157 | 162 |
| |
158 | 163 |
| |
159 | 164 |
| |
160 | 165 |
| |
161 | 166 |
| |
162 |
| - | |
| 167 | + | |
| 168 | + | |
163 | 169 |
| |
164 | 170 |
| |
165 | 171 |
| |
166 |
| - | |
167 | 172 |
| |
168 | 173 |
| |
169 | 174 |
| |
170 | 175 |
| |
171 | 176 |
| |
| 177 | + | |
| 178 | + | |
172 | 179 |
| |
173 | 180 |
| |
174 | 181 |
| |
175 |
| - | |
176 |
| - | |
| 182 | + | |
| 183 | + | |
177 | 184 |
| |
178 |
| - | |
179 |
| - | |
| 185 | + | |
180 | 186 |
| |
181 | 187 |
| |
182 | 188 |
| |
| |||
368 | 374 |
| |
369 | 375 |
| |
370 | 376 |
| |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
371 | 387 |
| |
372 | 388 |
| |
373 | 389 |
| |
374 | 390 |
| |
375 | 391 |
| |
376 | 392 |
| |
377 | 393 |
| |
| 394 | + | |
| 395 | + | |
378 | 396 |
| |
379 | 397 |
| |
380 | 398 |
| |
| |||
677 | 695 |
| |
678 | 696 |
| |
679 | 697 |
| |
680 |
| - | |
681 |
| - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
682 | 737 |
| |
683 | 738 |
| |
684 | 739 |
| |
| |||
1027 | 1082 |
| |
1028 | 1083 |
| |
1029 | 1084 |
| |
1030 |
| - | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1031 | 1088 |
| |
1032 | 1089 |
| |
1033 | 1090 |
| |
| |||
1203 | 1260 |
| |
1204 | 1261 |
| |
1205 | 1262 |
| |
| 1263 | + | |
1206 | 1264 |
| |
1207 | 1265 |
| |
1208 | 1266 |
| |
| |||
1309 | 1367 |
| |
1310 | 1368 |
| |
1311 | 1369 |
| |
| 1370 | + | |
1312 | 1371 |
| |
1313 | 1372 |
| |
1314 | 1373 |
| |
| |||
1505 | 1564 |
| |
1506 | 1565 |
| |
1507 | 1566 |
| |
1508 |
| - | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
1509 | 1570 |
| |
1510 | 1571 |
| |
1511 | 1572 |
| |
| |||
2154 | 2215 |
| |
2155 | 2216 |
| |
2156 | 2217 |
| |
2157 |
| - | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
2158 | 2221 |
| |
2159 | 2222 |
| |
2160 | 2223 |
| |
| |||
2244 | 2307 |
| |
2245 | 2308 |
| |
2246 | 2309 |
| |
| 2310 | + | |
2247 | 2311 |
| |
2248 | 2312 |
| |
2249 | 2313 |
| |
|
Lines changed: 40 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
445 | 445 |
| |
446 | 446 |
| |
447 | 447 |
| |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
448 | 488 |
| |
449 | 489 |
| |
450 | 490 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
236 | 236 |
| |
237 | 237 |
| |
238 | 238 |
| |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
239 | 264 |
| |
240 | 265 |
| |
241 | 266 |
| |
|
0 commit comments
Comments
(0)