diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index e7494d09ba1ba2eabb41aa592201fd3c4fecfb58..ea481d31ebc58dd0cab73fb5d514232f904b093c 100755 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -136,36 +136,6 @@ SELECT * FROM tmp_new2; DROP TABLE tmp_new; DROP TABLE tmp_new2; --- ALTER TABLE ... RENAME on corrupted relations -SET allow_system_table_mods = dml; -SET gp_allow_rename_relation_without_lock = ON; --- missing entry -CREATE TABLE cor (a int, b float); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; -DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; -ALTER TABLE cor RENAME TO oldcor; -INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; -DROP TABLE oldcor; --- typname is out of sync -CREATE TABLE cor (a int, b float, c text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; -ALTER TABLE cor RENAME TO newcor2; -ALTER TABLE newcor2 RENAME TO cor; -DROP TABLE cor; --- relname is out of sync -CREATE TABLE cor (a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -UPDATE pg_class SET relname='othercor' WHERE relname='cor'; -ALTER TABLE othercor RENAME TO tmpcor; -ALTER TABLE tmpcor RENAME TO cor; -DROP TABLE cor; -RESET allow_system_table_mods; -RESET gp_allow_rename_relation_without_lock; -- ALTER TABLE ... RENAME on non-table relations -- renaming indexes (FIXME: this should probably test the index's functionality) ALTER INDEX onek_unique1 RENAME TO tmp_onek_unique1; @@ -521,20 +491,6 @@ insert into atacc1 (test,test2) values (4,5); insert into atacc1 (test,test2) values (5,4); insert into atacc1 (test,test2) values (5,5); drop table atacc1; --- MPP-20466 Dis-allow duplicate constraint names for same table -create table dupconstr ( - i int, - j int constraint test CHECK (j > 10)) - distributed by (i); --- should fail because of duplicate constraint name -alter table dupconstr add constraint test unique (i); -NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "dupconstr_i_key" for table "dupconstr" -ERROR: constraint "test" for relation "dupconstr" already exists -alter table dupconstr add constraint test primary key (i); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dupconstr_pkey" for table "dupconstr" -ERROR: constraint "test" for relation "dupconstr" already exists --- cleanup -drop table dupconstr; -- lets do some naming tests create table atacc1 (test int, test2 int, unique(test)) distributed by (test); NOTICE: CREATE TABLE / UNIQUE will create implicit index "atacc1_test_key" for table "atacc1" @@ -1458,27 +1414,6 @@ select f3,max(f1) from foo group by f3 order by f3; alter table foo alter f1 TYPE integer; -- fails ERROR: column "f1" cannot be cast to type "pg_catalog.int4" alter table foo alter f1 TYPE varchar(10); --- --- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) --- -drop table foo; -create domain mytype as text; -create temp table foo (f1 text, f2 mytype, f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -insert into foo values('aa','bb','cc'); -drop domain mytype cascade; -NOTICE: drop cascades to table foo column f2 -alter table foo alter f1 TYPE varchar(10); -drop table foo; -create domain mytype as int; -create temp table foo (f1 text, f2 mytype, f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -insert into foo values('aa',0,'cc'); -drop domain mytype cascade; -NOTICE: drop cascades to table foo column f2 -alter table foo alter f1 TYPE varchar(10); create table anothertab (atcol1 serial8, atcol2 boolean, constraint anothertab_chk check (atcol1 <= 3)) distributed by (atcol1); diff --git a/src/test/regress/expected/alter_table_gp.out b/src/test/regress/expected/alter_table_gp.out new file mode 100644 index 0000000000000000000000000000000000000000..5476f189661f6b3418ddd0ae3d7ed87edaa81be9 --- /dev/null +++ b/src/test/regress/expected/alter_table_gp.out @@ -0,0 +1,127 @@ +-- ALTER TABLE ... RENAME on corrupted relations +SET allow_system_table_mods = dml; +SET gp_allow_rename_relation_without_lock = ON; +-- missing entry +CREATE TABLE cor (a int, b float); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; +DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; +ALTER TABLE cor RENAME TO oldcor; +INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; +DROP TABLE oldcor; +-- typname is out of sync +CREATE TABLE cor (a int, b float, c text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; +ALTER TABLE cor RENAME TO newcor2; +ALTER TABLE newcor2 RENAME TO cor; +DROP TABLE cor; +-- relname is out of sync +CREATE TABLE cor (a int, b int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +UPDATE pg_class SET relname='othercor' WHERE relname='cor'; +ALTER TABLE othercor RENAME TO tmpcor; +ALTER TABLE tmpcor RENAME TO cor; +DROP TABLE cor; +RESET allow_system_table_mods; +RESET gp_allow_rename_relation_without_lock; +-- MPP-20466 Dis-allow duplicate constraint names for same table +create table dupconstr ( + i int, + j int constraint test CHECK (j > 10)) + distributed by (i); +-- should fail because of duplicate constraint name +alter table dupconstr add constraint test unique (i); +NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "dupconstr_i_key" for table "dupconstr" +ERROR: constraint "test" for relation "dupconstr" already exists +alter table dupconstr add constraint test primary key (i); +NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dupconstr_pkey" for table "dupconstr" +ERROR: constraint "test" for relation "dupconstr" already exists +-- cleanup +drop table dupconstr; +-- +-- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) +-- +create domain mytype as text; +create temp table at_foo (f1 text, f2 mytype, f3 text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +insert into at_foo values('aa','bb','cc'); +drop domain mytype cascade; +NOTICE: drop cascades to table at_foo column f2 +alter table at_foo alter f1 TYPE varchar(10); +drop table at_foo; +create domain mytype as int; +create temp table at_foo (f1 text, f2 mytype, f3 text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +insert into at_foo values('aa',0,'cc'); +drop domain mytype cascade; +NOTICE: drop cascades to table at_foo column f2 +alter table at_foo alter f1 TYPE varchar(10); +-- Verify that INSERT, UPDATE and DELETE work after dropping a column and +-- adding a constraint. There was a bug on that in ORCA, once upon a time +-- (MPP-20207) +CREATE TABLE altable(a int, b text, c int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +ALTER TABLE altable DROP COLUMN b; +ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); +INSERT INTO altable(a, c) VALUES(0, -10); +ERROR: new row for relation "altable" violates check constraint "c_check" (seg0 127.0.0.1:40000 pid=21750) +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +DELETE FROM altable WHERE c = -10; +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +UPDATE altable SET c = -10; +ERROR: new row for relation "altable" violates check constraint "c_check" (seg0 127.0.0.1:40000 pid=21750) +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +UPDATE altable SET c = 1; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- + 0 | 1 +(1 row) + diff --git a/src/test/regress/expected/alter_table_gp_optimizer.out b/src/test/regress/expected/alter_table_gp_optimizer.out new file mode 100644 index 0000000000000000000000000000000000000000..1aa7cf276e7b40eb01518f832e17e116f739f0cb --- /dev/null +++ b/src/test/regress/expected/alter_table_gp_optimizer.out @@ -0,0 +1,129 @@ +-- ALTER TABLE ... RENAME on corrupted relations +SET allow_system_table_mods = dml; +SET gp_allow_rename_relation_without_lock = ON; +-- missing entry +CREATE TABLE cor (a int, b float); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; +DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; +ALTER TABLE cor RENAME TO oldcor; +INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; +DROP TABLE oldcor; +-- typname is out of sync +CREATE TABLE cor (a int, b float, c text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; +ALTER TABLE cor RENAME TO newcor2; +ALTER TABLE newcor2 RENAME TO cor; +DROP TABLE cor; +-- relname is out of sync +CREATE TABLE cor (a int, b int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +UPDATE pg_class SET relname='othercor' WHERE relname='cor'; +ALTER TABLE othercor RENAME TO tmpcor; +ALTER TABLE tmpcor RENAME TO cor; +DROP TABLE cor; +RESET allow_system_table_mods; +RESET gp_allow_rename_relation_without_lock; +-- MPP-20466 Dis-allow duplicate constraint names for same table +create table dupconstr ( + i int, + j int constraint test CHECK (j > 10)) + distributed by (i); +-- should fail because of duplicate constraint name +alter table dupconstr add constraint test unique (i); +NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "dupconstr_i_key" for table "dupconstr" +ERROR: constraint "test" for relation "dupconstr" already exists +alter table dupconstr add constraint test primary key (i); +NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dupconstr_pkey" for table "dupconstr" +ERROR: constraint "test" for relation "dupconstr" already exists +-- cleanup +drop table dupconstr; +-- +-- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) +-- +create domain mytype as text; +create temp table at_foo (f1 text, f2 mytype, f3 text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +insert into at_foo values('aa','bb','cc'); +drop domain mytype cascade; +NOTICE: drop cascades to table at_foo column f2 +alter table at_foo alter f1 TYPE varchar(10); +drop table at_foo; +create domain mytype as int; +create temp table at_foo (f1 text, f2 mytype, f3 text); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +insert into at_foo values('aa',0,'cc'); +drop domain mytype cascade; +NOTICE: drop cascades to table at_foo column f2 +alter table at_foo alter f1 TYPE varchar(10); +-- Verify that INSERT, UPDATE and DELETE work after dropping a column and +-- adding a constraint. There was a bug on that in ORCA, once upon a time +-- (MPP-20207) +CREATE TABLE altable(a int, b text, c int); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +ALTER TABLE altable DROP COLUMN b; +ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); +INSERT INTO altable(a, c) VALUES(0, -10); +ERROR: One or more assertions failed (seg0 127.0.0.1:40000 pid=22251) +DETAIL: Check constraint c_check for table altable was violated +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +DELETE FROM altable WHERE c = -10; +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- +(0 rows) + +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +UPDATE altable SET c = -10; +ERROR: One or more assertions failed (seg0 127.0.0.1:40000 pid=22251) +DETAIL: Check constraint c_check for table altable was violated +SELECT * FROM altable ORDER BY 1; + a | c +---+---- + 0 | 10 +(1 row) + +UPDATE altable SET c = 1; +SELECT * FROM altable ORDER BY 1; + a | c +---+--- + 0 | 1 +(1 row) + diff --git a/src/test/regress/expected/alter_table_optimizer.out b/src/test/regress/expected/alter_table_optimizer.out index 0766618443bb81a141d578923106debcdad277c9..6be642dc019cb03c008a752eba31473ebd0c15ac 100644 --- a/src/test/regress/expected/alter_table_optimizer.out +++ b/src/test/regress/expected/alter_table_optimizer.out @@ -137,36 +137,6 @@ SELECT * FROM tmp_new2; DROP TABLE tmp_new; DROP TABLE tmp_new2; --- ALTER TABLE ... RENAME on corrupted relations -SET allow_system_table_mods = dml; -SET gp_allow_rename_relation_without_lock = ON; --- missing entry -CREATE TABLE cor (a int, b float); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; -DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; -ALTER TABLE cor RENAME TO oldcor; -INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; -DROP TABLE oldcor; --- typname is out of sync -CREATE TABLE cor (a int, b float, c text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; -ALTER TABLE cor RENAME TO newcor2; -ALTER TABLE newcor2 RENAME TO cor; -DROP TABLE cor; --- relname is out of sync -CREATE TABLE cor (a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -UPDATE pg_class SET relname='othercor' WHERE relname='cor'; -ALTER TABLE othercor RENAME TO tmpcor; -ALTER TABLE tmpcor RENAME TO cor; -DROP TABLE cor; -RESET allow_system_table_mods; -RESET gp_allow_rename_relation_without_lock; -- ALTER TABLE ... RENAME on non-table relations -- renaming indexes (FIXME: this should probably test the index's functionality) ALTER INDEX onek_unique1 RENAME TO tmp_onek_unique1; @@ -527,20 +497,6 @@ insert into atacc1 (test,test2) values (4,5); insert into atacc1 (test,test2) values (5,4); insert into atacc1 (test,test2) values (5,5); drop table atacc1; --- MPP-20466 Dis-allow duplicate constraint names for same table -create table dupconstr ( - i int, - j int constraint test CHECK (j > 10)) - distributed by (i); --- should fail because of duplicate constraint name -alter table dupconstr add constraint test unique (i); -NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "dupconstr_i_key" for table "dupconstr" -ERROR: constraint "test" for relation "dupconstr" already exists -alter table dupconstr add constraint test primary key (i); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dupconstr_pkey" for table "dupconstr" -ERROR: constraint "test" for relation "dupconstr" already exists --- cleanup -drop table dupconstr; -- lets do some naming tests create table atacc1 (test int, test2 int, unique(test)) distributed by (test); NOTICE: CREATE TABLE / UNIQUE will create implicit index "atacc1_test_key" for table "atacc1" @@ -1475,27 +1431,6 @@ select f3,max(f1) from foo group by f3 order by f3; alter table foo alter f1 TYPE integer; -- fails ERROR: column "f1" cannot be cast to type "pg_catalog.int4" alter table foo alter f1 TYPE varchar(10); --- --- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) --- -drop table foo; -create domain mytype as text; -create temp table foo (f1 text, f2 mytype, f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -insert into foo values('aa','bb','cc'); -drop domain mytype cascade; -NOTICE: drop cascades to table foo column f2 -alter table foo alter f1 TYPE varchar(10); -drop table foo; -create domain mytype as int; -create temp table foo (f1 text, f2 mytype, f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -insert into foo values('aa',0,'cc'); -drop domain mytype cascade; -NOTICE: drop cascades to table foo column f2 -alter table foo alter f1 TYPE varchar(10); create table anothertab (atcol1 serial8, atcol2 boolean, constraint anothertab_chk check (atcol1 <= 3)) distributed by (atcol1); diff --git a/src/test/regress/greenplum_schedule b/src/test/regress/greenplum_schedule index 14cf49d83ea986ca34ff9347c0db99f65ee86f71..d83c1df1d5aebc79000e3a09816526851d078697 100755 --- a/src/test/regress/greenplum_schedule +++ b/src/test/regress/greenplum_schedule @@ -72,7 +72,7 @@ test: vacuum_gp ignore: gp_portal_error test: external_table column_compression eagerfree mapred gpdtm_plpgsql alter_table_aocs alter_table_aocs2 alter_distribution_policy ic aoco_privileges aocs -test: alter_table_ao ao_create_alter_valid_table subtransaction_limit oid_consistency udf_exception_blocks +test: alter_table_gp alter_table_ao ao_create_alter_valid_table subtransaction_limit oid_consistency udf_exception_blocks ignore: icudp_full test: resource_queue diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 5afb33d6960eff920d82e9c9570451b8eff6970e..a6f67b9c56f6217d25424caafaf2e4ff31e3b296 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -164,34 +164,6 @@ SELECT * FROM tmp_new2; DROP TABLE tmp_new; DROP TABLE tmp_new2; --- ALTER TABLE ... RENAME on corrupted relations -SET allow_system_table_mods = dml; -SET gp_allow_rename_relation_without_lock = ON; --- missing entry -CREATE TABLE cor (a int, b float); -INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; -DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; -ALTER TABLE cor RENAME TO oldcor; -INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; -DROP TABLE oldcor; - --- typname is out of sync -CREATE TABLE cor (a int, b float, c text); -UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; -ALTER TABLE cor RENAME TO newcor2; -ALTER TABLE newcor2 RENAME TO cor; -DROP TABLE cor; - --- relname is out of sync -CREATE TABLE cor (a int, b int); -UPDATE pg_class SET relname='othercor' WHERE relname='cor'; -ALTER TABLE othercor RENAME TO tmpcor; -ALTER TABLE tmpcor RENAME TO cor; -DROP TABLE cor; - -RESET allow_system_table_mods; -RESET gp_allow_rename_relation_without_lock; - -- ALTER TABLE ... RENAME on non-table relations -- renaming indexes (FIXME: this should probably test the index's functionality) ALTER INDEX onek_unique1 RENAME TO tmp_onek_unique1; @@ -481,17 +453,6 @@ insert into atacc1 (test,test2) values (5,4); insert into atacc1 (test,test2) values (5,5); drop table atacc1; --- MPP-20466 Dis-allow duplicate constraint names for same table -create table dupconstr ( - i int, - j int constraint test CHECK (j > 10)) - distributed by (i); --- should fail because of duplicate constraint name -alter table dupconstr add constraint test unique (i); -alter table dupconstr add constraint test primary key (i); --- cleanup -drop table dupconstr; - -- lets do some naming tests create table atacc1 (test int, test2 int, unique(test)) distributed by (test); alter table atacc1 add unique (test2); @@ -1034,23 +995,6 @@ select f3,max(f1) from foo group by f3 order by f3; alter table foo alter f1 TYPE integer; -- fails alter table foo alter f1 TYPE varchar(10); --- --- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) --- -drop table foo; -create domain mytype as text; -create temp table foo (f1 text, f2 mytype, f3 text); -insert into foo values('aa','bb','cc'); -drop domain mytype cascade; -alter table foo alter f1 TYPE varchar(10); - -drop table foo; -create domain mytype as int; -create temp table foo (f1 text, f2 mytype, f3 text); -insert into foo values('aa',0,'cc'); -drop domain mytype cascade; -alter table foo alter f1 TYPE varchar(10); - create table anothertab (atcol1 serial8, atcol2 boolean, constraint anothertab_chk check (atcol1 <= 3)) distributed by (atcol1); diff --git a/src/test/regress/sql/alter_table_gp.sql b/src/test/regress/sql/alter_table_gp.sql new file mode 100644 index 0000000000000000000000000000000000000000..8204f57d1b5654e18664d8b76dc6768683e5c173 --- /dev/null +++ b/src/test/regress/sql/alter_table_gp.sql @@ -0,0 +1,84 @@ +-- ALTER TABLE ... RENAME on corrupted relations +SET allow_system_table_mods = dml; +SET gp_allow_rename_relation_without_lock = ON; +-- missing entry +CREATE TABLE cor (a int, b float); +INSERT INTO cor SELECT i, i+1 FROM generate_series(1,100)i; +DELETE FROM pg_attribute WHERE attname='a' AND attrelid='cor'::regclass; +ALTER TABLE cor RENAME TO oldcor; +INSERT INTO pg_attribute SELECT distinct * FROM gp_dist_random('pg_attribute') WHERE attname='a' AND attrelid='oldcor'::regclass; +DROP TABLE oldcor; + +-- typname is out of sync +CREATE TABLE cor (a int, b float, c text); +UPDATE pg_type SET typname='newcor' WHERE typrelid='cor'::regclass; +ALTER TABLE cor RENAME TO newcor2; +ALTER TABLE newcor2 RENAME TO cor; +DROP TABLE cor; + +-- relname is out of sync +CREATE TABLE cor (a int, b int); +UPDATE pg_class SET relname='othercor' WHERE relname='cor'; +ALTER TABLE othercor RENAME TO tmpcor; +ALTER TABLE tmpcor RENAME TO cor; +DROP TABLE cor; + +RESET allow_system_table_mods; +RESET gp_allow_rename_relation_without_lock; + + +-- MPP-20466 Dis-allow duplicate constraint names for same table +create table dupconstr ( + i int, + j int constraint test CHECK (j > 10)) + distributed by (i); +-- should fail because of duplicate constraint name +alter table dupconstr add constraint test unique (i); +alter table dupconstr add constraint test primary key (i); +-- cleanup +drop table dupconstr; + + +-- +-- Test ALTER COLUMN TYPE after dropped column with text datatype (see MPP-19146) +-- +create domain mytype as text; +create temp table at_foo (f1 text, f2 mytype, f3 text); +insert into at_foo values('aa','bb','cc'); +drop domain mytype cascade; +alter table at_foo alter f1 TYPE varchar(10); + +drop table at_foo; +create domain mytype as int; +create temp table at_foo (f1 text, f2 mytype, f3 text); +insert into at_foo values('aa',0,'cc'); +drop domain mytype cascade; +alter table at_foo alter f1 TYPE varchar(10); + + +-- Verify that INSERT, UPDATE and DELETE work after dropping a column and +-- adding a constraint. There was a bug on that in ORCA, once upon a time +-- (MPP-20207) + +CREATE TABLE altable(a int, b text, c int); +ALTER TABLE altable DROP COLUMN b; + +ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); +INSERT INTO altable(a, c) VALUES(0, -10); +SELECT * FROM altable ORDER BY 1; +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; + +DELETE FROM altable WHERE c = -10; +SELECT * FROM altable ORDER BY 1; +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; +DELETE FROM altable WHERE c = 10; +SELECT * FROM altable ORDER BY 1; + +INSERT INTO altable(a, c) VALUES(0, 10); +SELECT * FROM altable ORDER BY 1; +UPDATE altable SET c = -10; +SELECT * FROM altable ORDER BY 1; +UPDATE altable SET c = 1; +SELECT * FROM altable ORDER BY 1; diff --git a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_delete.ans b/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_delete.ans deleted file mode 100644 index 7b734f7fe960b1f7c8b24454f8294f3870f60d4d..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_delete.ans +++ /dev/null @@ -1,45 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 --- start_ignore -SET optimizer_log=on;SET optimizer=on; -SET -SET --- end_ignore -ALTER TABLE altable DROP COLUMN b; -ALTER TABLE -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -ALTER TABLE -INSERT INTO altable(a, c) VALUES(0, 10); -INSERT 0 1 -SELECT * FROM altable ORDER BY 1; - a | c ----+---- - 0 | 10 -(1 row) - -DELETE FROM altable WHERE c = -10; -DELETE 0 -SELECT * FROM altable ORDER BY 1; - a | c ----+---- - 0 | 10 -(1 row) - -DELETE FROM altable WHERE c = 10; -DELETE 1 -SELECT * FROM altable ORDER BY 1; - a | c ----+--- -(0 rows) - -DELETE FROM altable WHERE c = 10; -DELETE 0 -SELECT * FROM altable ORDER BY 1; - a | c ----+--- -(0 rows) - diff --git a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_insert.ans b/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_insert.ans deleted file mode 100644 index 02882bbe042dcc86f53287337eb73b25db4a21b9..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_insert.ans +++ /dev/null @@ -1,38 +0,0 @@ --- start_ignore -SET optimizer=on; -SET -SET optimizer_log=on; -SET --- end_ignore --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore ---start_ignore -set gp_enable_column_oriented_table=on; -psql:mpp20207_insert_orca.sql:14: ERROR: unrecognized configuration parameter "gp_enable_column_oriented_table" -\echo --end_ignore ---end_ignore -ALTER TABLE altable DROP COLUMN b; -ALTER TABLE -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -ALTER TABLE -INSERT INTO altable(a, c) VALUES(0, -10); -psql:mpp20207_insert_orca.sql:19: ERROR: One or more assertions failed (seg1 antova-mbp.local:40011 pid=39753) -DETAIL: Check constraint c_check for table altable was violated -SELECT * FROM altable ORDER BY 1; - a | c ----+--- -(0 rows) - -INSERT INTO altable(a, c) VALUES(0, 10); -INSERT 0 1 -SELECT * FROM altable ORDER BY 1; - a | c ----+---- - 0 | 10 -(1 row) - diff --git a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_update.ans b/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_update.ans deleted file mode 100644 index 24dbd4ab496996b907c92fe11d1702c72827becf..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/expected/mpp20207_update.ans +++ /dev/null @@ -1,47 +0,0 @@ --- start_ignore -SET optimizer=on; -SET -SET optimizer_log=on; -SET --- end_ignore --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore ---start_ignore -set gp_enable_column_oriented_table=on; -psql:mpp20207_update_orca.sql:14: ERROR: unrecognized configuration parameter "gp_enable_column_oriented_table" -\echo --end_ignore ---end_ignore -ALTER TABLE altable DROP COLUMN b; -ALTER TABLE -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -ALTER TABLE -INSERT INTO altable(a, c) VALUES(0, 10); -INSERT 0 1 -SELECT * FROM altable ORDER BY 1; - a | c ----+---- - 0 | 10 -(1 row) - -UPDATE altable SET c = -10; -psql:mpp20207_update_orca.sql:21: ERROR: One or more assertions failed (seg1 slice1 antova-mbp.local:40011 pid=39781) -DETAIL: Check constraint c_check for table altable was violated -SELECT * FROM altable ORDER BY 1; - a | c ----+---- - 0 | 10 -(1 row) - -UPDATE altable SET c = 1; -UPDATE 1 -SELECT * FROM altable ORDER BY 1; - a | c ----+--- - 0 | 1 -(1 row) - diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete.sql deleted file mode 100644 index 1316475cc60f44a120ab5bb4bacf5be09f0c00c0..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete.sql +++ /dev/null @@ -1,21 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -ALTER TABLE altable DROP COLUMN b; - -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -INSERT INTO altable(a, c) VALUES(0, 10); -SELECT * FROM altable ORDER BY 1; -DELETE FROM altable WHERE c = -10; -SELECT * FROM altable ORDER BY 1; -DELETE FROM altable WHERE c = 10; -SELECT * FROM altable ORDER BY 1; -DELETE FROM altable WHERE c = 10; -SELECT * FROM altable ORDER BY 1; - diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete_setup.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete_setup.sql deleted file mode 100644 index 7d4bb22172c1acdf3ae451471974da6a01f72d19..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_delete_setup.sql +++ /dev/null @@ -1,11 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -DROP TABLE if exists altable; -CREATE TABLE altable(a int, b text, c int); diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert.sql deleted file mode 100644 index a6d5f97da5056bb5e504288b87525c7eaa138945..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert.sql +++ /dev/null @@ -1,18 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @gpopt 1.532 --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -ALTER TABLE altable DROP COLUMN b; - -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -INSERT INTO altable(a, c) VALUES(0, -10); -SELECT * FROM altable ORDER BY 1; -INSERT INTO altable(a, c) VALUES(0, 10); -SELECT * FROM altable ORDER BY 1; - diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert_setup.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert_setup.sql deleted file mode 100644 index 7d4bb22172c1acdf3ae451471974da6a01f72d19..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_insert_setup.sql +++ /dev/null @@ -1,11 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -DROP TABLE if exists altable; -CREATE TABLE altable(a int, b text, c int); diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update.sql deleted file mode 100644 index 3795fdb178702ec39609215adbf9a9aa735c157e..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update.sql +++ /dev/null @@ -1,19 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @gpopt 1.532 --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -ALTER TABLE altable DROP COLUMN b; - -ALTER TABLE altable ADD CONSTRAINT c_check CHECK (c > 0); -INSERT INTO altable(a, c) VALUES(0, 10); -SELECT * FROM altable ORDER BY 1; -UPDATE altable SET c = -10; -SELECT * FROM altable ORDER BY 1; -UPDATE altable SET c = 1; -SELECT * FROM altable ORDER BY 1; diff --git a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update_setup.sql b/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update_setup.sql deleted file mode 100644 index 7d4bb22172c1acdf3ae451471974da6a01f72d19..0000000000000000000000000000000000000000 --- a/src/test/tinc/tincrepo/dml/functional/sql/mpp20207_update_setup.sql +++ /dev/null @@ -1,11 +0,0 @@ --- @author prabhd --- @created 2012-12-05 12:00:00 --- @modified 2012-12-05 12:00:00 --- @tags dml --- @db_name dmldb --- @description Mpp-20207 -\echo --start_ignore -set gp_enable_column_oriented_table=on; -\echo --end_ignore -DROP TABLE if exists altable; -CREATE TABLE altable(a int, b text, c int);