Improve regression test for #8410.

The previous version of the query disregarded the result of the MergeAppend
instead of checking its results.

Andres Freund
This commit is contained in:
Tom Lane 2013-08-30 21:40:21 -04:00
parent ac2d0e464a
commit abd3f8ca4b
2 changed files with 32 additions and 33 deletions

View File

@ -1353,42 +1353,41 @@ ORDER BY x, y;
-- exercise rescan code path via a repeatedly-evaluated subquery
explain (costs off)
SELECT
(SELECT g.i FROM (
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
ARRAY(SELECT f.i FROM (
(SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1)
UNION ALL
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
(SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1)
) f(i)
ORDER BY f.i LIMIT 1)
ORDER BY f.i LIMIT 10)
FROM generate_series(1, 3) g(i);
QUERY PLAN
------------------------------------------------------------------------------------
QUERY PLAN
----------------------------------------------------------------
Function Scan on generate_series g
SubPlan 1
-> Limit
-> Result
-> Merge Append
Sort Key: generate_series.generate_series
-> Sort
Sort Key: generate_series.generate_series
-> Function Scan on generate_series
-> Sort
Sort Key: generate_series_1.generate_series
-> Function Scan on generate_series generate_series_1
(12 rows)
-> Merge Append
Sort Key: ((d.d + g.i))
-> Sort
Sort Key: ((d.d + g.i))
-> Function Scan on generate_series d
-> Sort
Sort Key: ((d_1.d + g.i))
-> Function Scan on generate_series d_1
(11 rows)
SELECT
(SELECT g.i FROM (
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
ARRAY(SELECT f.i FROM (
(SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1)
UNION ALL
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
(SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1)
) f(i)
ORDER BY f.i LIMIT 1)
ORDER BY f.i LIMIT 10)
FROM generate_series(1, 3) g(i);
i
---
1
2
3
array
------------------------------
{1,5,6,8,11,11,14,16,17,20}
{2,6,7,9,12,12,15,17,18,21}
{3,7,8,10,13,13,16,18,19,22}
(3 rows)
reset enable_seqscan;

View File

@ -442,21 +442,21 @@ ORDER BY x, y;
-- exercise rescan code path via a repeatedly-evaluated subquery
explain (costs off)
SELECT
(SELECT g.i FROM (
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
ARRAY(SELECT f.i FROM (
(SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1)
UNION ALL
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
(SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1)
) f(i)
ORDER BY f.i LIMIT 1)
ORDER BY f.i LIMIT 10)
FROM generate_series(1, 3) g(i);
SELECT
(SELECT g.i FROM (
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
ARRAY(SELECT f.i FROM (
(SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1)
UNION ALL
(SELECT * FROM generate_series(1, 2) ORDER BY 1)
(SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1)
) f(i)
ORDER BY f.i LIMIT 1)
ORDER BY f.i LIMIT 10)
FROM generate_series(1, 3) g(i);
reset enable_seqscan;