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

View File

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