pgsql: Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs
Date: 2022-05-12 15:32:10
Message-ID: E1npAnR-000MUA-Uw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs.

This follows in the footsteps of commit 2591ee8ec by removing one more
ill-advised shortcut from planning of GroupingFuncs. It's true that
we don't intend to execute the argument expression(s) at runtime, but
we still have to process any Vars appearing within them, or we risk
failure at setrefs.c time (or more fundamentally, in EXPLAIN trying
to print such an expression). Vars in upper plan nodes have to have
referents in the next plan level, whether we ever execute 'em or not.

Per bug #17479 from Michael J. Sullivan. Back-patch to all supported
branches.

Richard Guo

Discussion: https://postgr.es/m/17479-6260deceaf0ad304@postgresql.org

Branch
------
REL_13_STABLE

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

Modified Files
--------------
src/backend/optimizer/util/var.c | 10 +----
src/test/regress/expected/groupingsets.out | 64 ++++++++++++++++++++++++++++++
src/test/regress/sql/groupingsets.sql | 23 +++++++++++
3 files changed, 89 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-05-12 16:14:49 pgsql: Mark a few 'bbsink' related functions / variables static.
Previous Message Bruce Momjian 2022-05-12 14:12:17 pgsql: relnotes: adjust several logical replication items and FK text