pgsql: Repair logic for reordering grouping sets optimization. - Mailing list pgsql-committers

From Andrew Gierth
Subject pgsql: Repair logic for reordering grouping sets optimization.
Date
Msg-id E1hhiix-0003L8-7G@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4a36c77156f2ff6e07a349cddc65e5dd21abc1a8

Modified Files
--------------
src/backend/optimizer/plan/planner.c       | 39 ++++++++++++++----------------
src/test/regress/expected/groupingsets.out | 13 ++++++++++
src/test/regress/sql/groupingsets.sql      |  3 +++
3 files changed, 34 insertions(+), 21 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Exclude new src/test/modules/unsafe_tests directory from MSVCbu
Next
From: Noah Misch
Date:
Subject: pgsql: Don't read fields of a misaligned ExpandedObjectHeader orAnyArr