Normalize tests: shard table names in foreign_key_to_reference_table

pull/3336/head
Jelte Fennema 2020-01-03 11:55:27 +01:00
parent 7f3de68b0d
commit 883ee9121f
7 changed files with 68 additions and 68 deletions

View File

@ -17,14 +17,14 @@ s/node group [12] (but|does)/node group \1/
# Differing names can have differing table column widths
s/^-[+-]{2,}$/---------------------------------------------------------------------/g
## In foreign_key_to_reference_table, normalize shard table names, etc in
## the generated plan
#s/"(foreign_key_2_|fkey_ref_to_dist_|fkey_ref_)[0-9]+"/"\1xxxxxxx"/g
#s/"(referenced_table_|referencing_table_|referencing_table2_)[0-9]+"/"\1xxxxxxx"/g
#s/"(referencing_table_0_|referenced_table2_)[0-9]+"/"\1xxxxxxx"/g
#s/\(id\)=\([0-9]+\)/(id)=(X)/g
#s/\(ref_id\)=\([0-9]+\)/(ref_id)=(X)/g
#
# In foreign_key_to_reference_table, normalize shard table names, etc in
# the generated plan
s/"(foreign_key_2_|fkey_ref_to_dist_|fkey_ref_)[0-9]+"/"\1xxxxxxx"/g
s/"(referenced_table_|referencing_table_|referencing_table2_)[0-9]+"/"\1xxxxxxx"/g
s/"(referencing_table_0_|referenced_table2_)[0-9]+"/"\1xxxxxxx"/g
s/\(id\)=\([0-9]+\)/(id)=(X)/g
s/\(ref_id\)=\([0-9]+\)/(ref_id)=(X)/g
## shard table names for multi_subtransactions
#s/"t2_[0-9]+"/"t2_xxxxxxx"/g
#

View File

@ -452,8 +452,8 @@ ALTER TABLE referencing_table ADD CONSTRAINT fkey_ref FOREIGN KEY (ref_id) REFER
-- test inserts
-- test insert to referencing table while there is NO corresponding value in referenced table
INSERT INTO referencing_table VALUES(1, 1);
ERROR: insert or update on table "referencing_table_7000141" violates foreign key constraint "fkey_ref_7000141"
DETAIL: Key (ref_id)=(1) is not present in table "referenced_table_7000140".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test insert to referencing while there is corresponding value in referenced table
INSERT INTO referenced_table SELECT x, x from generate_series(1,1000) as f(x);
@ -461,8 +461,8 @@ INSERT INTO referencing_table SELECT x, x from generate_series(1,500) as f(x);
-- test deletes
-- test delete from referenced table while there is corresponding value in referencing table
DELETE FROM referenced_table WHERE id > 3;
ERROR: update or delete on table "referenced_table_7000140" violates foreign key constraint "fkey_ref_7000143" on table "referencing_table_7000143"
DETAIL: Key (id)=(4) is still referenced from table "referencing_table_7000143".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test delete from referenced table while there is NO corresponding value in referencing table
DELETE FROM referenced_table WHERE id = 501;
@ -644,8 +644,8 @@ INSERT INTO referenced_table SELECT x,x FROM generate_series(1,1000) AS f(x);
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_7000190" violates foreign key constraint "fkey_ref_7000190"
DETAIL: Key (ref_id)=(1004) is not present in table "referenced_table_7000187".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
DROP TABLE referenced_table CASCADE;
NOTICE: drop cascades to constraint fkey_ref on table referencing_table
DROP TABLE referencing_table CASCADE;
@ -675,8 +675,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_7000199" violates foreign key constraint "fkey_ref_7000199"
DETAIL: Key (ref_id)=(1004) is not present in table "referenced_table_7000196".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
DROP TABLE referenced_table CASCADE;
NOTICE: drop cascades to constraint fkey_ref on table referencing_table
DROP TABLE referencing_table CASCADE;
@ -817,16 +817,16 @@ 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_7000226" violates foreign key constraint "foreign_key_2_7000226"
DETAIL: Key (id)=(1) is not present in table "referenced_table2_7000225".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "foreign_key_2_xxxxxxx"
DETAIL: Key (id)=(X) is not present in table "referenced_table2_xxxxxxx".
-- 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_7000226" violates foreign key constraint "foreign_key_2_7000226"
DETAIL: Key (id)=(1) is not present in table "referenced_table2_7000225".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "foreign_key_2_xxxxxxx"
DETAIL: Key (id)=(X) is not present in table "referenced_table2_xxxxxxx".
-- 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_7000228" violates foreign key constraint "fkey_ref_7000228"
DETAIL: Key (id)=(1015) is not present in table "referenced_table_7000224".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx"
DETAIL: Key (id)=(X) is not present in table "referenced_table_xxxxxxx".
-- should succeed
INSERT INTO referencing_table SELECT x, x+1 FROM generate_series(600,900) AS f(x);
SELECT count(*) FROM referencing_table;
@ -945,13 +945,13 @@ 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_7000246" violates foreign key constraint "foreign_key_2_7000246"
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "foreign_key_2_xxxxxxx"
-- 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_7000246" violates foreign key constraint "foreign_key_2_7000246"
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "foreign_key_2_xxxxxxx"
-- 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_7000248" violates foreign key constraint "fkey_ref_7000248"
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "fkey_ref_xxxxxxx"
-- should succeed
INSERT INTO referencing_table SELECT x, x+501 FROM generate_series(0,1000) AS f(x);
SELECT count(*) FROM referencing_table;
@ -1083,14 +1083,14 @@ 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_7000273" violates foreign key constraint "fkey_ref_to_dist_7000273"
DETAIL: Key (id)=(1) is not present in table "referencing_table_7000265".
ERROR: insert or update on table "referencing_table2_xxxxxxx" violates foreign key constraint "fkey_ref_to_dist_xxxxxxx"
DETAIL: Key (id)=(X) is not present in table "referencing_table_xxxxxxx".
-- 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_7000273" violates foreign key constraint "fkey_ref_to_dist_7000273"
DETAIL: Key (id)=(401) is not present in table "referencing_table_7000265".
ERROR: insert or update on table "referencing_table2_xxxxxxx" violates foreign key constraint "fkey_ref_to_dist_xxxxxxx"
DETAIL: Key (id)=(X) is not present in table "referencing_table_xxxxxxx".
-- 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;
@ -1815,7 +1815,7 @@ ALTER TABLE referencing_table_4 ADD CONSTRAINT fkey_to_ref FOREIGN KEY (value_1)
-- should fail since the data will flow to partitioning_test_4 and it has a foreign constraint to partitioning_test_0 on id column
INSERT INTO referencing_table VALUES (0, 5);
ERROR: insert or update on table "referencing_table_4_7000540" violates foreign key constraint "fkey_7000540"
DETAIL: Key (id)=(0) is not present in table "referencing_table_0_7000524".
DETAIL: Key (id)=(X) is not present in table "referencing_table_0_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- should succeed on partitioning_test_0
INSERT INTO referencing_table VALUES (0, 1);
@ -1828,7 +1828,7 @@ SELECT * FROM referencing_table;
-- should fail since partitioning_test_4 has foreign constraint to referenced_table on value_1 column
INSERT INTO referencing_table VALUES (0, 5);
ERROR: insert or update on table "referencing_table_4_7000540" violates foreign key constraint "fkey_to_ref_7000540"
DETAIL: Key (value_1)=(5) is not present in table "referenced_table_7000512".
DETAIL: Key (value_1)=(5) is not present in table "referenced_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
INSERT INTO referenced_table VALUES(5,5);
-- should succeed since both of the foreign constraints are positive

View File

@ -113,7 +113,7 @@ ALTER TABLE unique_test_table ADD CONSTRAINT unn_id UNIQUE(id);
INSERT INTO unique_test_table VALUES(1, 'Ahmet');
INSERT INTO unique_test_table VALUES(1, 'Mehmet');
ERROR: duplicate key value violates unique constraint "unn_id_1450035"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
CONTEXT: while executing command on localhost:xxxxx
ALTER TABLE unique_test_table DROP CONSTRAINT unn_id;
-- Insert row which will conflict with the next unique constraint command
@ -121,7 +121,7 @@ INSERT INTO unique_test_table VALUES(1, 'Mehmet');
-- Can not create constraint since it conflicts with the existing data
ALTER TABLE unique_test_table ADD CONSTRAINT unn_id UNIQUE(id);
ERROR: could not create unique index "unn_id_1450035"
DETAIL: Key (id)=(1) is duplicated.
DETAIL: Key (id)=(X) is duplicated.
CONTEXT: while executing command on localhost:xxxxx
-- Can create unique constraint over multiple columns which must include
-- distribution column
@ -147,7 +147,7 @@ ALTER TABLE unique_test_table_ref ADD CONSTRAINT unn_id UNIQUE(id);
INSERT INTO unique_test_table_ref VALUES(1, 'Ahmet');
INSERT INTO unique_test_table_ref VALUES(1, 'Mehmet');
ERROR: duplicate key value violates unique constraint "unn_id_1450066"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
CONTEXT: while executing command on localhost:xxxxx
-- We can add unique constraint with multiple columns
ALTER TABLE unique_test_table_ref DROP CONSTRAINT unn_id;
@ -179,7 +179,7 @@ HINT: Consider using hash partitioning.
-- Error out. Table can not have two rows with the same id.
\COPY unique_test_table_append FROM STDIN DELIMITER AS ',';
ERROR: duplicate key value violates unique constraint "unn_id_1450067"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
DROP TABLE unique_test_table_append;
-- Check "CHECK CONSTRAINT"
CREATE TABLE products (

View File

@ -133,8 +133,8 @@ SELECT create_distributed_table('referencing_table', 'ref_id', 'hash');
-- test inserts
-- test insert to referencing table while there is NO corresponding value in referenced table
INSERT INTO referencing_table VALUES(1, 1);
ERROR: insert or update on table "referencing_table_1350129" violates foreign key constraint "referencing_table_ref_id_fkey_1350129"
DETAIL: Key (ref_id)=(1) is not present in table "referenced_table_1350097".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350129"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test insert to referencing while there is corresponding value in referenced table
INSERT INTO referenced_table VALUES(1, 1);
@ -142,8 +142,8 @@ INSERT INTO referencing_table VALUES(1, 1);
-- test deletes
-- test delete from referenced table while there is corresponding value in referencing table
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350097" violates foreign key constraint "referencing_table_ref_id_fkey_1350129" on table "referencing_table_1350129"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350129".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350129" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test delete from referenced table while there is NO corresponding value in referencing table
DELETE FROM referencing_table WHERE ref_id = 1;
@ -227,8 +227,8 @@ SELECT create_distributed_table('referencing_table', 'ref_id', 'hash');
INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350225" violates foreign key constraint "referencing_table_ref_id_fkey_1350257" on table "referencing_table_1350257"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350257".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350257" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
BEGIN;
DELETE FROM referenced_table WHERE id = 1;
@ -265,8 +265,8 @@ INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
BEGIN;
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350289" violates foreign key constraint "referencing_table_ref_id_fkey_1350321" on table "referencing_table_1350321"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350321".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350321" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
DELETE FROM referencing_table WHERE ref_id = 1;
ERROR: current transaction is aborted, commands ignored until end of transaction block
@ -303,8 +303,8 @@ SELECT create_distributed_table('referencing_table', 'ref_id', 'hash');
INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
UPDATE referenced_table SET test_column = 10 WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350353" violates foreign key constraint "referencing_table_ref_id_fkey_1350385" on table "referencing_table_1350385"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_1350385".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350385" on table "referencing_table_xxxxxxx"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
BEGIN;
UPDATE referenced_table SET test_column = 10 WHERE id = 1;
@ -343,8 +343,8 @@ INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
BEGIN;
UPDATE referenced_table SET test_column = 20 WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350417" violates foreign key constraint "referencing_table_ref_id_fkey_1350449" on table "referencing_table_1350449"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_1350449".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350449" on table "referencing_table_xxxxxxx"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
UPDATE referencing_table SET id = 20 WHERE ref_id = 1;
ERROR: current transaction is aborted, commands ignored until end of transaction block
@ -404,7 +404,7 @@ SELECT create_distributed_table('referencing_table', 'ref_id', 'hash');
(1 row)
INSERT INTO referencing_table VALUES(null, 2);
ERROR: insert or update on table "referencing_table_1350600" violates foreign key constraint "referencing_table_ref_id_fkey_1350600"
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "referencing_table_ref_id_fkey_1350600"
DETAIL: MATCH FULL does not allow mixing of null and nonnull key values.
CONTEXT: while executing command on localhost:xxxxx
SELECT * FROM referencing_table;
@ -521,8 +521,8 @@ ERROR: number of referencing and referenced columns for foreign key disagree
-- test foreign constraint creation while existing tables does not satisfy the constraint
INSERT INTO referencing_table VALUES(1, 1);
ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id) REFERENCES referenced_table(id);
ERROR: insert or update on table "referencing_table_1350628" violates foreign key constraint "test_constraint_1350628"
DETAIL: Key (ref_id)=(1) is not present in table "referenced_table_1350624".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test foreign constraint with correct conditions
DELETE FROM referencing_table WHERE ref_id = 1;
@ -530,8 +530,8 @@ ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id)
-- test inserts
-- test insert to referencing table while there is NO corresponding value in referenced table
INSERT INTO referencing_table VALUES(1, 1);
ERROR: insert or update on table "referencing_table_1350628" violates foreign key constraint "test_constraint_1350628"
DETAIL: Key (ref_id)=(1) is not present in table "referenced_table_1350624".
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628"
DETAIL: Key (ref_id)=(X) is not present in table "referenced_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test insert to referencing while there is corresponding value in referenced table
INSERT INTO referenced_table VALUES(1, 1);
@ -539,8 +539,8 @@ INSERT INTO referencing_table VALUES(1, 1);
-- test deletes
-- test delete from referenced table while there is corresponding value in referencing table
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350624" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_1350628"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350628".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
-- test delete from referenced table while there is NO corresponding value in referencing table
DELETE FROM referencing_table WHERE ref_id = 1;
@ -569,8 +569,8 @@ ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id)
INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350624" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_1350628"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350628".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
BEGIN;
DELETE FROM referenced_table WHERE id = 1;
@ -593,8 +593,8 @@ INSERT INTO referenced_table VALUES(1, 1);
INSERT INTO referencing_table VALUES(1, 1);
BEGIN;
DELETE FROM referenced_table WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350624" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_1350628"
DETAIL: Key (id)=(1) is still referenced from table "referencing_table_1350628".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_xxxxxxx"
DETAIL: Key (id)=(X) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
DELETE FROM referencing_table WHERE ref_id = 1;
ERROR: current transaction is aborted, commands ignored until end of transaction block
@ -615,8 +615,8 @@ ALTER TABLE referencing_table DROP CONSTRAINT test_constraint;
-- test ON UPDATE NO ACTION + DEFERABLE + INITIALLY DEFERRED
ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id, id) REFERENCES referenced_table(id, test_column) ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED;
UPDATE referenced_table SET test_column = 10 WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350624" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_1350628"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_1350628".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_xxxxxxx"
DETAIL: Key (id, test_column)=(1, 1) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
BEGIN;
UPDATE referenced_table SET test_column = 10 WHERE id = 1;
@ -639,8 +639,8 @@ ALTER TABLE referencing_table DROP CONSTRAINT test_constraint;
ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id, id) REFERENCES referenced_table(id, test_column) ON UPDATE RESTRICT;
BEGIN;
UPDATE referenced_table SET test_column = 20 WHERE id = 1;
ERROR: update or delete on table "referenced_table_1350624" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_1350628"
DETAIL: Key (id, test_column)=(1, 10) is still referenced from table "referencing_table_1350628".
ERROR: update or delete on table "referenced_table_xxxxxxx" violates foreign key constraint "test_constraint_1350628" on table "referencing_table_xxxxxxx"
DETAIL: Key (id, test_column)=(1, 10) is still referenced from table "referencing_table_xxxxxxx".
CONTEXT: while executing command on localhost:xxxxx
UPDATE referencing_table SET id = 20 WHERE ref_id = 1;
ERROR: current transaction is aborted, commands ignored until end of transaction block
@ -673,7 +673,7 @@ ALTER TABLE referencing_table DROP CONSTRAINT test_constraint;
-- test MATCH FULL
ALTER TABLE referencing_table ADD CONSTRAINT test_constraint FOREIGN KEY(ref_id, id) REFERENCES referenced_table(id, test_column) MATCH FULL;
INSERT INTO referencing_table VALUES(null, 2);
ERROR: insert or update on table "referencing_table_1350631" violates foreign key constraint "test_constraint_1350631"
ERROR: insert or update on table "referencing_table_xxxxxxx" violates foreign key constraint "test_constraint_1350631"
DETAIL: MATCH FULL does not allow mixing of null and nonnull key values.
CONTEXT: while executing command on localhost:xxxxx
SELECT * FROM referencing_table;
@ -749,7 +749,7 @@ COMMIT;
-- test insertion to referencing table, we expect that to fail
INSERT INTO transaction_referencing_table VALUES(1, 1);
ERROR: insert or update on table "transaction_referencing_table" violates foreign key constraint "transaction_fk_constraint"
DETAIL: Key (ref_id)=(1) is not present in table "transaction_referenced_table".
DETAIL: Key (ref_id)=(X) is not present in table "transaction_referenced_table".
-- proper insertion to both referenced and referencing tables
INSERT INTO transaction_referenced_table VALUES(1);
INSERT INTO transaction_referencing_table VALUES(1, 1);

View File

@ -484,7 +484,7 @@ BEGIN;
INSERT INTO objects VALUES (1, 'apple');
INSERT INTO objects VALUES (1, 'orange');
ERROR: duplicate key value violates unique constraint "objects_pkey_1200003"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
CONTEXT: while executing command on localhost:xxxxx
COMMIT;
-- data shouldn't have persisted...

View File

@ -201,7 +201,7 @@ BEGIN;
INSERT INTO objects_mx VALUES (1, 'apple');
INSERT INTO objects_mx VALUES (1, 'orange');
ERROR: duplicate key value violates unique constraint "objects_mx_pkey_1220103"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
COMMIT;
-- data shouldn't have persisted...
SELECT * FROM objects_mx WHERE id = 1;
@ -216,7 +216,7 @@ BEGIN;
INSERT INTO objects_mx VALUES (1, 'apple');
INSERT INTO objects_mx VALUES (1, 'orange');
ERROR: duplicate key value violates unique constraint "objects_mx_pkey_1220103"
DETAIL: Key (id)=(1) already exists.
DETAIL: Key (id)=(X) already exists.
CONTEXT: while executing command on localhost:xxxxx
COMMIT;
-- data shouldn't have persisted...

View File

@ -1919,7 +1919,7 @@ INSERT INTO partitioning_test_2010 VALUES (1, '2010-02-01');
ALTER TABLE partitioning_test ATTACH PARTITION partitioning_test_2010
FOR VALUES FROM ('2010-01-01') TO ('2011-01-01');
ERROR: insert or update on table "partitioning_test_2010_1660191" violates foreign key constraint "partitioning_reference_fkey_1660179"
DETAIL: Key (id)=(1) is not present in table "reference_table_1660177".
DETAIL: Key (id)=(X) is not present in table "reference_table_1660177".
CONTEXT: while executing command on localhost:xxxxx
-- Truncate, so attaching again won't fail
TRUNCATE partitioning_test_2010;