mirror of https://github.com/citusdata/citus.git
fixup! Update existing tests & Add more tests
use debug4 and don't rely on debug message in testspull/4453/head
parent
7d2d926b94
commit
be2e18e4bf
|
@ -955,7 +955,7 @@ InvalidateForeignKeyGraphForDDL(void)
|
||||||
{
|
{
|
||||||
if (shouldInvalidateForeignKeyGraph)
|
if (shouldInvalidateForeignKeyGraph)
|
||||||
{
|
{
|
||||||
ereport(DEBUG1, (errmsg("DDL command invalidates foreign key graph")));
|
ereport(DEBUG4, (errmsg("DDL command invalidates foreign key graph")));
|
||||||
|
|
||||||
InvalidateForeignKeyGraph();
|
InvalidateForeignKeyGraph();
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,6 @@ BEGIN;
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
ALTER TABLE on_update_fkey_table ADD COLUMN X INT;
|
ALTER TABLE on_update_fkey_table ADD COLUMN X INT;
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
ERROR: cannot execute parallel DDL on table "on_update_fkey_table" after SELECT command on reference table "reference_table" because there is a foreign key between them and "reference_table" has been accessed in this transaction
|
ERROR: cannot execute parallel DDL on table "on_update_fkey_table" after SELECT command on reference table "reference_table" because there is a foreign key between them and "reference_table" has been accessed in this transaction
|
||||||
DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency.
|
DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency.
|
||||||
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
|
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
|
||||||
|
@ -1386,7 +1385,6 @@ ADD CONSTRAINT
|
||||||
fkey_delete FOREIGN KEY(value_1)
|
fkey_delete FOREIGN KEY(value_1)
|
||||||
REFERENCES
|
REFERENCES
|
||||||
reference_table(id) ON DELETE CASCADE;
|
reference_table(id) ON DELETE CASCADE;
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
INSERT INTO reference_table SELECT i FROM generate_series(0, 10) i;
|
INSERT INTO reference_table SELECT i FROM generate_series(0, 10) i;
|
||||||
DEBUG: distributed INSERT ... SELECT can only select from distributed tables
|
DEBUG: distributed INSERT ... SELECT can only select from distributed tables
|
||||||
DEBUG: Collecting INSERT ... SELECT results on coordinator
|
DEBUG: Collecting INSERT ... SELECT results on coordinator
|
||||||
|
|
|
@ -737,22 +737,10 @@ FROM get_foreign_key_connected_relations('non_existent_table') AS f(oid oid)
|
||||||
ORDER BY tablename;
|
ORDER BY tablename;
|
||||||
ERROR: relation "non_existent_table" does not exist
|
ERROR: relation "non_existent_table" does not exist
|
||||||
\set VERBOSITY TERSE
|
\set VERBOSITY TERSE
|
||||||
SET client_min_messages TO DEBUG1;
|
SET client_min_messages TO ERROR;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
||||||
NOTICE: drop cascades to constraint fkey_4 on table distributed_table_3
|
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
ALTER TABLE distributed_table_3 DROP CONSTRAINT distributed_table_3_col_key CASCADE;
|
ALTER TABLE distributed_table_3 DROP CONSTRAINT distributed_table_3_col_key CASCADE;
|
||||||
NOTICE: drop cascades to constraint fkey_6 on table distributed_table_1
|
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
DEBUG: drop cascades to constraint fkey_6_xxx on table fkey_graph.distributed_table_1_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_6_xxx on table fkey_graph.distributed_table_1_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_6_xxx on table fkey_graph.distributed_table_1_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_6_xxx on table fkey_graph.distributed_table_1_xxx
|
|
||||||
-- show that we process drop constraint commands that are dropping uniquness
|
-- show that we process drop constraint commands that are dropping uniquness
|
||||||
-- constraints and then invalidate fkey graph. So we shouldn't see
|
-- constraints and then invalidate fkey graph. So we shouldn't see
|
||||||
-- distributed_table_3 as it was split via above drop constraint commands
|
-- distributed_table_3 as it was split via above drop constraint commands
|
||||||
|
@ -778,23 +766,28 @@ ERROR: cannot drop column col of table reference_table_2 because other objects
|
||||||
-- but we invalidate foreign key graph in below two transaction blocks
|
-- but we invalidate foreign key graph in below two transaction blocks
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
||||||
NOTICE: drop cascades to constraint fkey_4 on table distributed_table_3
|
SELECT oid::regclass::text AS tablename
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
FROM get_foreign_key_connected_relations('distributed_table_2') AS f(oid oid)
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
ORDER BY tablename;
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
tablename
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
---------------------------------------------------------------------
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
distributed_table_1
|
||||||
|
distributed_table_2
|
||||||
|
distributed_table_3
|
||||||
|
reference_table_1
|
||||||
|
reference_table_2
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE reference_table_2 DROP COLUMN col CASCADE;
|
ALTER TABLE reference_table_2 DROP COLUMN col CASCADE;
|
||||||
NOTICE: drop cascades to constraint fkey_5 on table distributed_table_2
|
SELECT oid::regclass::text AS tablename
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
FROM get_foreign_key_connected_relations('reference_table_2') AS f(oid oid)
|
||||||
DEBUG: drop cascades to 2 other objects
|
ORDER BY tablename;
|
||||||
DETAIL: drop cascades to constraint fkey_5_xxx on table fkey_graph.distributed_table_2_xxx
|
tablename
|
||||||
drop cascades to constraint fkey_5_xxx on table fkey_graph.distributed_table_2_xxx
|
---------------------------------------------------------------------
|
||||||
DEBUG: drop cascades to 2 other objects
|
(0 rows)
|
||||||
DETAIL: drop cascades to constraint fkey_5_xxx on table fkey_graph.distributed_table_2_xxx
|
|
||||||
drop cascades to constraint fkey_5_xxx on table fkey_graph.distributed_table_2_xxx
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- now we should see distributed_table_2 as well since we rollback'ed
|
-- now we should see distributed_table_2 as well since we rollback'ed
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
|
@ -811,12 +804,6 @@ ORDER BY tablename;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DROP TABLE distributed_table_2 CASCADE;
|
DROP TABLE distributed_table_2 CASCADE;
|
||||||
NOTICE: drop cascades to constraint fkey_4 on table distributed_table_3
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: drop cascades to constraint fkey_4_xxx on table fkey_graph.distributed_table_3_xxx
|
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
-- should only see reference_table_1 & reference_table_2
|
-- should only see reference_table_1 & reference_table_2
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
FROM get_foreign_key_connected_relations('reference_table_1') AS f(oid oid)
|
FROM get_foreign_key_connected_relations('reference_table_1') AS f(oid oid)
|
||||||
|
@ -830,9 +817,7 @@ DEBUG: DDL command invalidates foreign key graph
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE distributed_table_2 ADD CONSTRAINT fkey_55 FOREIGN KEY (col) REFERENCES reference_table_2(col);
|
ALTER TABLE distributed_table_2 ADD CONSTRAINT fkey_55 FOREIGN KEY (col) REFERENCES reference_table_2(col);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
ALTER TABLE distributed_table_1 ADD CONSTRAINT fkey_66 FOREIGN KEY (col) REFERENCES distributed_table_3(col);
|
ALTER TABLE distributed_table_1 ADD CONSTRAINT fkey_66 FOREIGN KEY (col) REFERENCES distributed_table_3(col);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
-- show that we handle multiple edges between nodes in foreign key graph
|
-- show that we handle multiple edges between nodes in foreign key graph
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
FROM get_foreign_key_connected_relations('reference_table_1') AS f(oid oid)
|
FROM get_foreign_key_connected_relations('reference_table_1') AS f(oid oid)
|
||||||
|
@ -848,22 +833,27 @@ DEBUG: DDL command invalidates foreign key graph
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
-- hide "verifying table" log because the order we print it changes
|
|
||||||
-- in different pg versions
|
|
||||||
set client_min_messages to error;
|
|
||||||
ALTER TABLE distributed_table_2 ADD CONSTRAINT pkey PRIMARY KEY (col);
|
ALTER TABLE distributed_table_2 ADD CONSTRAINT pkey PRIMARY KEY (col);
|
||||||
set client_min_messages to debug1;
|
|
||||||
-- show that droping a constraint not involved in any foreign key
|
-- show that droping a constraint not involved in any foreign key
|
||||||
-- constraint doesn't invalidate foreign key graph
|
-- constraint doesn't invalidate foreign key graph
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT pkey;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT pkey;
|
||||||
|
SELECT oid::regclass::text AS tablename
|
||||||
|
FROM get_foreign_key_connected_relations('distributed_table_2') AS f(oid oid)
|
||||||
|
ORDER BY tablename;
|
||||||
|
tablename
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
distributed_table_1
|
||||||
|
distributed_table_2
|
||||||
|
distributed_table_3
|
||||||
|
reference_table_1
|
||||||
|
reference_table_2
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
||||||
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "local_table_3_pkey" for table "local_table_3"
|
|
||||||
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
CREATE TABLE local_table_4 (col int PRIMARY KEY REFERENCES local_table_3 (col));
|
CREATE TABLE local_table_4 (col int PRIMARY KEY REFERENCES local_table_3 (col));
|
||||||
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "local_table_4_pkey" for table "local_table_4"
|
|
||||||
-- we invalidate foreign key graph for add column & create table
|
-- we invalidate foreign key graph for add column & create table
|
||||||
-- commands defining foreign keys too
|
-- commands defining foreign keys too
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
|
@ -879,11 +869,8 @@ DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "local_table_4_pke
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
||||||
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "local_table_3_pkey" for table "local_table_3"
|
|
||||||
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
ALTER TABLE local_table_1 DROP COLUMN another_col;
|
ALTER TABLE local_table_1 DROP COLUMN another_col;
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
-- we invalidate foreign key graph for drop column commands dropping
|
-- we invalidate foreign key graph for drop column commands dropping
|
||||||
-- referencing columns, should not print anything
|
-- referencing columns, should not print anything
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
|
@ -896,12 +883,8 @@ DEBUG: DDL command invalidates foreign key graph
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
CREATE TABLE local_table_3 (col int PRIMARY KEY);
|
||||||
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "local_table_3_pkey" for table "local_table_3"
|
|
||||||
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
ALTER TABLE local_table_1 ADD COLUMN another_col int REFERENCES local_table_3(col);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
ALTER TABLE local_table_3 DROP COLUMN col CASCADE;
|
ALTER TABLE local_table_3 DROP COLUMN col CASCADE;
|
||||||
NOTICE: drop cascades to constraint local_table_1_another_col_fkey on table local_table_1
|
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
-- we invalidate foreign key graph for drop column commands dropping
|
-- we invalidate foreign key graph for drop column commands dropping
|
||||||
-- referenced columns, should not print anything
|
-- referenced columns, should not print anything
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
|
@ -925,11 +908,8 @@ ALTER TABLE local_table_1 ADD COLUMN unrelated_column int;
|
||||||
-- does not invalidate foreign key graph
|
-- does not invalidate foreign key graph
|
||||||
DROP TABLE local_table_4;
|
DROP TABLE local_table_4;
|
||||||
CREATE TABLE partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
CREATE TABLE partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_1_col_1_key" for table "partitioned_table_1"
|
|
||||||
CREATE TABLE partitioned_table_1_100_200 PARTITION OF partitioned_table_1 FOR VALUES FROM (100) TO (200);
|
CREATE TABLE partitioned_table_1_100_200 PARTITION OF partitioned_table_1 FOR VALUES FROM (100) TO (200);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_1_100_200_col_1_key" for table "partitioned_table_1_100_200"
|
|
||||||
CREATE TABLE partitioned_table_1_200_300 PARTITION OF partitioned_table_1 FOR VALUES FROM (200) TO (300);
|
CREATE TABLE partitioned_table_1_200_300 PARTITION OF partitioned_table_1 FOR VALUES FROM (200) TO (300);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_1_200_300_col_1_key" for table "partitioned_table_1_200_300"
|
|
||||||
SELECT create_distributed_table('partitioned_table_1', 'col_1');
|
SELECT create_distributed_table('partitioned_table_1', 'col_1');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -937,11 +917,8 @@ SELECT create_distributed_table('partitioned_table_1', 'col_1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE partitioned_table_2 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
CREATE TABLE partitioned_table_2 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_2_col_1_key" for table "partitioned_table_2"
|
|
||||||
CREATE TABLE partitioned_table_2_100_200 PARTITION OF partitioned_table_2 FOR VALUES FROM (100) TO (200);
|
CREATE TABLE partitioned_table_2_100_200 PARTITION OF partitioned_table_2 FOR VALUES FROM (100) TO (200);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_2_100_200_col_1_key" for table "partitioned_table_2_100_200"
|
|
||||||
CREATE TABLE partitioned_table_2_200_300 PARTITION OF partitioned_table_2 FOR VALUES FROM (200) TO (300);
|
CREATE TABLE partitioned_table_2_200_300 PARTITION OF partitioned_table_2 FOR VALUES FROM (200) TO (300);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_2_200_300_col_1_key" for table "partitioned_table_2_200_300"
|
|
||||||
SELECT create_distributed_table('partitioned_table_2', 'col_1');
|
SELECT create_distributed_table('partitioned_table_2', 'col_1');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -949,8 +926,6 @@ SELECT create_distributed_table('partitioned_table_2', 'col_1');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE reference_table_4 (col_1 INT UNIQUE, col_2 INT UNIQUE);
|
CREATE TABLE reference_table_4 (col_1 INT UNIQUE, col_2 INT UNIQUE);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "reference_table_4_col_1_key" for table "reference_table_4"
|
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "reference_table_4_col_2_key" for table "reference_table_4"
|
|
||||||
SELECT create_reference_table('reference_table_4');
|
SELECT create_reference_table('reference_table_4');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -959,12 +934,8 @@ SELECT create_reference_table('reference_table_4');
|
||||||
|
|
||||||
-- observe foreign key graph invalidation with partitioned tables
|
-- observe foreign key graph invalidation with partitioned tables
|
||||||
ALTER TABLE partitioned_table_1 ADD CONSTRAINT fkey_8 FOREIGN KEY (col_1) REFERENCES reference_table_4(col_2);
|
ALTER TABLE partitioned_table_1 ADD CONSTRAINT fkey_8 FOREIGN KEY (col_1) REFERENCES reference_table_4(col_2);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
ALTER TABLE partitioned_table_2 ADD CONSTRAINT fkey_9 FOREIGN KEY (col_1) REFERENCES reference_table_4(col_2);
|
ALTER TABLE partitioned_table_2 ADD CONSTRAINT fkey_9 FOREIGN KEY (col_1) REFERENCES reference_table_4(col_2);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
CREATE TABLE partitioned_table_1_300_400 PARTITION OF partitioned_table_1 FOR VALUES FROM (300) TO (400);
|
CREATE TABLE partitioned_table_1_300_400 PARTITION OF partitioned_table_1 FOR VALUES FROM (300) TO (400);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "partitioned_table_1_300_400_col_1_key" for table "partitioned_table_1_300_400"
|
|
||||||
DEBUG: switching to sequential query execution mode
|
|
||||||
-- we invalidate foreign key graph as attach partition creates a new distributed table
|
-- we invalidate foreign key graph as attach partition creates a new distributed table
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
FROM get_foreign_key_connected_relations('partitioned_table_1_300_400') AS f(oid oid)
|
FROM get_foreign_key_connected_relations('partitioned_table_1_300_400') AS f(oid oid)
|
||||||
|
@ -982,25 +953,18 @@ ORDER BY tablename;
|
||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
CREATE TABLE local_partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
CREATE TABLE local_partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_partitioned_table_1_col_1_key" for table "local_partitioned_table_1"
|
|
||||||
CREATE TABLE local_table_5 (col_1 INT UNIQUE, col_2 INT);
|
CREATE TABLE local_table_5 (col_1 INT UNIQUE, col_2 INT);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_table_5_col_1_key" for table "local_table_5"
|
|
||||||
-- in below two show that attaching a partition doesn't invalidate
|
-- in below two show that attaching a partition doesn't invalidate
|
||||||
-- foreign key cache as parent table isn't involved in any foreign
|
-- foreign key cache as parent table isn't involved in any foreign
|
||||||
-- key relationship
|
-- key relationship
|
||||||
CREATE TABLE local_partitioned_table_1_100_200 PARTITION OF local_partitioned_table_1 FOR VALUES FROM (100) TO (200);
|
CREATE TABLE local_partitioned_table_1_100_200 PARTITION OF local_partitioned_table_1 FOR VALUES FROM (100) TO (200);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_partitioned_table_1_100_200_col_1_key" for table "local_partitioned_table_1_100_200"
|
|
||||||
CREATE TABLE local_partitioned_table_1_200_300 (col_1 INT UNIQUE, col_2 INT);
|
CREATE TABLE local_partitioned_table_1_200_300 (col_1 INT UNIQUE, col_2 INT);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_partitioned_table_1_200_300_col_1_key" for table "local_partitioned_table_1_200_300"
|
|
||||||
ALTER TABLE local_partitioned_table_1 ATTACH PARTITION local_partitioned_table_1_200_300 FOR VALUES FROM (200) TO (300);
|
ALTER TABLE local_partitioned_table_1 ATTACH PARTITION local_partitioned_table_1_200_300 FOR VALUES FROM (200) TO (300);
|
||||||
DEBUG: verifying table "local_partitioned_table_1_200_300"
|
|
||||||
-- define a foreign key from partitioned table
|
-- define a foreign key from partitioned table
|
||||||
ALTER TABLE local_partitioned_table_1 ADD CONSTRAINT fkey_10 FOREIGN KEY (col_1) REFERENCES local_table_5(col_1);
|
ALTER TABLE local_partitioned_table_1 ADD CONSTRAINT fkey_10 FOREIGN KEY (col_1) REFERENCES local_table_5(col_1);
|
||||||
DEBUG: DDL command invalidates foreign key graph
|
|
||||||
-- in below two show that attaching partition invalidates foreign
|
-- in below two show that attaching partition invalidates foreign
|
||||||
-- key cache as parent table is involved in a foreign key relationship
|
-- key cache as parent table is involved in a foreign key relationship
|
||||||
CREATE TABLE local_partitioned_table_1_300_400 PARTITION OF local_partitioned_table_1 FOR VALUES FROM (300) TO (400);
|
CREATE TABLE local_partitioned_table_1_300_400 PARTITION OF local_partitioned_table_1 FOR VALUES FROM (300) TO (400);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_partitioned_table_1_300_400_col_1_key" for table "local_partitioned_table_1_300_400"
|
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
FROM get_foreign_key_connected_relations('local_partitioned_table_1_300_400') AS f(oid oid)
|
FROM get_foreign_key_connected_relations('local_partitioned_table_1_300_400') AS f(oid oid)
|
||||||
ORDER BY tablename;
|
ORDER BY tablename;
|
||||||
|
@ -1014,9 +978,7 @@ ORDER BY tablename;
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
CREATE TABLE local_partitioned_table_1_500_600 (col_1 INT UNIQUE, col_2 INT);
|
CREATE TABLE local_partitioned_table_1_500_600 (col_1 INT UNIQUE, col_2 INT);
|
||||||
DEBUG: CREATE TABLE / UNIQUE will create implicit index "local_partitioned_table_1_500_600_col_1_key" for table "local_partitioned_table_1_500_600"
|
|
||||||
ALTER TABLE local_partitioned_table_1 ATTACH PARTITION local_partitioned_table_1_500_600 FOR VALUES FROM (500) TO (600);
|
ALTER TABLE local_partitioned_table_1 ATTACH PARTITION local_partitioned_table_1_500_600 FOR VALUES FROM (500) TO (600);
|
||||||
DEBUG: verifying table "local_partitioned_table_1_500_600"
|
|
||||||
SELECT oid::regclass::text AS tablename
|
SELECT oid::regclass::text AS tablename
|
||||||
FROM get_foreign_key_connected_relations('local_table_5') AS f(oid oid)
|
FROM get_foreign_key_connected_relations('local_table_5') AS f(oid oid)
|
||||||
ORDER BY tablename;
|
ORDER BY tablename;
|
||||||
|
|
|
@ -308,7 +308,7 @@ FROM get_foreign_key_connected_relations('non_existent_table') AS f(oid oid)
|
||||||
ORDER BY tablename;
|
ORDER BY tablename;
|
||||||
|
|
||||||
\set VERBOSITY TERSE
|
\set VERBOSITY TERSE
|
||||||
SET client_min_messages TO DEBUG1;
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
||||||
|
@ -331,10 +331,18 @@ ALTER TABLE reference_table_2 DROP COLUMN col;
|
||||||
-- but we invalidate foreign key graph in below two transaction blocks
|
-- but we invalidate foreign key graph in below two transaction blocks
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT distributed_table_2_col_key CASCADE;
|
||||||
|
|
||||||
|
SELECT oid::regclass::text AS tablename
|
||||||
|
FROM get_foreign_key_connected_relations('distributed_table_2') AS f(oid oid)
|
||||||
|
ORDER BY tablename;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE reference_table_2 DROP COLUMN col CASCADE;
|
ALTER TABLE reference_table_2 DROP COLUMN col CASCADE;
|
||||||
|
|
||||||
|
SELECT oid::regclass::text AS tablename
|
||||||
|
FROM get_foreign_key_connected_relations('reference_table_2') AS f(oid oid)
|
||||||
|
ORDER BY tablename;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
-- now we should see distributed_table_2 as well since we rollback'ed
|
-- now we should see distributed_table_2 as well since we rollback'ed
|
||||||
|
@ -360,15 +368,15 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
-- hide "verifying table" log because the order we print it changes
|
|
||||||
-- in different pg versions
|
|
||||||
set client_min_messages to error;
|
|
||||||
ALTER TABLE distributed_table_2 ADD CONSTRAINT pkey PRIMARY KEY (col);
|
ALTER TABLE distributed_table_2 ADD CONSTRAINT pkey PRIMARY KEY (col);
|
||||||
set client_min_messages to debug1;
|
|
||||||
|
|
||||||
-- show that droping a constraint not involved in any foreign key
|
-- show that droping a constraint not involved in any foreign key
|
||||||
-- constraint doesn't invalidate foreign key graph
|
-- constraint doesn't invalidate foreign key graph
|
||||||
ALTER TABLE distributed_table_2 DROP CONSTRAINT pkey;
|
ALTER TABLE distributed_table_2 DROP CONSTRAINT pkey;
|
||||||
|
|
||||||
|
SELECT oid::regclass::text AS tablename
|
||||||
|
FROM get_foreign_key_connected_relations('distributed_table_2') AS f(oid oid)
|
||||||
|
ORDER BY tablename;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
Loading…
Reference in New Issue