forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7b67a0a
committed
Fix some interrelated planner issues with initPlans and Param munging.
In commit68fa28f I tried to teach SS_finalize_plan() to cope withinitPlans attached anywhere in the plan tree, by dint of moving itshandling of those into the recursion in finalize_plan(). It turns out thatthat doesn't really work: if a lower-level plan node emits an initPlanoutput parameter in its targetlist, it's legitimate for upper levels toreference those Params --- and at the point where this code runs, thosereferences look just like the Param itself, so finalize_plan() quiteproperly rejects them as being in the wrong place. We could lobotomizethe checks enough to allow that, probably, but then it's not clear thatwe'd have any meaningful check for misplaced Params at all. What seemsbetter, at least in the near term, is to tweak standard_planner() a bitso that initPlans are never placed anywhere but the topmost plan nodefor a query level, restoring the behavior that occurred pre-9.6. Possiblywe can do better if this code is ever merged into setrefs.c: then it wouldbe possible to check a Param's placement only when we'd failed to replaceit with a Var referencing a child plan node's targetlist.BTW, I'm now suspicious that finalize_plan is doing the wrong thing byreturning the node's allParam rather than extParam to be incorporatedin the parent node's set of used parameters. However, it makes nodifference given that initPlans only appear at top level, so I'll leavethat alone for now.Another thing that emerged from this is that standard_planner() needsto check for initPlans before deciding that it's safe to stick a Gathernode on top in force_parallel_mode mode. We previously guarded againstthat by deciding the plan wasn't wholePlanParallelSafe if any subplanshad been found, but after commit5ce5e4a it's necessary to have thissubstitute test, because path parallel_safe markings don't account forinitPlans. (Normally, we'd have decided the paths weren't safe anywaydue to appearances of SubPlan nodes, Params, or CTE scans somewhere inthe tree --- but it's possible for those all to be optimized away whileinitPlans still remain.)Per fuzz testing by Andreas Seltenreich.Report: <874m89rw7x.fsf@credativ.de>1 parent48bfeb2 commit7b67a0a
File tree
5 files changed
+122
-9
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
5 files changed
+122
-9
lines changedLines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
314 | 314 |
| |
315 | 315 |
| |
316 | 316 |
| |
317 |
| - | |
318 |
| - | |
319 |
| - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
320 | 321 |
| |
321 | 322 |
| |
322 | 323 |
| |
|
Lines changed: 22 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
305 | 305 |
| |
306 | 306 |
| |
307 | 307 |
| |
308 |
| - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
309 | 323 |
| |
310 | 324 |
| |
311 | 325 |
| |
312 | 326 |
| |
313 |
| - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
314 | 331 |
| |
315 |
| - | |
316 |
| - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
317 | 335 |
| |
318 | 336 |
| |
319 | 337 |
| |
|
Lines changed: 15 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2187 | 2187 |
| |
2188 | 2188 |
| |
2189 | 2189 |
| |
2190 |
| - | |
| 2190 | + | |
2191 | 2191 |
| |
2192 | 2192 |
| |
2193 | 2193 |
| |
| |||
2226 | 2226 |
| |
2227 | 2227 |
| |
2228 | 2228 |
| |
2229 |
| - | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
2230 | 2232 |
| |
2231 | 2233 |
| |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
2232 | 2245 |
| |
2233 | 2246 |
| |
2234 | 2247 |
| |
|
Lines changed: 65 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1285 | 1285 |
| |
1286 | 1286 |
| |
1287 | 1287 |
| |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + |
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
484 | 484 |
| |
485 | 485 |
| |
486 | 486 |
| |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + |
0 commit comments
Comments
(0)