forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit54889ea
committed
Correctly identify which EC members are computable at a plan node.
find_computable_ec_member() had the wrong mental model of whatits primary caller prepare_sort_from_pathkeys() would do withthe selected EquivalenceClass member expression. We will notcompute the EC expression in a plan node atop the one returningthe passed-in targetlist; rather, the EC expression will becomputed as an additional column of that targetlist. So anyVar or quasi-Var used in the given tlist is also available to theEC expression. In simple cases this makes no difference becausethe given tlist is just a list of Vars or quasi-Vars --- but ifwe are considering an appendrel member produced by flatteninga UNION ALL, the tlist may contain expressions, resulting infailure to match and a "could not find pathkey item to sort"error.To fix, we can flatten both the tlist and the EC members withpull_var_clause(), and then just check for subset-ness, sothat the code is actually shorter than before.While this bug is quite old, the present patch only works back tov13. We could possibly make it work in v12 by back-patching partsof3753982. On the whole though I don't like the risk/rewardratio of that idea. v12's final release is next month, meaningthere would be no chance to correct matters if the patch causes aregression. Since this failure has escaped notice for 14 years,it's likely nobody will hit it in the field with v12.Per bug #18652 from Alexander Lakhin.Andrei Lepikhov and Tom LaneDiscussion:https://postgr.es/m/18652-deaa782ebcca85d1@postgresql.org1 parentff33df2 commit54889ea
File tree
3 files changed
+71
-38
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+71
-38
lines changedLines changed: 33 additions & 38 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
42 | 41 |
| |
43 | 42 |
| |
44 | 43 |
| |
| |||
806 | 805 |
| |
807 | 806 |
| |
808 | 807 |
| |
809 |
| - | |
810 |
| - | |
811 |
| - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
812 | 820 |
| |
813 | 821 |
| |
814 | 822 |
| |
| |||
828 | 836 |
| |
829 | 837 |
| |
830 | 838 |
| |
| 839 | + | |
831 | 840 |
| |
832 | 841 |
| |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
833 | 853 |
| |
834 | 854 |
| |
835 | 855 |
| |
836 |
| - | |
| 856 | + | |
837 | 857 |
| |
838 | 858 |
| |
839 | 859 |
| |
| |||
851 | 871 |
| |
852 | 872 |
| |
853 | 873 |
| |
854 |
| - | |
| 874 | + | |
855 | 875 |
| |
856 |
| - | |
857 |
| - | |
858 |
| - | |
859 |
| - | |
860 |
| - | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
861 | 881 |
| |
862 |
| - | |
| 882 | + | |
863 | 883 |
| |
864 | 884 |
| |
865 |
| - | |
| 885 | + | |
866 | 886 |
| |
867 | 887 |
| |
868 | 888 |
| |
| |||
880 | 900 |
| |
881 | 901 |
| |
882 | 902 |
| |
883 |
| - | |
884 |
| - | |
885 |
| - | |
886 |
| - | |
887 |
| - | |
888 |
| - | |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 |
| - | |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 |
| - | |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
906 |
| - | |
907 |
| - | |
908 | 903 |
| |
909 | 904 |
| |
910 | 905 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1677 | 1677 |
| |
1678 | 1678 |
| |
1679 | 1679 |
| |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1680 | 1710 |
| |
1681 | 1711 |
| |
1682 | 1712 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
601 | 601 |
| |
602 | 602 |
| |
603 | 603 |
| |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
604 | 612 |
| |
605 | 613 |
| |
606 | 614 |
| |
|
0 commit comments
Comments
(0)