- Notifications
You must be signed in to change notification settings - Fork5
Commitdd4134e
committed
Revisit handling of UNION ALL subqueries with non-Var output columns.
In commit57664ed I tried to fix a bugreported by Teodor Sigaev by making non-simple-Var output columns distinct(by wrapping their expressions with dummy PlaceHolderVar nodes). This didnot work too well. Commitb28ffd0 fixedsome ensuing problems with matching to child indexes, but per a recentreport from Claus Stadler, constraint exclusion of UNION ALL subqueries wasstill broken, because constant-simplification didn't handle the injectedPlaceHolderVars well either. On reflection, the original patch was quitemisguided: there is no reason to expect that EquivalenceClass child memberswill be distinct. So instead of trying to make them so, we should ensurethat we can cope with the situation when they're not.Accordingly, this patch reverts the code changes in the above-mentionedcommits (though the regression test cases they added stay). Instead, I'veadded assorted defenses to make sure that duplicate EC child members don'tcause any problems. Teodor's original problem ("MergeAppend child'stargetlist doesn't match MergeAppend") is addressed more directly byrevising prepare_sort_from_pathkeys to let the parent MergeAppend's sortlist guide creation of each child's sort list.In passing, get rid of add_sort_column; as far as I can tell, testing forduplicate sort keys at this stage is dead code. Certainly it doesn'ttrigger often enough to be worth expending cycles on in ordinary queries.And keeping the test would've greatly complicated the new logic inprepare_sort_from_pathkeys, because comparing pathkey list entries againsta previous output array requires that we not skip any entries in the list.Back-patch to 9.1, like the previous patches. The only known issue inthis area that wasn't caused by the ill-advised previous patches was theMergeAppend planning failure, which of course is not relevant before 9.1.It's possible that we need some of the new defenses against duplicate childEC entries in older branches, but until there's some clear evidence of thatI'm going to refrain from back-patching further.1 parentaef5fe7 commitdd4134e
File tree
16 files changed
+411
-258
lines changed- src
- backend/optimizer
- path
- plan
- prep
- util
- include
- nodes
- optimizer
- test/regress
- expected
- sql
16 files changed
+411
-258
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
496 | 496 |
| |
497 | 497 |
| |
498 | 498 |
| |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
499 | 507 |
| |
500 | 508 |
| |
501 | 509 |
| |
|
Lines changed: 41 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
491 | 491 |
| |
492 | 492 |
| |
493 | 493 |
| |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
494 | 503 |
| |
495 | 504 |
| |
496 | 505 |
| |
| |||
511 | 520 |
| |
512 | 521 |
| |
513 | 522 |
| |
| 523 | + | |
514 | 524 |
| |
515 | 525 |
| |
516 | 526 |
| |
| |||
548 | 558 |
| |
549 | 559 |
| |
550 | 560 |
| |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
551 | 568 |
| |
552 | 569 |
| |
553 | 570 |
| |
| |||
1505 | 1522 |
| |
1506 | 1523 |
| |
1507 | 1524 |
| |
| 1525 | + | |
1508 | 1526 |
| |
1509 | 1527 |
| |
1510 | 1528 |
| |
| |||
1626 | 1644 |
| |
1627 | 1645 |
| |
1628 | 1646 |
| |
| 1647 | + | |
1629 | 1648 |
| |
1630 | 1649 |
| |
1631 | 1650 |
| |
| |||
1747 | 1766 |
| |
1748 | 1767 |
| |
1749 | 1768 |
| |
| 1769 | + | |
| 1770 | + | |
1750 | 1771 |
| |
1751 | 1772 |
| |
1752 | 1773 |
| |
| |||
1800 | 1821 |
| |
1801 | 1822 |
| |
1802 | 1823 |
| |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
1803 | 1827 |
| |
1804 | 1828 |
| |
1805 | 1829 |
| |
| |||
1908 | 1932 |
| |
1909 | 1933 |
| |
1910 | 1934 |
| |
1911 |
| - | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
1912 | 1945 |
| |
1913 | 1946 |
| |
1914 | 1947 |
| |
| |||
1933 | 1966 |
| |
1934 | 1967 |
| |
1935 | 1968 |
| |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
1936 | 1972 |
| |
1937 | 1973 |
| |
1938 | 1974 |
| |
| |||
2187 | 2223 |
| |
2188 | 2224 |
| |
2189 | 2225 |
| |
2190 |
| - | |
2191 |
| - | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
2192 | 2230 |
| |
2193 | 2231 |
| |
2194 | 2232 |
| |
|
Lines changed: 8 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2157 | 2157 |
| |
2158 | 2158 |
| |
2159 | 2159 |
| |
2160 |
| - | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
2161 | 2168 |
| |
2162 | 2169 |
| |
2163 | 2170 |
| |
| |||
2580 | 2587 |
| |
2581 | 2588 |
| |
2582 | 2589 |
| |
2583 |
| - | |
2584 |
| - | |
2585 |
| - | |
2586 |
| - | |
2587 |
| - | |
2588 |
| - | |
2589 |
| - | |
2590 |
| - | |
2591 |
| - | |
2592 | 2590 |
| |
2593 | 2591 |
| |
2594 | 2592 |
| |
|
Lines changed: 16 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
221 | 221 |
| |
222 | 222 |
| |
223 | 223 |
| |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
224 | 229 |
| |
225 | 230 |
| |
226 | 231 |
| |
| |||
237 | 242 |
| |
238 | 243 |
| |
239 | 244 |
| |
| 245 | + | |
240 | 246 |
| |
241 | 247 |
| |
242 | 248 |
| |
| |||
268 | 274 |
| |
269 | 275 |
| |
270 | 276 |
| |
271 |
| - | |
| 277 | + | |
272 | 278 |
| |
273 | 279 |
| |
274 | 280 |
| |
| |||
320 | 326 |
| |
321 | 327 |
| |
322 | 328 |
| |
| 329 | + | |
323 | 330 |
| |
324 | 331 |
| |
325 | 332 |
| |
| |||
546 | 553 |
| |
547 | 554 |
| |
548 | 555 |
| |
| 556 | + | |
549 | 557 |
| |
550 | 558 |
| |
551 | 559 |
| |
| |||
636 | 644 |
| |
637 | 645 |
| |
638 | 646 |
| |
| 647 | + | |
639 | 648 |
| |
640 | 649 |
| |
641 | 650 |
| |
| |||
680 | 689 |
| |
681 | 690 |
| |
682 | 691 |
| |
| 692 | + | |
| 693 | + | |
| 694 | + | |
683 | 695 |
| |
684 | 696 |
| |
685 | 697 |
| |
| |||
719 | 731 |
| |
720 | 732 |
| |
721 | 733 |
| |
| 734 | + | |
722 | 735 |
| |
723 | 736 |
| |
724 | 737 |
| |
| |||
910 | 923 |
| |
911 | 924 |
| |
912 | 925 |
| |
| 926 | + | |
913 | 927 |
| |
914 | 928 |
| |
915 | 929 |
| |
| |||
918 | 932 |
| |
919 | 933 |
| |
920 | 934 |
| |
| 935 | + | |
921 | 936 |
| |
922 | 937 |
| |
923 | 938 |
| |
|
0 commit comments
Comments
(0)