forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0f7ec8d
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 parentcc53123 commit0f7ec8d
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 | |
---|---|---|---|
| |||
2325 | 2325 |
| |
2326 | 2326 |
| |
2327 | 2327 |
| |
2328 |
| - | |
2329 |
| - | |
2330 | 2328 |
| |
2331 | 2329 |
| |
2332 | 2330 |
| |
| |||
2344 | 2342 |
| |
2345 | 2343 |
| |
2346 | 2344 |
| |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
2347 | 2348 |
| |
2348 | 2349 |
| |
2349 | 2350 |
| |
| |||
2431 | 2432 |
| |
2432 | 2433 |
| |
2433 | 2434 |
| |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
2434 | 2445 |
| |
2435 | 2446 |
| |
2436 | 2447 |
| |
| |||
2455 | 2466 |
| |
2456 | 2467 |
| |
2457 | 2468 |
| |
2458 |
| - | |
2459 |
| - | |
2460 |
| - | |
2461 |
| - | |
2462 |
| - | |
2463 |
| - | |
2464 |
| - | |
2465 |
| - | |
2466 |
| - | |
2467 | 2469 |
| |
2468 | 2470 |
| |
2469 | 2471 |
| |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
167 | 167 |
| |
168 | 168 |
| |
169 | 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 | + | |
170 | 201 |
| |
171 | 202 |
| |
172 | 203 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
92 | 102 |
| |
93 | 103 |
| |
94 | 104 |
| |
|
0 commit comments
Comments
(0)