forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf4e7756
committed
Build whole-row Vars the same way during parsing and planning.
makeWholeRowVar() has different rules for constructing awhole-row Var depending on the kind of RTE it's representing.This turns out to be problematic because the rewriter and plannercan convert view RTEs and set-returning-function RTEs intosubquery RTEs; so a whole-row Var made during planning mightlook different from one made by the parser. In isolation thisdoesn't cause any problem, but if a query contains Vars madeboth ways for the same varno, there are cross-checks in theexecutor that will complain. This manifests for UPDATE, DELETE,and MERGE queries that use whole-row table references.To fix, we need makeWholeRowVar() to produce the same resultfrom an inlined RTE as it would have for the original. Foran inlined view, we can use RangeTblEntry.relid to detectthat this had been a view RTE. For inlined SRFs, make adata structure definition change akin to commit47bb9db,and say that we won't clear RangeTblEntry.functions untilthe end of planning. That allows makeWholeRowVar() torepeat what it would have done with the unmodified RTE.Reported-by: Duncan Sands <duncan.sands@deepbluecap.com>Reported-by: Dean Rasheed <dean.a.rasheed@gmail.com>Diagnosed-by: Tender Wang <tndrwang@gmail.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Discussion:https://postgr.es/m/3518c50a-ab18-482f-b916-a37263622501@deepbluecap.comBackpatch-through: 131 parent18cd15e commitf4e7756
File tree
4 files changed
+140
-5
lines changed- src
- backend
- nodes
- optimizer/prep
- test/regress
- expected
- sql
4 files changed
+140
-5
lines changedLines changed: 49 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
161 | 161 |
| |
162 | 162 |
| |
163 | 163 |
| |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
164 | 211 |
| |
165 | 212 |
| |
166 | 213 |
| |
| |||
217 | 264 |
| |
218 | 265 |
| |
219 | 266 |
| |
220 |
| - | |
221 |
| - | |
| 267 | + | |
| 268 | + | |
222 | 269 |
| |
223 | 270 |
| |
224 | 271 |
| |
|
Lines changed: 8 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
914 | 914 |
| |
915 | 915 |
| |
916 | 916 |
| |
917 |
| - | |
918 |
| - | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
919 | 925 |
| |
920 | 926 |
| |
921 | 927 |
| |
|
Lines changed: 59 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
286 | 286 |
| |
287 | 287 |
| |
288 | 288 |
| |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
289 | 346 |
| |
290 | 347 |
| |
291 | 348 |
| |
| |||
726 | 783 |
| |
727 | 784 |
| |
728 | 785 |
| |
729 |
| - | |
| 786 | + | |
730 | 787 |
| |
| 788 | + | |
731 | 789 |
| |
732 | 790 |
| |
733 | 791 |
| |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
132 | 132 |
| |
133 | 133 |
| |
134 | 134 |
| |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
135 | 159 |
| |
136 | 160 |
| |
137 | 161 |
| |
|
0 commit comments
Comments
(0)