提交 ef203885 编写于 作者: H Heikki Linnakangas

Move tests for an old ORCA bug related to dropped columns from TINC.

In the passing, also move existing tests GPDB-specific tests out of the
'alter_table' test. The 'alter_table' test is inherited from the upstream,
so let's try to keep it unmodified.
上级 f853f3b0
......@@ -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);
......
-- 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)
-- 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)
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
-- 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;
-- @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)
-- 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)
-- 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)
-- @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;
-- @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);
-- @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;
-- @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);
-- @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;
-- @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);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册