Fix psql-dependent DDL tests

Obviously lots of \d commands in this file.
pull/1439/head
Jason Petersen 2017-05-31 11:19:49 -06:00
parent dee1db807f
commit 1ef60069b6
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
2 changed files with 35 additions and 29 deletions

View File

@ -47,7 +47,7 @@ FROM
ORDER BY attnum;
\c - - - :master_port
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column;
SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
@ -65,7 +65,7 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
-- Verify that SET NOT NULL works
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
-- Drop default so that NULLs will be inserted for this column
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT;
@ -77,7 +77,7 @@ ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT;
-- Verify that DROP NOT NULL works
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
-- \copy should succeed now
\copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
@ -88,7 +88,7 @@ SELECT count(*) from lineitem_alter;
SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2;
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2;
@ -116,19 +116,19 @@ ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS int_column2;
ALTER TABLE IF EXISTS lineitem_alter RENAME COLUMN l_orderkey_renamed TO l_orderkey;
SELECT SUM(l_orderkey) FROM lineitem_alter;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
-- Verify that we can execute commands with multiple subcommands
ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER,
ADD COLUMN int_column2 INTEGER;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
ALTER TABLE lineitem_alter ADD COLUMN int_column3 INTEGER,
ALTER COLUMN int_column1 SET STATISTICS 10;
ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
-- Verify that we cannot execute alter commands on the distribution column
@ -161,7 +161,7 @@ ALTER TABLE IF EXISTS non_existent_table RENAME COLUMN column1 TO column2;
-- Verify that none of the failed alter table commands took effect on the master
-- node
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
-- verify that non-propagated ddl commands are allowed inside a transaction block
SET citus.enable_ddl_propagation to false;
@ -185,7 +185,8 @@ CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
ALTER TABLE lineitem_alter ADD COLUMN first integer;
COMMIT;
\d lineitem_alter
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
\d temp_index_2
ALTER TABLE lineitem_alter DROP COLUMN first;
DROP INDEX temp_index_2;

View File

@ -77,8 +77,7 @@ ORDER BY attnum;
(27 rows)
\c - - - :master_port
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -102,6 +101,7 @@ ORDER BY attnum;
int_column1 | integer | default 1
int_column2 | integer | default 2
null_column | integer |
(21 rows)
SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column;
float_column | count
@ -138,8 +138,7 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
-- Verify that SET NOT NULL works
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+--------------------
l_orderkey | bigint | not null
@ -163,6 +162,7 @@ ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL;
int_column1 | integer |
int_column2 | integer | not null default 2
null_column | integer |
(21 rows)
-- Drop default so that NULLs will be inserted for this column
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT;
@ -173,8 +173,7 @@ ERROR: null value in column "int_column2" violates not-null constraint
DETAIL: Failing row contains (1, 155190, 7706, 1, 17.00, 21168.23, 0.04, 0.02, N, O, 1996-03-13, 1996-02-12, 1996-03-22, DELIVER IN PERSON , TRUCK , egular courts above the, 1, null, null, null, null).
-- Verify that DROP NOT NULL works
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -198,6 +197,7 @@ ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL;
int_column1 | integer |
int_column2 | integer |
null_column | integer |
(21 rows)
-- \copy should succeed now
\copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
@ -216,8 +216,7 @@ SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP B
(2 rows)
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -241,6 +240,7 @@ ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT;
int_column1 | integer |
int_column2 | double precision |
null_column | integer |
(21 rows)
SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2;
int_column2 | pg_typeof | count
@ -280,8 +280,7 @@ SELECT SUM(l_orderkey) FROM lineitem_alter;
53620791
(1 row)
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -301,12 +300,12 @@ SELECT SUM(l_orderkey) FROM lineitem_alter;
l_shipmode | character(10) | not null
l_comment | character varying(44) | not null
null_column | integer |
(17 rows)
-- Verify that we can execute commands with multiple subcommands
ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER,
ADD COLUMN int_column2 INTEGER;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -328,14 +327,14 @@ ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER,
null_column | integer |
int_column1 | integer |
int_column2 | integer |
(19 rows)
ALTER TABLE lineitem_alter ADD COLUMN int_column3 INTEGER,
ALTER COLUMN int_column1 SET STATISTICS 10;
ERROR: alter table command is currently unsupported
DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP CONSTRAINT and TYPE subcommands are supported.
ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -355,6 +354,7 @@ ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2;
l_shipmode | character(10) | not null
l_comment | character varying(44) | not null
null_column | integer |
(17 rows)
-- Verify that we cannot execute alter commands on the distribution column
ALTER TABLE lineitem_alter ALTER COLUMN l_orderkey DROP NOT NULL;
@ -395,8 +395,7 @@ ALTER TABLE IF EXISTS non_existent_table RENAME COLUMN column1 TO column2;
NOTICE: relation "non_existent_table" does not exist, skipping
-- Verify that none of the failed alter table commands took effect on the master
-- node
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -416,6 +415,7 @@ NOTICE: relation "non_existent_table" does not exist, skipping
l_shipmode | character(10) | not null
l_comment | character varying(44) | not null
null_column | integer |
(17 rows)
-- verify that non-propagated ddl commands are allowed inside a transaction block
SET citus.enable_ddl_propagation to false;
@ -446,8 +446,7 @@ BEGIN;
CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
ALTER TABLE lineitem_alter ADD COLUMN first integer;
COMMIT;
\d lineitem_alter
Table "public.lineitem_alter"
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
Column | Type | Modifiers
-----------------+-----------------------+-----------
l_orderkey | bigint | not null
@ -468,8 +467,14 @@ COMMIT;
l_comment | character varying(44) | not null
null_column | integer |
first | integer |
Indexes:
"temp_index_2" btree (l_orderkey)
(18 rows)
\d temp_index_2
Index "public.temp_index_2"
Column | Type | Definition
------------+--------+------------
l_orderkey | bigint | l_orderkey
btree, for table "public.lineitem_alter"
ALTER TABLE lineitem_alter DROP COLUMN first;
DROP INDEX temp_index_2;