forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitda5800d
committed
Don't presort ORDER BY/DISTINCT Aggrefs with volatile functions
In1349d27, we gave the planner the ability to provide ORDER BY/DISTINCTAggrefs with presorted input so that nodeAgg would not have to performsorts during execution. That commit failed to properly consider theimplications of if the Aggref had a volatile function in its ORDERBY/DISTINCT clause. As it happened, this resulted in an ERROR about thevolatile function being missing from the targetlist.Here, instead of adding the volatile function to the targetlist, we justnever consider an Aggref with a volatile function in its ORDER BY/DISTINCTclause when choosing which Aggrefs we should sort by. We do this as if wewere to choose a plan which provided these aggregates with presortedinput, then if there were many such aggregates which could all share thesame sort order, then it may be surprising if they all shared the samesort sometimes and didn't at other times when some other set of aggregateswere given presorted results. We can avoid this inconsistency by justnever providing these volatile function aggregates with presorted input.Reported-by: Dean RasheedDiscussion:https://postgr.es/m/CAEZATCWETioXs5kY8vT6BVguY41_wD962VDk=u_Nvd7S1UXzuQ@mail.gmail.com1 parent52585f8 commitda5800d
File tree
3 files changed
+79
-6
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+79
-6
lines changedLines changed: 49 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3147 | 3147 |
| |
3148 | 3148 |
| |
3149 | 3149 |
| |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
3150 | 3171 |
| |
3151 | 3172 |
| |
3152 | 3173 |
| |
| |||
3168 | 3189 |
| |
3169 | 3190 |
| |
3170 | 3191 |
| |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
3171 | 3205 |
| |
3172 | 3206 |
| |
3173 | 3207 |
| |
| |||
3254 | 3288 |
| |
3255 | 3289 |
| |
3256 | 3290 |
| |
| 3291 | + | |
3257 | 3292 |
| |
3258 | 3293 |
| |
3259 | 3294 |
| |
3260 | 3295 |
| |
3261 | 3296 |
| |
3262 | 3297 |
| |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
3263 | 3311 |
| |
3264 | 3312 |
| |
3265 | 3313 |
| |
3266 | 3314 |
| |
3267 | 3315 |
| |
3268 | 3316 |
| |
3269 |
| - | |
3270 |
| - | |
| 3317 | + | |
3271 | 3318 |
| |
3272 | 3319 |
| |
3273 | 3320 |
| |
| |||
3279 | 3326 |
| |
3280 | 3327 |
| |
3281 | 3328 |
| |
3282 |
| - | |
3283 |
| - | |
3284 | 3329 |
| |
3285 |
| - | |
3286 |
| - | |
3287 | 3330 |
| |
3288 | 3331 |
| |
3289 | 3332 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1471 | 1471 |
| |
1472 | 1472 |
| |
1473 | 1473 |
| |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
1474 | 1493 |
| |
1475 | 1494 |
| |
1476 | 1495 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
546 | 546 |
| |
547 | 547 |
| |
548 | 548 |
| |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
549 | 560 |
| |
550 | 561 |
| |
551 | 562 |
| |
|
0 commit comments
Comments
(0)