Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit779ac2c

Browse files
committed
Add test case showing that commitd0d4404 fixed a live bug.
When I committedd0d4404 (Account for optimized MinMax aggregatesduring SS_finalize_plan), I didn't have a test case showing that itwas fixing any reachable bug. Here is one, based on bug #18465 fromHal 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 ofpgsql-release.Discussion:https://postgr.es/m/18465-2fae927718976b22@postgresql.orgDiscussion:https://postgr.es/m/2391880.1689025003@sss.pgh.pa.us
1 parent3f49df9 commit779ac2c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

‎src/test/regress/expected/aggregates.out

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,37 @@ NOTICE: drop cascades to 3 other objects
12731273
DETAIL: drop cascades to table minmaxtest1
12741274
drop cascades to table minmaxtest2
12751275
drop cascades to table minmaxtest3
1276+
-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465)
1277+
begin;
1278+
set local enable_sort = off;
1279+
explain (costs off)
1280+
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
1281+
from int4_tbl t0;
1282+
QUERY PLAN
1283+
---------------------------------------------------------------------
1284+
Seq Scan on int4_tbl t0
1285+
SubPlan 2
1286+
-> HashAggregate
1287+
Group Key: (InitPlan 1).col1
1288+
InitPlan 1
1289+
-> Limit
1290+
-> Seq Scan on int4_tbl t1
1291+
Filter: ((f1 IS NOT NULL) AND (f1 = t0.f1))
1292+
-> Result
1293+
(9 rows)
1294+
1295+
select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1)
1296+
from int4_tbl t0;
1297+
f1 | min
1298+
-------------+-------------
1299+
0 | 0
1300+
123456 | 123456
1301+
-123456 | -123456
1302+
2147483647 | 2147483647
1303+
-2147483647 | -2147483647
1304+
(5 rows)
1305+
1306+
rollback;
12761307
-- check for correct detection of nested-aggregate errors
12771308
select max(min(unique1)) from tenk1;
12781309
ERROR: aggregate function calls cannot be nested

‎src/test/regress/sql/aggregates.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,16 @@ select distinct min(f1), max(f1) from minmaxtest;
436436

437437
droptable minmaxtest cascade;
438438

439+
-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465)
440+
begin;
441+
set local enable_sort= off;
442+
explain (costs off)
443+
select f1, (select distinctmin(t1.f1)from int4_tbl t1wheret1.f1=t0.f1)
444+
from int4_tbl t0;
445+
select f1, (select distinctmin(t1.f1)from int4_tbl t1wheret1.f1=t0.f1)
446+
from int4_tbl t0;
447+
rollback;
448+
439449
-- check for correct detection of nested-aggregate errors
440450
selectmax(min(unique1))from tenk1;
441451
select (selectmax(min(unique1))from int8_tbl)from tenk1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp