pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix asymmetry in setting EquivalenceClass.ec_sortref
Date: Thu, 06 Jun 2024 10:45:49 +0000
Message-ID: <E1sFAcu-000Fms-IV@gemulon.postgresql.org> (raw)

Fix asymmetry in setting EquivalenceClass.ec_sortref

0452b461bc made get_eclass_for_sort_expr() always set
EquivalenceClass.ec_sortref if it's not done yet.  This leads to an asymmetric
situation when whoever first looks for the EquivalenceClass sets the
ec_sortref.  It is also counterintuitive that get_eclass_for_sort_expr()
performs modification of data structures.

This commit makes make_pathkeys_for_sortclauses_extended() responsible for
setting EquivalenceClass.ec_sortref.  Now we set the
EquivalenceClass.ec_sortref's needed to explore alternative GROUP BY ordering
specifically during building pathkeys by the list of grouping clauses.

Discussion: https://postgr.es/m/17037754-f187-4138-8285-0e2bfebd0dea%40postgrespro.ru
Reported-by: Tom Lane
Author: Andrei Lepikhov
Reviewed-by: Alexander Korotkov, Pavel Borisov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/199012a3d844c6283e0ab4b1139440840a91433d

Modified Files
--------------
src/backend/optimizer/path/equivclass.c  | 13 +--------
src/backend/optimizer/path/pathkeys.c    | 18 ++++++++++--
src/backend/optimizer/plan/planner.c     | 16 ++++++++---
src/include/optimizer/paths.h            |  3 +-
src/test/regress/expected/aggregates.out | 47 ++++++++++++++++++++++++++++++++
src/test/regress/sql/aggregates.sql      | 14 ++++++++++
6 files changed, 92 insertions(+), 19 deletions(-)



Message-ID: <E1sFAcu-000Fms-IV@gemulon.postgresql.org>
Permalink:  ../E1sFAcu-000Fms-IV@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sFAcu-000Fms-IV@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix asymmetry in setting EquivalenceClass.ec_sortref
  In-Reply-To: <E1sFAcu-000Fms-IV@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox