]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Make pull_var_clause() handle GroupingFuncs exactly like Aggrefs.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 May 2022 15:31:46 +0000 (11:31 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 May 2022 15:31:46 +0000 (11:31 -0400)
commit7f7f1750d4ca7b03ca0bfc2b89dd466816514fe6
tree26d90c33d2c929f8b4c15bb9431e0d7db972d8a2
parent87c1dd246af8ace926645900f02886905b889718
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
src/backend/optimizer/util/var.c
src/test/regress/expected/groupingsets.out
src/test/regress/sql/groupingsets.sql