aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-02-07 09:21:57 +0900
committerMichael Paquier <michael@paquier.xyz>2019-02-07 09:21:57 +0900
commit537898bd81bd8bd3650846e0abde4298ff1373da (patch)
tree36bf143e48b904394e829076386d909829cdb21a /src/test
parenteba775345d23d2c999bbb412ae658b6dab36e3e8 (diff)
downloadpostgresql-537898bd81bd8bd3650846e0abde4298ff1373da.tar.gz
postgresql-537898bd81bd8bd3650846e0abde4298ff1373da.zip
Add more tests for CREATE TABLE AS with WITH NO DATA
The relation creation is done at executor startup, however the main regression test suite is lacking scenarios where no data is inserted which is something that can happen when using EXECUTE or EXPLAIN with CREATE TABLE AS and WITH NO DATA. Some patches are worked on to reshape the way CTAS relations are created, so this makes sure that we do not miss some query patterns already supported. Reported-by: Andreas Karlsson Author: Michael Paquier Reviewed-by: Andreas Karlsson Discussion: https://postgr.es/m/20190206091817.GB14980@paquier.xyz
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/prepare.out7
-rw-r--r--src/test/regress/expected/select_into.out7
-rw-r--r--src/test/regress/sql/prepare.sql3
-rw-r--r--src/test/regress/sql/select_into.sql7
4 files changed, 18 insertions, 6 deletions
diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out
index d07c0cc9c91..717732300d1 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 942f975e953..f373fae6796 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 7fe8c8d7f55..985d0f05c96 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 62eddeed9d9..a708fef0ea0 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