diff options
| author | Tom Lane | 2012-09-13 15:31:40 +0000 |
|---|---|---|
| committer | Tom Lane | 2012-09-13 15:32:25 +0000 |
| commit | a20993608a65b9896b4c05cb7061bc60d6f1840a (patch) | |
| tree | ce1d91f8b25a661bd28ef85f19648f0bbd3a9c27 /src/test | |
| parent | 6b896f511f8dbeac9f09cc54c6cb62bdff25e501 (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/window.out | 12 | ||||
| -rw-r--r-- | src/test/regress/sql/window.sql | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out index 77786266255..49252c82ae3 100644 --- a/src/test/regress/expected/window.out +++ b/src/test/regress/expected/window.out @@ -614,6 +614,18 @@ group by ten order by ten; 9 | 10040184 | 7 (10 rows) +-- window and aggregate with GROUP BY expression (9.2 bug) +explain (costs off) +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y; + QUERY PLAN +------------------------------- + WindowAgg + -> HashAggregate + -> Seq Scan on tenk1 +(3 rows) + -- test non-default frame specifications SELECT four, ten, sum(ten) over (partition by four order by ten), diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql index d8e9e7e3b1c..769be0fdc61 100644 --- a/src/test/regress/sql/window.sql +++ b/src/test/regress/sql/window.sql @@ -145,6 +145,12 @@ select ten, from tenk1 group by ten order by ten; +-- window and aggregate with GROUP BY expression (9.2 bug) +explain (costs off) +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y; + -- test non-default frame specifications SELECT four, ten, sum(ten) over (partition by four order by ten), |
