- Notifications
You must be signed in to change notification settings - Fork5k
Commitce4f46f
committed
Change mechanism to set up source targetlist in MERGE
We were setting MERGE source subplan's targetlist by expanding theindividual attributes of the source relation completely, early in theparse analysis phase. This failed to work when the condition of anaction included a whole-row reference, causing setrefs.c to error outwith ERROR: variable not found in subplan target listsbecause at that point there is nothing to resolve the whole-rowreference with. We can fix this by having preprocess_targetlist expandthe source targetlist for Vars required from the source rel by allactions. Moreover, by using this expansion mechanism we can do awaywith the targetlist expansion in transformMergeStmt, which is goodbecause then we no longer pull in columns that aren't needed foranything.Add a test case for the problem.While at it, remove some redundant code in preprocess_targetlist():MERGE was doing separately what is already being done for UPDATE/DELETE,so we can just rely on the latter and remove the former. (The handlingof inherited rels was different for MERGE, but that was a no-longer-necessary hack.)Fix outdated, related comments for fix_join_expr also.Author: Richard Guo <guofenglinux@gmail.com>Author: Álvaro Herrera <alvherre@alvh.no-ip.org>Reported-by: Joe Wildish <joe@lateraljoin.com>Discussion:https://postgr.es/m/fab3b90a-914d-46a9-beb0-df011ee39ee5@www.fastmail.com1 parenta4b5754 commitce4f46f
File tree
6 files changed
+80
-27
lines changed- src
- backend
- optimizer
- plan
- prep
- parser
- test/regress
- expected
- sql
6 files changed
+80
-27
lines changedLines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2748 | 2748 |
| |
2749 | 2749 |
| |
2750 | 2750 |
| |
2751 |
| - | |
| 2751 | + | |
2752 | 2752 |
| |
2753 | 2753 |
| |
2754 | 2754 |
| |
| |||
2763 | 2763 |
| |
2764 | 2764 |
| |
2765 | 2765 |
| |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
2766 | 2771 |
| |
2767 | 2772 |
| |
2768 | 2773 |
| |
|
Lines changed: 44 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
116 | 116 |
| |
117 |
| - | |
| 117 | + | |
| 118 | + | |
118 | 119 |
| |
119 | 120 |
| |
120 | 121 |
| |
| |||
125 | 126 |
| |
126 | 127 |
| |
127 | 128 |
| |
128 |
| - | |
129 |
| - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
130 | 133 |
| |
131 | 134 |
| |
132 | 135 |
| |
133 | 136 |
| |
134 | 137 |
| |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 | 138 |
| |
146 | 139 |
| |
147 | 140 |
| |
| |||
151 | 144 |
| |
152 | 145 |
| |
153 | 146 |
| |
| 147 | + | |
| 148 | + | |
154 | 149 |
| |
155 | 150 |
| |
156 | 151 |
| |
157 | 152 |
| |
158 | 153 |
| |
159 | 154 |
| |
160 | 155 |
| |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
161 | 186 |
| |
162 | 187 |
| |
163 | 188 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
22 | 21 |
| |
23 | 22 |
| |
24 | 23 |
| |
| |||
205 | 204 |
| |
206 | 205 |
| |
207 | 206 |
| |
208 |
| - | |
209 |
| - | |
210 |
| - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
211 | 212 |
| |
212 | 213 |
| |
213 | 214 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
791 | 791 |
| |
792 | 792 |
| |
793 | 793 |
| |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
794 | 807 |
| |
795 | 808 |
| |
796 | 809 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2800 | 2800 |
| |
2801 | 2801 |
| |
2802 | 2802 |
| |
2803 |
| - | |
| 2803 | + | |
2804 | 2804 |
| |
2805 | 2805 |
| |
2806 | 2806 |
| |
| |||
2847 | 2847 |
| |
2848 | 2848 |
| |
2849 | 2849 |
| |
2850 |
| - | |
| 2850 | + | |
2851 | 2851 |
| |
2852 | 2852 |
| |
2853 | 2853 |
| |
| |||
2889 | 2889 |
| |
2890 | 2890 |
| |
2891 | 2891 |
| |
2892 |
| - | |
| 2892 | + | |
2893 | 2893 |
| |
2894 | 2894 |
| |
2895 | 2895 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
527 | 527 |
| |
528 | 528 |
| |
529 | 529 |
| |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
530 | 539 |
| |
531 | 540 |
| |
532 | 541 |
| |
|
0 commit comments
Comments
(0)