pgsql: Repair logic for reordering grouping sets optimization.

From: Andrew Gierth <rhodiumtoad(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Repair logic for reordering grouping sets optimization.
Date: 2019-06-30 22:55:07
Message-ID: E1hhiix-0003L1-6j@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/da53be23d1c5e529675e958eaee54cfed4e4dbac

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2019-07-01 00:36:19 pgsql: Don't read fields of a misaligned ExpandedObjectHeader or AnyArr
Previous Message Tom Lane 2019-06-30 18:05:30 pgsql: Exclude new src/test/modules/unsafe_tests directory from MSVC bu