Commit a1637ca
committed
Repair logic for reordering grouping sets optimization.
The logic in reorder_grouping_sets to order grouping set elements to
match a pre-specified sort ordering was defective, resulting in
unnecessary sort nodes (though the query output would still be
correct). Repair, simplifying the code a little, and add a test.
Per report from Richard Guo, though I didn't use their patch. Original
bug seems to have been my fault.
Backpatch back to 9.5 where grouping sets were introduced.
Discussion: https://postgr.es/m/CAN_9JTzyjGcUjiBHxLsgqfk7PkdLGXiM=pwM+=ph2LsWw0WO1A@mail.gmail.com1 parent 69da8c1 commit a1637ca
File tree
3 files changed
+34
-21
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+34
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3255 | 3255 | | |
3256 | 3256 | | |
3257 | 3257 | | |
3258 | | - | |
3259 | 3258 | | |
3260 | 3259 | | |
3261 | 3260 | | |
| |||
3265 | 3264 | | |
3266 | 3265 | | |
3267 | 3266 | | |
3268 | | - | |
| 3267 | + | |
| 3268 | + | |
3269 | 3269 | | |
3270 | | - | |
3271 | | - | |
3272 | | - | |
3273 | | - | |
| 3270 | + | |
| 3271 | + | |
3274 | 3272 | | |
3275 | | - | |
3276 | | - | |
3277 | | - | |
3278 | | - | |
3279 | | - | |
3280 | | - | |
3281 | | - | |
3282 | | - | |
3283 | | - | |
3284 | | - | |
3285 | | - | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
3286 | 3277 | | |
3287 | | - | |
3288 | | - | |
| 3278 | + | |
3289 | 3279 | | |
3290 | | - | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
3291 | 3283 | | |
3292 | 3284 | | |
3293 | 3285 | | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
3294 | 3292 | | |
3295 | 3293 | | |
3296 | | - | |
3297 | 3294 | | |
3298 | 3295 | | |
3299 | 3296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
640 | 653 | | |
641 | 654 | | |
642 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
| |||
0 commit comments