mirror of https://github.com/citusdata/citus.git
foreign_key_to_reference_table: terse to avoid differing order of drop cascade details
parent
0d9e5bde9c
commit
9065ef429c
|
@ -37,13 +37,13 @@ then
|
|||
sed -Ef $BASEDIR/normalize.sed < $file1 > $file1.modified
|
||||
sed -Ef $BASEDIR/normalize.sed < $file2 > $file2.modified
|
||||
|
||||
$DIFF $args $file1.modified $file2.modified
|
||||
$DIFF -w $args $file1.modified $file2.modified
|
||||
exitcode=$?
|
||||
|
||||
rm -f $file1.modified $file2.modified
|
||||
else
|
||||
# if test is not in normalized_tests.lst, just diff without normalizing.
|
||||
$DIFF $args $file1 $file2
|
||||
$DIFF -w $args $file1 $file2
|
||||
exitcode=$?
|
||||
fi
|
||||
|
||||
|
|
|
@ -702,8 +702,8 @@ INSERT INTO referenced_table(test_column2) SELECT x FROM generate_series(1,1000)
|
|||
INSERT INTO referencing_table(id) SELECT x FROM generate_series(1,1000) AS f(x);
|
||||
-- Fails for non existing value inserts (serial is already incremented)
|
||||
INSERT INTO referencing_table(id) SELECT x FROM generate_series(1,10) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000197" violates foreign key constraint "fkey_ref_7000197"
|
||||
DETAIL: Key (ref_id)=(1001) is not present in table "referenced_table_7000196".
|
||||
ERROR: insert or update on table "referencing_table_7000200" violates foreign key constraint "fkey_ref_7000200"
|
||||
DETAIL: Key (ref_id)=(1003) is not present in table "referenced_table_7000196".
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to constraint fkey_ref on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
|
@ -844,17 +844,17 @@ INSERT INTO referenced_table SELECT x, x+1 FROM generate_series(0,1000) AS f(x);
|
|||
INSERT INTO referenced_table2 SELECT x, x+1 FROM generate_series(500,1500) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,1500) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000227" violates foreign key constraint "foreign_key_2_7000227"
|
||||
DETAIL: Key (id)=(5) is not present in table "referenced_table2_7000225".
|
||||
ERROR: insert or update on table "referencing_table_7000229" violates foreign key constraint "foreign_key_2_7000229"
|
||||
DETAIL: Key (id)=(0) is not present in table "referenced_table2_7000225".
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000227" violates foreign key constraint "foreign_key_2_7000227"
|
||||
DETAIL: Key (id)=(5) is not present in table "referenced_table2_7000225".
|
||||
ERROR: insert or update on table "referencing_table_7000229" violates foreign key constraint "foreign_key_2_7000229"
|
||||
DETAIL: Key (id)=(0) is not present in table "referenced_table2_7000225".
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000227" violates foreign key constraint "fkey_ref_7000227"
|
||||
DETAIL: Key (id)=(1005) is not present in table "referenced_table_7000224".
|
||||
-- should success
|
||||
ERROR: insert or update on table "referencing_table_7000231" violates foreign key constraint "fkey_ref_7000231"
|
||||
DETAIL: Key (id)=(1001) is not present in table "referenced_table_7000224".
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(600,900) AS f(x);
|
||||
SELECT count(*) FROM referencing_table;
|
||||
count
|
||||
|
@ -909,6 +909,7 @@ SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_tab
|
|||
16
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to constraint referencing_table_id_fkey on table referencing_table
|
||||
DROP TABLE referenced_table2 CASCADE;
|
||||
|
@ -971,17 +972,14 @@ INSERT INTO referenced_table SELECT x, x+1 FROM generate_series(0,1000) AS f(x);
|
|||
INSERT INTO referenced_table2 SELECT x, x+1 FROM generate_series(500,1500) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,1500) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "foreign_key_2_7000251"
|
||||
DETAIL: Key (ref_id)=(7) is not present in table "referenced_table2_7000245".
|
||||
ERROR: insert or update on table "referencing_table_7000249" violates foreign key constraint "foreign_key_2_7000249"
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "foreign_key_2_7000251"
|
||||
DETAIL: Key (ref_id)=(7) is not present in table "referenced_table2_7000245".
|
||||
ERROR: insert or update on table "referencing_table_7000249" violates foreign key constraint "foreign_key_2_7000249"
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "fkey_ref_7000251"
|
||||
DETAIL: Key (id)=(1001) is not present in table "referenced_table_7000244".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+501 FROM generate_series(0,1000) AS f(x);
|
||||
SELECT count(*) FROM referencing_table;
|
||||
count
|
||||
|
@ -1044,6 +1042,7 @@ NOTICE: drop cascades to constraint referencing_table_id_fkey on table referenc
|
|||
DROP TABLE referenced_table2 CASCADE;
|
||||
NOTICE: drop cascades to constraint foreign_key_2 on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- two distributed tables are referencing to one reference table and
|
||||
-- in the same time the distributed table 2 is referencing to
|
||||
-- distributed table 1. Thus, we have a triangular
|
||||
|
@ -1111,15 +1110,15 @@ SELECT * FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_table.%' A
|
|||
INSERT INTO referenced_table SELECT x, x+1 FROM generate_series(0,1000) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,100) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table2_7000274" violates foreign key constraint "fkey_ref_to_dist_7000274"
|
||||
DETAIL: Key (id)=(5) is not present in table "referencing_table_7000266".
|
||||
-- should success
|
||||
ERROR: insert or update on table "referencing_table2_7000276" violates foreign key constraint "fkey_ref_to_dist_7000276"
|
||||
DETAIL: Key (id)=(0) is not present in table "referencing_table_7000268".
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(200,500) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table2_7000274" violates foreign key constraint "fkey_ref_to_dist_7000274"
|
||||
DETAIL: Key (id)=(403) is not present in table "referencing_table_7000266".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,300) AS f(x);
|
||||
DELETE FROM referenced_table WHERE test_column < 200;
|
||||
SELECT count(*) FROM referencing_table;
|
||||
|
@ -1141,13 +1140,13 @@ SELECT count(*) FROM referencing_table2;
|
|||
1
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to constraint fkey_ref on table referencing_table2
|
||||
drop cascades to constraint fkey_ref on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
NOTICE: drop cascades to constraint fkey_ref_to_dist on table referencing_table2
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- Check if the above fkeys are created with create_distributed_table
|
||||
CREATE TABLE referenced_table(test_column int, test_column2 int UNIQUE, PRIMARY KEY(test_column));
|
||||
CREATE TABLE referencing_table(id int PRIMARY KEY, ref_id int, FOREIGN KEY (id) REFERENCES referenced_table(test_column) ON DELETE CASCADE);
|
||||
|
@ -1179,13 +1178,13 @@ SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_tab
|
|||
24
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to constraint referencing_table2_ref_id_fkey on table referencing_table2
|
||||
drop cascades to constraint referencing_table_id_fkey on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
NOTICE: drop cascades to constraint referencing_table2_id_fkey on table referencing_table2
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- In this test we have a chained relationship in form of
|
||||
-- distributed table (referencing_referencing_table) has a foreign key with two columns
|
||||
-- to another distributed table (referencing_table)
|
||||
|
|
|
@ -854,7 +854,7 @@ DETAIL: Key (id)=(5) is not present in table "referenced_table2_7000225".
|
|||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000227" violates foreign key constraint "fkey_ref_7000227"
|
||||
DETAIL: Key (id)=(1005) is not present in table "referenced_table_7000224".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(600,900) AS f(x);
|
||||
SELECT count(*) FROM referencing_table;
|
||||
count
|
||||
|
@ -909,6 +909,7 @@ SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_tab
|
|||
16
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to constraint referencing_table_id_fkey on table referencing_table
|
||||
DROP TABLE referenced_table2 CASCADE;
|
||||
|
@ -972,16 +973,13 @@ INSERT INTO referenced_table2 SELECT x, x+1 FROM generate_series(500,1500) AS f(
|
|||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,1500) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "foreign_key_2_7000251"
|
||||
DETAIL: Key (ref_id)=(7) is not present in table "referenced_table2_7000245".
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "foreign_key_2_7000251"
|
||||
DETAIL: Key (ref_id)=(7) is not present in table "referenced_table2_7000245".
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table_7000251" violates foreign key constraint "fkey_ref_7000251"
|
||||
DETAIL: Key (id)=(1001) is not present in table "referenced_table_7000244".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+501 FROM generate_series(0,1000) AS f(x);
|
||||
SELECT count(*) FROM referencing_table;
|
||||
count
|
||||
|
@ -1044,6 +1042,7 @@ NOTICE: drop cascades to constraint referencing_table_id_fkey on table referenc
|
|||
DROP TABLE referenced_table2 CASCADE;
|
||||
NOTICE: drop cascades to constraint foreign_key_2 on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- two distributed tables are referencing to one reference table and
|
||||
-- in the same time the distributed table 2 is referencing to
|
||||
-- distributed table 1. Thus, we have a triangular
|
||||
|
@ -1113,13 +1112,13 @@ INSERT INTO referenced_table SELECT x, x+1 FROM generate_series(0,1000) AS f(x);
|
|||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,100) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table2_7000274" violates foreign key constraint "fkey_ref_to_dist_7000274"
|
||||
DETAIL: Key (id)=(5) is not present in table "referencing_table_7000266".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(200,500) AS f(x);
|
||||
ERROR: insert or update on table "referencing_table2_7000274" violates foreign key constraint "fkey_ref_to_dist_7000274"
|
||||
DETAIL: Key (id)=(403) is not present in table "referencing_table_7000266".
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,300) AS f(x);
|
||||
DELETE FROM referenced_table WHERE test_column < 200;
|
||||
SELECT count(*) FROM referencing_table;
|
||||
|
@ -1141,13 +1140,13 @@ SELECT count(*) FROM referencing_table2;
|
|||
1
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to constraint fkey_ref on table referencing_table2
|
||||
drop cascades to constraint fkey_ref on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
NOTICE: drop cascades to constraint fkey_ref_to_dist on table referencing_table2
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- Check if the above fkeys are created with create_distributed_table
|
||||
CREATE TABLE referenced_table(test_column int, test_column2 int UNIQUE, PRIMARY KEY(test_column));
|
||||
CREATE TABLE referencing_table(id int PRIMARY KEY, ref_id int, FOREIGN KEY (id) REFERENCES referenced_table(test_column) ON DELETE CASCADE);
|
||||
|
@ -1179,13 +1178,13 @@ SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_tab
|
|||
24
|
||||
(1 row)
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to constraint referencing_table2_ref_id_fkey on table referencing_table2
|
||||
drop cascades to constraint referencing_table_id_fkey on table referencing_table
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
NOTICE: drop cascades to constraint referencing_table2_id_fkey on table referencing_table2
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
\set VERBOSITY default
|
||||
-- In this test we have a chained relationship in form of
|
||||
-- distributed table (referencing_referencing_table) has a foreign key with two columns
|
||||
-- to another distributed table (referencing_table)
|
||||
|
|
|
@ -428,7 +428,7 @@ INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,1500) AS f(x)
|
|||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(600,900) AS f(x);
|
||||
|
||||
SELECT count(*) FROM referencing_table;
|
||||
|
@ -451,6 +451,7 @@ SELECT create_distributed_table('referencing_table', 'id');
|
|||
|
||||
SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_table.%' AND refd_relid LIKE 'fkey_reference_table.%';
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
DROP TABLE referenced_table2 CASCADE;
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
|
@ -484,7 +485,7 @@ INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,1500) AS f(x)
|
|||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(1000,1400) AS f(x);
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+501 FROM generate_series(0,1000) AS f(x);
|
||||
|
||||
SELECT count(*) FROM referencing_table;
|
||||
|
@ -514,6 +515,7 @@ SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_tab
|
|||
DROP TABLE referenced_table CASCADE;
|
||||
DROP TABLE referenced_table2 CASCADE;
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
\set VERBOSITY default
|
||||
|
||||
|
||||
-- two distributed tables are referencing to one reference table and
|
||||
|
@ -542,11 +544,11 @@ SELECT * FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_table.%' A
|
|||
INSERT INTO referenced_table SELECT x, x+1 FROM generate_series(0,1000) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,100) AS f(x);
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(0,400) AS f(x);
|
||||
-- should fail
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(200,500) AS f(x);
|
||||
-- should success
|
||||
-- should succeed
|
||||
INSERT INTO referencing_table2 SELECT x, x+1 FROM generate_series(0,300) AS f(x);
|
||||
|
||||
DELETE FROM referenced_table WHERE test_column < 200;
|
||||
|
@ -555,9 +557,11 @@ SELECT count(*) FROM referencing_table2;
|
|||
DELETE FROM referencing_table WHERE id > 200;
|
||||
SELECT count(*) FROM referencing_table2;
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
\set VERBOSITY default
|
||||
|
||||
-- Check if the above fkeys are created with create_distributed_table
|
||||
CREATE TABLE referenced_table(test_column int, test_column2 int UNIQUE, PRIMARY KEY(test_column));
|
||||
|
@ -572,10 +576,11 @@ COMMIT;
|
|||
|
||||
SELECT count(*) FROM table_fkeys_in_workers WHERE relid LIKE 'fkey_reference_table.%' AND refd_relid LIKE 'fkey_reference_table.%';
|
||||
|
||||
\set VERBOSITY terse
|
||||
DROP TABLE referenced_table CASCADE;
|
||||
DROP TABLE referencing_table CASCADE;
|
||||
DROP TABLE referencing_table2 CASCADE;
|
||||
|
||||
\set VERBOSITY default
|
||||
|
||||
-- In this test we have a chained relationship in form of
|
||||
-- distributed table (referencing_referencing_table) has a foreign key with two columns
|
||||
|
|
Loading…
Reference in New Issue