forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf9f63ed
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 parent0226cd7 commitf9f63ed
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 | |
---|---|---|---|
| |||
2269 | 2269 |
| |
2270 | 2270 |
| |
2271 | 2271 |
| |
2272 |
| - | |
2273 |
| - | |
2274 | 2272 |
| |
2275 | 2273 |
| |
2276 | 2274 |
| |
| |||
2288 | 2286 |
| |
2289 | 2287 |
| |
2290 | 2288 |
| |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
2291 | 2292 |
| |
2292 | 2293 |
| |
2293 | 2294 |
| |
| |||
2375 | 2376 |
| |
2376 | 2377 |
| |
2377 | 2378 |
| |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
2378 | 2389 |
| |
2379 | 2390 |
| |
2380 | 2391 |
| |
| |||
2399 | 2410 |
| |
2400 | 2411 |
| |
2401 | 2412 |
| |
2402 |
| - | |
2403 |
| - | |
2404 |
| - | |
2405 |
| - | |
2406 |
| - | |
2407 |
| - | |
2408 |
| - | |
2409 |
| - | |
2410 |
| - | |
2411 | 2413 |
| |
2412 | 2414 |
| |
2413 | 2415 |
| |
|
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)