forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4d346de
committed
Avoid pushing quals down into sub-queries that have grouping sets.
The trouble with doing this is that an apparently-constant subqueryoutput column isn't really constant if it is a grouping column thatappears in only some of the grouping sets. A qual using such acolumn would be subject to incorrect const-folding after push-down,as seen in bug #16585 from Paul Sivash.To fix, just disable qual pushdown altogether if the sub-query hasnonempty groupingSets. While we could imagine far less restrictivesolutions, there is not much point in working harder right now,because subquery_planner() won't move HAVING clauses to WHERE withinsuch a subquery. If the qual stays in HAVING it's not going to bea lot more useful than if we'd kept it at the outer level.Having said that, this restriction could be removed if we used aparsetree representation that distinguished such outputs from actualconstants, which is something I hope to do in future. Hence, makethe patch a minimal addition rather than integrating it more tightly(e.g. by renumbering the existing items in subquery_is_pushdown_safe'scomment).Back-patch to 9.5 where grouping sets were introduced.Discussion:https://postgr.es/m/16585-9d8c340d23ade8c1@postgresql.org1 parent5b02d68 commit4d346de
File tree
3 files changed
+63
-0
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+63
-0
lines changedLines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3182 | 3182 |
| |
3183 | 3183 |
| |
3184 | 3184 |
| |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
3185 | 3196 |
| |
3186 | 3197 |
| |
3187 | 3198 |
| |
| |||
3226 | 3237 |
| |
3227 | 3238 |
| |
3228 | 3239 |
| |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
3229 | 3244 |
| |
3230 | 3245 |
| |
3231 | 3246 |
| |
|
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
434 | 434 |
| |
435 | 435 |
| |
436 | 436 |
| |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
437 | 469 |
| |
438 | 470 |
| |
439 | 471 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
172 | 172 |
| |
173 | 173 |
| |
174 | 174 |
| |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
175 | 191 |
| |
176 | 192 |
| |
177 | 193 |
| |
|
0 commit comments
Comments
(0)