forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbf7ca15
committed
Ensure that RowExprs and whole-row Vars produce the expected column names.
At one time it wasn't terribly important what column names were associatedwith the fields of a composite Datum, but since the introduction ofoperations like row_to_json(), it's important that looking up the rowtypeID embedded in the Datum returns the column names that users would expect.That did not work terribly well before this patch: you could get the columnnames of the underlying table, or column aliases from any level of thequery, depending on minor details of the plan tree. You could even gettotally empty field names, which is disastrous for cases like row_to_json().To fix this for whole-row Vars, look to the RTE referenced by the Var, andmake sure its column aliases are applied to the rowtype associated withthe result Datums. This is a tad scary because we might have to returna transient RECORD type even though the Var is declared as having somenamed rowtype. In principle it should be all right because the recordtype will still be physically compatible with the named rowtype; butI had to weaken one Assert in ExecEvalConvertRowtype, and there might bethird-party code containing similar assumptions.Similarly, RowExprs have to be willing to override the column names comingfrom a named composite result type and produce a RECORD when the columnaliases visible at the site of the RowExpr differ from the underlyingtable's column names.In passing, revert the decision made in commit398f70e to addan alias-list argument to ExecTypeFromExprList: better to provide thatfunctionality in a separate function. This also reverts most of the codechanges ind685814, which we don't need because we're no longerdepending on the tupdesc found in the child plan node's result slot to beblessed.Back-patch to 9.4, but not earlier, since this solution changes the resultsin some cases that users might not have realized were buggy. We'll apply amore restricted form of this patch in older branches.1 parent1e0b436 commitbf7ca15
File tree
8 files changed
+340
-73
lines changed- src
- backend/executor
- include
- executor
- nodes
- test/regress
- expected
- sql
8 files changed
+340
-73
lines changedLines changed: 77 additions & 38 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| 53 | + | |
53 | 54 |
| |
54 | 55 |
| |
55 | 56 |
| |
| |||
712 | 713 |
| |
713 | 714 |
| |
714 | 715 |
| |
| 716 | + | |
| 717 | + | |
715 | 718 |
| |
716 | 719 |
| |
717 | 720 |
| |
| |||
787 | 790 |
| |
788 | 791 |
| |
789 | 792 |
| |
790 |
| - | |
791 |
| - | |
792 | 793 |
| |
793 | 794 |
| |
794 | 795 |
| |
| |||
860 | 861 |
| |
861 | 862 |
| |
862 | 863 |
| |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
863 | 873 |
| |
864 | 874 |
| |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
865 | 886 |
| |
866 |
| - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
867 | 918 |
| |
868 | 919 |
| |
869 | 920 |
| |
| |||
886 | 937 |
| |
887 | 938 |
| |
888 | 939 |
| |
889 |
| - | |
890 | 940 |
| |
891 | 941 |
| |
892 | 942 |
| |
| |||
916 | 966 |
| |
917 | 967 |
| |
918 | 968 |
| |
919 |
| - | |
920 |
| - | |
921 |
| - | |
922 |
| - | |
923 |
| - | |
924 |
| - | |
925 |
| - | |
926 |
| - | |
927 |
| - | |
928 |
| - | |
929 |
| - | |
930 |
| - | |
931 |
| - | |
932 |
| - | |
933 | 969 |
| |
934 | 970 |
| |
935 | 971 |
| |
936 | 972 |
| |
937 | 973 |
| |
938 | 974 |
| |
939 |
| - | |
940 |
| - | |
| 975 | + | |
941 | 976 |
| |
942 |
| - | |
943 |
| - | |
944 |
| - | |
945 |
| - | |
946 |
| - | |
| 977 | + | |
| 978 | + | |
947 | 979 |
| |
948 | 980 |
| |
949 | 981 |
| |
| |||
997 | 1029 |
| |
998 | 1030 |
| |
999 | 1031 |
| |
| 1032 | + | |
1000 | 1033 |
| |
1001 |
| - | |
| 1034 | + | |
1002 | 1035 |
| |
1003 | 1036 |
| |
1004 | 1037 |
| |
| |||
1025 | 1058 |
| |
1026 | 1059 |
| |
1027 | 1060 |
| |
1028 |
| - | |
| 1061 | + | |
1029 | 1062 |
| |
1030 |
| - | |
1031 |
| - | |
1032 |
| - | |
1033 |
| - | |
| 1063 | + | |
| 1064 | + | |
1034 | 1065 |
| |
1035 | 1066 |
| |
1036 | 1067 |
| |
| |||
2850 | 2881 |
| |
2851 | 2882 |
| |
2852 | 2883 |
| |
2853 |
| - | |
2854 |
| - | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
2855 | 2892 |
| |
2856 | 2893 |
| |
2857 | 2894 |
| |
| |||
4375 | 4412 |
| |
4376 | 4413 |
| |
4377 | 4414 |
| |
| 4415 | + | |
4378 | 4416 |
| |
4379 | 4417 |
| |
4380 | 4418 |
| |
| |||
4778 | 4816 |
| |
4779 | 4817 |
| |
4780 | 4818 |
| |
4781 |
| - | |
4782 |
| - | |
4783 |
| - | |
4784 |
| - | |
4785 |
| - | |
| 4819 | + | |
| 4820 | + | |
4786 | 4821 |
| |
4787 | 4822 |
| |
4788 | 4823 |
| |
4789 | 4824 |
| |
4790 | 4825 |
| |
4791 | 4826 |
| |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
4792 | 4831 |
| |
4793 | 4832 |
| |
4794 | 4833 |
| |
|
Lines changed: 55 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
943 | 943 |
| |
944 | 944 |
| |
945 | 945 |
| |
946 |
| - | |
| 946 | + | |
| 947 | + | |
947 | 948 |
| |
948 | 949 |
| |
949 |
| - | |
| 950 | + | |
950 | 951 |
| |
951 | 952 |
| |
952 |
| - | |
953 |
| - | |
| 953 | + | |
954 | 954 |
| |
955 | 955 |
| |
956 |
| - | |
957 |
| - | |
958 | 956 |
| |
959 | 957 |
| |
960 |
| - | |
| 958 | + | |
961 | 959 |
| |
962 |
| - | |
963 |
| - | |
| 960 | + | |
964 | 961 |
| |
965 | 962 |
| |
966 | 963 |
| |
967 |
| - | |
| 964 | + | |
968 | 965 |
| |
969 | 966 |
| |
970 | 967 |
| |
| |||
977 | 974 |
| |
978 | 975 |
| |
979 | 976 |
| |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
980 | 1025 |
| |
981 | 1026 |
| |
982 | 1027 |
| |
|
Lines changed: 0 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
29 |
| - | |
30 | 29 |
| |
31 | 30 |
| |
32 | 31 |
| |
| |||
279 | 278 |
| |
280 | 279 |
| |
281 | 280 |
| |
282 |
| - | |
283 |
| - | |
284 | 281 |
| |
285 | 282 |
| |
286 | 283 |
| |
| |||
494 | 491 |
| |
495 | 492 |
| |
496 | 493 |
| |
497 |
| - | |
498 |
| - | |
499 |
| - | |
500 |
| - | |
501 |
| - | |
502 |
| - | |
503 |
| - | |
504 |
| - | |
505 |
| - | |
506 |
| - | |
507 |
| - | |
508 |
| - | |
509 |
| - | |
510 |
| - | |
511 |
| - | |
512 |
| - | |
513 | 494 |
| |
514 | 495 |
| |
515 | 496 |
| |
|
Lines changed: 1 addition & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
29 | 28 |
| |
30 | 29 |
| |
31 | 30 |
| |
| |||
189 | 188 |
| |
190 | 189 |
| |
191 | 190 |
| |
192 |
| - | |
193 |
| - | |
194 | 191 |
| |
195 | 192 |
| |
196 | 193 |
| |
| |||
242 | 239 |
| |
243 | 240 |
| |
244 | 241 |
| |
245 |
| - | |
246 |
| - | |
| 242 | + | |
247 | 243 |
| |
248 | 244 |
| |
249 | 245 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
268 | 268 |
| |
269 | 269 |
| |
270 | 270 |
| |
271 |
| - | |
| 271 | + | |
| 272 | + | |
272 | 273 |
| |
273 | 274 |
| |
274 | 275 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
578 | 578 |
| |
579 | 579 |
| |
580 | 580 |
| |
| 581 | + | |
581 | 582 |
| |
582 | 583 |
| |
583 | 584 |
| |
|
0 commit comments
Comments
(0)