On Tue, Feb 05, 2019 at 06:56:00PM +0100, Andreas Karlsson wrote: > I guess that I could fix that for the second case as soon as I understand > how much of the portal stuff can be skipped in ExecuteQuery(). But I am not > sure what we should do with EXPLAIN ANALYZE ... NO DATA. It feels like a > contraction to me. Should we just raise an error? Or should we try to > preserve the current behavior where you see something like the > below?
This grammar is documented, so it seems to me that it would be just annoying for users relying on it to throw an error for a pattern that simply worked, particularly if a driver layer is using it. The issue this outlines is that we have a gap in the tests for a subset of the grammar, which is not a good thing. If I put Assert(!into->skipData) at the beginning of intorel_startup() then the main regression test suite is able to pass, both on HEAD and with your patch. There is one test for CTAS EXECUTE in prepare.sql, so let's add a pattern with WITH NO DATA there for the first pattern. Adding a second test with EXPLAIN SELECT INTO into select_into.sql also looks like a good thing. Attached is a patch to do that and close the gap. With that, we will be able to check for inconsistencies better when working on the follow-up patches. What do you think? -- Michael
diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out index d07c0cc9c9..717732300d 100644 --- a/src/test/regress/expected/prepare.out +++ b/src/test/regress/expected/prepare.out @@ -145,6 +145,13 @@ SELECT * FROM q5_prep_results; 9961 | 2058 | 1 | 1 | 1 | 1 | 61 | 961 | 1961 | 4961 | 9961 | 122 | 123 | DTAAAA | EBDAAA | OOOOxx (16 rows) +CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA') + WITH NO DATA; +SELECT * FROM q5_prep_nodata; + unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 +---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+--------- +(0 rows) + -- unknown or unspecified parameter types: should succeed PREPARE q6 AS SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2; diff --git a/src/test/regress/expected/select_into.out b/src/test/regress/expected/select_into.out index 942f975e95..f373fae679 100644 --- a/src/test/regress/expected/select_into.out +++ b/src/test/regress/expected/select_into.out @@ -112,14 +112,15 @@ SELECT * FROM created_table; 4567890123456789 | -4567890123456789 (5 rows) --- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't --- be stable. +-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS +-- WITH NO DATA, but hide the outputs since they won't be stable. DO $$ BEGIN EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl'; + EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA'; END$$; DROP TABLE created_table; -DROP TABLE easi; +DROP TABLE easi, easi2; -- -- Disallowed uses of SELECT ... INTO. All should fail -- diff --git a/src/test/regress/sql/prepare.sql b/src/test/regress/sql/prepare.sql index 7fe8c8d7f5..985d0f05c9 100644 --- a/src/test/regress/sql/prepare.sql +++ b/src/test/regress/sql/prepare.sql @@ -61,6 +61,9 @@ PREPARE q5(int, text) AS ORDER BY unique1; CREATE TEMPORARY TABLE q5_prep_results AS EXECUTE q5(200, 'DTAAAA'); SELECT * FROM q5_prep_results; +CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA') + WITH NO DATA; +SELECT * FROM q5_prep_nodata; -- unknown or unspecified parameter types: should succeed PREPARE q6 AS diff --git a/src/test/regress/sql/select_into.sql b/src/test/regress/sql/select_into.sql index 62eddeed9d..a708fef0ea 100644 --- a/src/test/regress/sql/select_into.sql +++ b/src/test/regress/sql/select_into.sql @@ -85,15 +85,16 @@ SELECT make_table(); SELECT * FROM created_table; --- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't --- be stable. +-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS +-- WITH NO DATA, but hide the outputs since they won't be stable. DO $$ BEGIN EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl'; + EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA'; END$$; DROP TABLE created_table; -DROP TABLE easi; +DROP TABLE easi, easi2; -- -- Disallowed uses of SELECT ... INTO. All should fail
signature.asc
Description: PGP signature