mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Add test case showing that commit d0d44049d fixed a live bug.
When I committed d0d44049d (Account for optimized MinMax aggregates during SS_finalize_plan), I didn't have a test case showing that it was fixing any reachable bug. Here is one, based on bug #18465 from Hal Takahara. Without the fix, all rows of the result show the same "min" value, because the aggregate doesn't get recalculated. Committed despite beta1 release freeze, with the concurrence of pgsql-release. Discussion: https://postgr.es/m/18465-2fae927718976b22@postgresql.org Discussion: https://postgr.es/m/2391880.1689025003@sss.pgh.pa.us
This commit is contained in:
parent
3f49df98d8
commit
779ac2c74b
@ -1273,6 +1273,37 @@ NOTICE: drop cascades to 3 other objects
|
||||
DETAIL: drop cascades to table minmaxtest1
|
||||
drop cascades to table minmaxtest2
|
||||
drop cascades to table minmaxtest3
|
||||
-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465)
|
||||
begin;
|
||||
set local enable_sort = off;
|
||||
explain (costs off)
|
||||
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
|
||||
from int4_tbl t0;
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------
|
||||
Seq Scan on int4_tbl t0
|
||||
SubPlan 2
|
||||
-> HashAggregate
|
||||
Group Key: (InitPlan 1).col1
|
||||
InitPlan 1
|
||||
-> Limit
|
||||
-> Seq Scan on int4_tbl t1
|
||||
Filter: ((f1 IS NOT NULL) AND (f1 = t0.f1))
|
||||
-> Result
|
||||
(9 rows)
|
||||
|
||||
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
|
||||
from int4_tbl t0;
|
||||
f1 | min
|
||||
-------------+-------------
|
||||
0 | 0
|
||||
123456 | 123456
|
||||
-123456 | -123456
|
||||
2147483647 | 2147483647
|
||||
-2147483647 | -2147483647
|
||||
(5 rows)
|
||||
|
||||
rollback;
|
||||
-- check for correct detection of nested-aggregate errors
|
||||
select max(min(unique1)) from tenk1;
|
||||
ERROR: aggregate function calls cannot be nested
|
||||
|
@ -436,6 +436,16 @@ select distinct min(f1), max(f1) from minmaxtest;
|
||||
|
||||
drop table minmaxtest cascade;
|
||||
|
||||
-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465)
|
||||
begin;
|
||||
set local enable_sort = off;
|
||||
explain (costs off)
|
||||
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
|
||||
from int4_tbl t0;
|
||||
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
|
||||
from int4_tbl t0;
|
||||
rollback;
|
||||
|
||||
-- check for correct detection of nested-aggregate errors
|
||||
select max(min(unique1)) from tenk1;
|
||||
select (select max(min(unique1)) from int8_tbl) from tenk1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user