Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e5a16c

Browse files
committed
The deferred trigger queue pushing to disk patch pointed out
that the regression tests for foreign keys didn't seem to testa deferred constraint that was not satisified by a laterstatement and was not made immediate by set constraints,so here's a simple added test with a single invalid insert anda commit.Stephan Szabo
1 parent1be17f1 commit1e5a16c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

‎src/test/regress/expected/foreign_key.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,3 +1053,22 @@ INSERT INTO pktable VALUES (2000, 3); -- too late
10531053
ERROR: current transaction is aborted, queries ignored until end of transaction block
10541054
COMMIT;
10551055
DROP TABLE fktable, pktable;
1056+
-- deferrable, initially deferred
1057+
CREATE TABLE pktable (
1058+
idINT4 PRIMARY KEY,
1059+
otherINT4
1060+
);
1061+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
1062+
CREATE TABLE fktable (
1063+
idINT4 PRIMARY KEY,
1064+
fkINT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED
1065+
);
1066+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "fktable_pkey" for table "fktable"
1067+
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
1068+
BEGIN;
1069+
-- no error here
1070+
INSERT INTO fktable VALUES (100, 200);
1071+
-- error here on commit
1072+
COMMIT;
1073+
ERROR: insert or update on "fktable" violates foreign key constraint "$1"
1074+
DETAIL: Key (fk)=(200) is not present in "pktable".

‎src/test/regress/sql/foreign_key.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,23 @@ INSERT INTO pktable VALUES (2000, 3); -- too late
674674
COMMIT;
675675

676676
DROPTABLE fktable, pktable;
677+
678+
-- deferrable, initially deferred
679+
CREATETABLEpktable (
680+
idINT4PRIMARY KEY,
681+
otherINT4
682+
);
683+
684+
CREATETABLEfktable (
685+
idINT4PRIMARY KEY,
686+
fkINT4REFERENCES pktable DEFERRABLE INITIALLY DEFERRED
687+
);
688+
689+
BEGIN;
690+
691+
-- no error here
692+
INSERT INTO fktableVALUES (100,200);
693+
694+
-- error here on commit
695+
COMMIT;
696+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp