forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf3b3b8d
committed
Compute correct em_nullable_relids in get_eclass_for_sort_expr().
Bug #8591 from Claudio Freire demonstrates that get_eclass_for_sort_exprmust be able to compute valid em_nullable_relids for any new equivalenceclass members it creates. I'd worried about this in the commit messagefordb9f0e1, but claimed that it wasn't aproblem because multi-member ECs should already exist when it runs. Thatis transparently wrong, though, because this function is also called byinitialize_mergeclause_eclasses, which runs during deconstruct_jointree.The example given in the bug report (which the new regression test itemis based upon) fails because the COALESCE() expression is first seen byinitialize_mergeclause_eclasses rather than process_equivalence.Fixing this requires passing the appropriate nullable_relids set toget_eclass_for_sort_expr, and it requires new code to compute that setfor top-level expressions such as ORDER BY, GROUP BY, etc. We storethe top-level nullable_relids in a new field in PlannerInfo to avoidcomputing it many times. In the back branches, I've added the newfield at the end of the struct to minimize ABI breakage for plannerplugins. There doesn't seem to be a good alternative to changingget_eclass_for_sort_expr's API signature, though. There probably aren'tany third-party extensions calling that function directly; moreover,if there are, they probably need to think about what to pass fornullable_relids anyway.Back-patch to 9.2, like the previous patch in this area.1 parentc7b849a commitf3b3b8d
File tree
8 files changed
+119
-7
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- include
- nodes
- optimizer
- test/regress
- expected
- sql
8 files changed
+119
-7
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1698 | 1698 |
| |
1699 | 1699 |
| |
1700 | 1700 |
| |
| 1701 | + | |
1701 | 1702 |
| |
1702 | 1703 |
| |
1703 | 1704 |
| |
|
Lines changed: 17 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
510 | 510 |
| |
511 | 511 |
| |
512 | 512 |
| |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
513 | 520 |
| |
514 | 521 |
| |
515 | 522 |
| |
| |||
538 | 545 |
| |
539 | 546 |
| |
540 | 547 |
| |
| 548 | + | |
541 | 549 |
| |
542 | 550 |
| |
543 | 551 |
| |
544 | 552 |
| |
545 | 553 |
| |
546 | 554 |
| |
547 | 555 |
| |
| 556 | + | |
548 | 557 |
| |
549 | 558 |
| |
550 | 559 |
| |
| |||
555 | 564 |
| |
556 | 565 |
| |
557 | 566 |
| |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
558 | 573 |
| |
559 | 574 |
| |
560 | 575 |
| |
| |||
629 | 644 |
| |
630 | 645 |
| |
631 | 646 |
| |
632 |
| - | |
633 |
| - | |
| 647 | + | |
| 648 | + | |
634 | 649 |
| |
635 | 650 |
| |
636 | 651 |
| |
|
Lines changed: 28 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
154 | 154 |
| |
155 | 155 |
| |
156 | 156 |
| |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 |
| |
158 | 161 |
| |
159 | 162 |
| |
| |||
169 | 172 |
| |
170 | 173 |
| |
171 | 174 |
| |
| 175 | + | |
172 | 176 |
| |
173 | 177 |
| |
174 | 178 |
| |
| |||
204 | 208 |
| |
205 | 209 |
| |
206 | 210 |
| |
207 |
| - | |
208 |
| - | |
| 211 | + | |
| 212 | + | |
209 | 213 |
| |
210 | 214 |
| |
211 | 215 |
| |
| |||
227 | 231 |
| |
228 | 232 |
| |
229 | 233 |
| |
| 234 | + | |
230 | 235 |
| |
231 | 236 |
| |
232 | 237 |
| |
| |||
248 | 253 |
| |
249 | 254 |
| |
250 | 255 |
| |
| 256 | + | |
251 | 257 |
| |
252 | 258 |
| |
253 | 259 |
| |
| |||
461 | 467 |
| |
462 | 468 |
| |
463 | 469 |
| |
464 |
| - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
465 | 474 |
| |
466 | 475 |
| |
| 476 | + | |
467 | 477 |
| |
468 | 478 |
| |
469 | 479 |
| |
| |||
551 | 561 |
| |
552 | 562 |
| |
553 | 563 |
| |
554 |
| - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
555 | 567 |
| |
556 | 568 |
| |
557 | 569 |
| |
558 | 570 |
| |
| 571 | + | |
559 | 572 |
| |
560 | 573 |
| |
561 | 574 |
| |
| |||
643 | 656 |
| |
644 | 657 |
| |
645 | 658 |
| |
| 659 | + | |
646 | 660 |
| |
647 | 661 |
| |
648 | 662 |
| |
| |||
748 | 762 |
| |
749 | 763 |
| |
750 | 764 |
| |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
751 | 772 |
| |
752 | 773 |
| |
753 | 774 |
| |
| |||
769 | 790 |
| |
770 | 791 |
| |
771 | 792 |
| |
| 793 | + | |
772 | 794 |
| |
773 | 795 |
| |
774 | 796 |
| |
| |||
824 | 846 |
| |
825 | 847 |
| |
826 | 848 |
| |
| 849 | + | |
827 | 850 |
| |
828 | 851 |
| |
829 | 852 |
| |
| |||
833 | 856 |
| |
834 | 857 |
| |
835 | 858 |
| |
| 859 | + | |
836 | 860 |
| |
837 | 861 |
| |
838 | 862 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
649 | 649 |
| |
650 | 650 |
| |
651 | 651 |
| |
| 652 | + | |
| 653 | + | |
| 654 | + | |
652 | 655 |
| |
653 | 656 |
| |
654 | 657 |
| |
| |||
790 | 793 |
| |
791 | 794 |
| |
792 | 795 |
| |
| 796 | + | |
793 | 797 |
| |
794 | 798 |
| |
795 | 799 |
| |
| |||
823 | 827 |
| |
824 | 828 |
| |
825 | 829 |
| |
| 830 | + | |
| 831 | + | |
826 | 832 |
| |
827 | 833 |
| |
828 | 834 |
| |
| |||
837 | 843 |
| |
838 | 844 |
| |
839 | 845 |
| |
| 846 | + | |
840 | 847 |
| |
841 | 848 |
| |
842 | 849 |
| |
| |||
851 | 858 |
| |
852 | 859 |
| |
853 | 860 |
| |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
854 | 868 |
| |
855 | 869 |
| |
856 | 870 |
| |
| |||
865 | 879 |
| |
866 | 880 |
| |
867 | 881 |
| |
| 882 | + | |
868 | 883 |
| |
869 | 884 |
| |
870 | 885 |
| |
871 | 886 |
| |
872 | 887 |
| |
873 | 888 |
| |
| 889 | + | |
874 | 890 |
| |
875 | 891 |
| |
876 | 892 |
| |
877 | 893 |
| |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
878 | 898 |
| |
879 | 899 |
| |
880 | 900 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
150 | 150 |
| |
151 | 151 |
| |
152 | 152 |
| |
153 |
| - | |
| 153 | + | |
| 154 | + | |
154 | 155 |
| |
155 | 156 |
| |
156 | 157 |
| |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
157 | 166 |
| |
158 | 167 |
| |
159 | 168 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
| 112 | + | |
112 | 113 |
| |
113 | 114 |
| |
114 | 115 |
| |
|
Lines changed: 29 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2900 | 2900 |
| |
2901 | 2901 |
| |
2902 | 2902 |
| |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
2903 | 2932 |
| |
2904 | 2933 |
| |
2905 | 2934 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
790 | 790 |
| |
791 | 791 |
| |
792 | 792 |
| |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
793 | 806 |
| |
794 | 807 |
| |
795 | 808 |
| |
|
0 commit comments
Comments
(0)