forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit10bad8c
committed
Repair bogus handling of multi-assignment Params in upper plan levels.
Our support for multiple-set-clauses in UPDATE assumes that the Paramsreferencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlanin the targetlist of the plan node that calculates the updated row.(Yeah, it's a hack...) In some PG branches it's possible that a Resultnode gets inserted between the primary calculation of the update tlistand the ModifyTable node. setrefs.c did the wrong thing in this caseand left the upper-level Params as Params, causing a crash at runtime.What it should do is replace them with "outer" Vars referencing the childplan node's output. That's a result of careless ordering of operationsin fix_upper_expr_mutator, so we can fix it just by reordering the code.Fix fix_join_expr_mutator similarly for consistency, even though joinnodes could never appear in such a context. (In general, it seemslikely to be a bit cheaper to use Vars than Params in such situationsanyway, so this patch might offer a tiny performance improvement.)The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuffwas introduced, so back-patch that far. However, this may be a livebug only in 9.6.x and 10.x, as the other branches don't seem to wantto calculate the final tlist below the Result node. (That plan shapechange between branches might be a mini-bug in itself, but I'm notreally interested in digging into the reasons for that right now.Still, add a regression test memorializing what we expect there,so we'll notice if it changes again.)Per bug report from Eduards Bezverhijs.Discussion:https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com1 parentd2267b6 commit10bad8c
File tree
3 files changed
+54
-11
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+54
-11
lines changedLines changed: 13 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2210 | 2210 |
| |
2211 | 2211 |
| |
2212 | 2212 |
| |
2213 |
| - | |
2214 |
| - | |
2215 | 2213 |
| |
2216 | 2214 |
| |
2217 | 2215 |
| |
| |||
2229 | 2227 |
| |
2230 | 2228 |
| |
2231 | 2229 |
| |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
2232 | 2233 |
| |
2233 | 2234 |
| |
2234 | 2235 |
| |
| |||
2316 | 2317 |
| |
2317 | 2318 |
| |
2318 | 2319 |
| |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
2319 | 2330 |
| |
2320 | 2331 |
| |
2321 | 2332 |
| |
| |||
2340 | 2351 |
| |
2341 | 2352 |
| |
2342 | 2353 |
| |
2343 |
| - | |
2344 |
| - | |
2345 |
| - | |
2346 |
| - | |
2347 |
| - | |
2348 |
| - | |
2349 |
| - | |
2350 |
| - | |
2351 |
| - | |
2352 | 2354 |
| |
2353 | 2355 |
| |
2354 | 2356 |
| |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
169 | 169 |
| |
170 | 170 |
| |
171 | 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 | + | |
172 | 203 |
| |
173 | 204 |
| |
174 | 205 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
91 | 101 |
| |
92 | 102 |
| |
93 | 103 |
| |
|
0 commit comments
Comments
(0)