forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit302d4ee
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 parent4e33da5 commit302d4ee
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 | |
---|---|---|---|
| |||
2312 | 2312 |
| |
2313 | 2313 |
| |
2314 | 2314 |
| |
2315 |
| - | |
2316 |
| - | |
2317 | 2315 |
| |
2318 | 2316 |
| |
2319 | 2317 |
| |
| |||
2331 | 2329 |
| |
2332 | 2330 |
| |
2333 | 2331 |
| |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
2334 | 2335 |
| |
2335 | 2336 |
| |
2336 | 2337 |
| |
| |||
2418 | 2419 |
| |
2419 | 2420 |
| |
2420 | 2421 |
| |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
2421 | 2432 |
| |
2422 | 2433 |
| |
2423 | 2434 |
| |
| |||
2442 | 2453 |
| |
2443 | 2454 |
| |
2444 | 2455 |
| |
2445 |
| - | |
2446 |
| - | |
2447 |
| - | |
2448 |
| - | |
2449 |
| - | |
2450 |
| - | |
2451 |
| - | |
2452 |
| - | |
2453 |
| - | |
2454 | 2456 |
| |
2455 | 2457 |
| |
2456 | 2458 |
| |
|
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)