diff options
| author | Tom Lane | 2016-07-02 17:23:02 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-07-02 17:23:12 +0000 |
| commit | 420c1661630c96ad10f58ca967d5f561bb404cf9 (patch) | |
| tree | 06a90e6edc366104467a2837cf36f7cb43b7df51 /src/test | |
| parent | b54f7a9ac9646845138f6851fdf3097e22daa383 (diff) | |
Fix failure to mark all aggregates with appropriate transtype.
In commit 915b703e1 I gave get_agg_clause_costs() the responsibility of
marking Aggref nodes with the appropriate aggtranstype. I failed to notice
that where it was being called from, it might see only a subset of the
Aggref nodes that were in the original targetlist. Specifically, if there
are duplicate aggregate calls in the tlist, either make_sort_input_target
or make_window_input_target might put just a single instance into the
grouping_target, and then only that instance would get marked. Fix by
moving the call back into grouping_planner(), before we start building
assorted PathTargets from the query tlist. Per report from Stefan Huehner.
Report: <20160702131056.GD3165@huehner.biz>
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/limit.out | 24 | ||||
| -rw-r--r-- | src/test/regress/sql/limit.sql | 8 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out index 659a1015b48..9c3eecfc3bd 100644 --- a/src/test/regress/expected/limit.out +++ b/src/test/regress/expected/limit.out @@ -296,3 +296,27 @@ order by s2 desc; 0 | 0 (3 rows) +-- test for failure to set all aggregates' aggtranstype +explain (verbose, costs off) +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Limit + Output: (sum(tenthous)), (((sum(tenthous))::double precision + (random() * '0'::double precision))), thousand + -> GroupAggregate + Output: sum(tenthous), ((sum(tenthous))::double precision + (random() * '0'::double precision)), thousand + Group Key: tenk1.thousand + -> Index Only Scan using tenk1_thous_tenthous on public.tenk1 + Output: thousand, tenthous +(7 rows) + +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3; + s1 | s2 +-------+------- + 45000 | 45000 + 45010 | 45010 + 45020 | 45020 +(3 rows) + diff --git a/src/test/regress/sql/limit.sql b/src/test/regress/sql/limit.sql index ef5686c520b..8015f81fc2b 100644 --- a/src/test/regress/sql/limit.sql +++ b/src/test/regress/sql/limit.sql @@ -91,3 +91,11 @@ order by s2 desc; select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 order by s2 desc; + +-- test for failure to set all aggregates' aggtranstype +explain (verbose, costs off) +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3; + +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3; |
