Skip site navigation (1) Skip section navigation (2)

pgsql: Fix case of window function + aggregate + GROUP BY expression.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix case of window function + aggregate + GROUP BY expression.
Date: 2012-09-13 15:32:53
Message-ID: E1TCBPR-0003Y6-NI@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Fix case of window function + aggregate + GROUP BY expression.

In commit 1bc16a946008a7cbb33a9a06a7c6765a807d7f59 I added a minor
optimization to drop the component variables of a GROUP BY expression from
the target list computed at the aggregation level of a query, if those Vars
weren't referenced elsewhere in the tlist.  However, I overlooked that the
window-function planning code would deconstruct such expressions and thus
need to have access to their component variables.  Fix it to not do that.

While at it, I removed the distinction between volatile and nonvolatile
window partition/order expressions: the code now computes all of them
at the aggregation level.  This saves a relatively expensive check for
volatility, and it's unclear that the resulting plan isn't better anyway.

Per bug #7535 from Louis-David Mitterrand.  Back-patch to 9.2.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a20993608a65b9896b4c05cb7061bc60d6f1840a

Modified Files
--------------
src/backend/optimizer/plan/planner.c |  163 +++++++++++++++++++++++++---------
src/test/regress/expected/window.out |   12 +++
src/test/regress/sql/window.sql      |    6 ++
3 files changed, 137 insertions(+), 44 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2012-09-13 17:44:34
Subject: pgsql: Keep plperl's current_call_data record on the stack,instead of
Previous:From: Kevin GrittnerDate: 2012-09-13 03:34:49
Subject: pgsql: Fix typo in comment for pclose_check() function.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group