- Notifications
You must be signed in to change notification settings - Fork28
Commitc0a493e
committed
Fix planner error (or assert trap) with nested set operations.
As reported by Sean Johnston in bug #14614, since 9.6 the planner can faildue to trying to look up the referent of a Var with varno 0. This happensbecause we generate such Vars in generate_append_tlist, for lack of anybetter way to describe the output of a SetOp node. In typical situationsnothing really cares about that, but given nested set-operation querieswe will call estimate_num_groups on the output of the subquery, and thatwants to know what a Var actually refers to. That logic used to look atsubquery->targetList, but in commit3fc6e2d I'd switched it to look atsubroot->processed_tlist, ie the actual output of the subquery plan not theparser's idea of the result. It seemed like a good idea at the time :-(.As a band-aid fix, change it back.Really we ought to have an honest way of naming the outputs of SetOp steps,which suggests that it'd be a good idea for the parser to emit an RTEcorresponding to each one. But that's a task for another day, and itcertainly wouldn't yield a back-patchable fix.Report:https://postgr.es/m/20170407115808.25934.51866@wrigleys.postgresql.org1 parentdd93afc commitc0a493e
File tree
3 files changed
+42
-1
lines changed- src
- backend/optimizer/prep
- test/regress
- expected
- sql
3 files changed
+42
-1
lines changedLines changed: 11 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
338 | 338 |
| |
339 | 339 |
| |
340 | 340 |
| |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
341 | 351 |
| |
342 | 352 |
| |
343 | 353 |
| |
| |||
347 | 357 |
| |
348 | 358 |
| |
349 | 359 |
| |
350 |
| - | |
| 360 | + | |
351 | 361 |
| |
352 | 362 |
| |
353 | 363 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
319 | 319 |
| |
320 | 320 |
| |
321 | 321 |
| |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
322 | 347 |
| |
323 | 348 |
| |
324 | 349 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
111 | 111 |
| |
112 | 112 |
| |
113 | 113 |
| |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
114 | 120 |
| |
115 | 121 |
| |
116 | 122 |
| |
|
0 commit comments
Comments
(0)