Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 537898b

Browse files
committed
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
1 parent eba7753 commit 537898b

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/test/regress/expected/prepare.out

+7
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ SELECT * FROM q5_prep_results;
145145
9961 | 2058 | 1 | 1 | 1 | 1 | 61 | 961 | 1961 | 4961 | 9961 | 122 | 123 | DTAAAA | EBDAAA | OOOOxx
146146
(16 rows)
147147

148+
CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA')
149+
WITH NO DATA;
150+
SELECT * FROM q5_prep_nodata;
151+
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
152+
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
153+
(0 rows)
154+
148155
-- unknown or unspecified parameter types: should succeed
149156
PREPARE q6 AS
150157
SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2;

src/test/regress/expected/select_into.out

+4-3
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ SELECT * FROM created_table;
112112
4567890123456789 | -4567890123456789
113113
(5 rows)
114114

115-
-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
116-
-- be stable.
115+
-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS
116+
-- WITH NO DATA, but hide the outputs since they won't be stable.
117117
DO $$
118118
BEGIN
119119
EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
120+
EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA';
120121
END$$;
121122
DROP TABLE created_table;
122-
DROP TABLE easi;
123+
DROP TABLE easi, easi2;
123124
--
124125
-- Disallowed uses of SELECT ... INTO. All should fail
125126
--

src/test/regress/sql/prepare.sql

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ PREPARE q5(int, text) AS
6161
ORDER BY unique1;
6262
CREATE TEMPORARY TABLE q5_prep_results AS EXECUTE q5(200, 'DTAAAA');
6363
SELECT * FROM q5_prep_results;
64+
CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA')
65+
WITH NO DATA;
66+
SELECT * FROM q5_prep_nodata;
6467

6568
-- unknown or unspecified parameter types: should succeed
6669
PREPARE q6 AS

src/test/regress/sql/select_into.sql

+4-3
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,16 @@ SELECT make_table();
8585

8686
SELECT * FROM created_table;
8787

88-
-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
89-
-- be stable.
88+
-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS
89+
-- WITH NO DATA, but hide the outputs since they won't be stable.
9090
DO $$
9191
BEGIN
9292
EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
93+
EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA';
9394
END$$;
9495

9596
DROP TABLE created_table;
96-
DROP TABLE easi;
97+
DROP TABLE easi, easi2;
9798

9899
--
99100
-- Disallowed uses of SELECT ... INTO. All should fail

0 commit comments

Comments
 (0)