mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-19 21:43:15 +03:00
Disable the RESTRICT foreign key action if "PRAGMA defer_foreign_keys" is set.
FossilOrigin-Name: 82470d1c3a41221c78bcdd402b2219c4c21c43af
This commit is contained in:
19
manifest
19
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Merge\sthe\sLIKE-operator\sbug\sfix\sfrom\strunk.
|
C Disable\sthe\sRESTRICT\sforeign\skey\saction\sif\s"PRAGMA\sdefer_foreign_keys"\sis\sset.
|
||||||
D 2016-01-20T16:02:48.763
|
D 2016-01-21T17:25:56.966
|
||||||
F Makefile.in a47ec69daac0cdfe3413e50ceea6dc8da3dc4ecb
|
F Makefile.in a47ec69daac0cdfe3413e50ceea6dc8da3dc4ecb
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc b4d0270955b3f102214b2242f2a1b802c22ee21b
|
F Makefile.msc b4d0270955b3f102214b2242f2a1b802c22ee21b
|
||||||
@@ -320,7 +320,7 @@ F src/dbstat.c ffd63fc8ba7541476ced189b95e95d7f2bc63f78
|
|||||||
F src/delete.c 86e3940d07fe69a40270c2aaf6ca6c7adf19246c
|
F src/delete.c 86e3940d07fe69a40270c2aaf6ca6c7adf19246c
|
||||||
F src/expr.c df0d7c3230d59abd679da22ff5ce4cfd0e3a0e63
|
F src/expr.c df0d7c3230d59abd679da22ff5ce4cfd0e3a0e63
|
||||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||||
F src/fkey.c e18b3dff7d47c7bcac5ac4fc178a89b9fd322b44
|
F src/fkey.c 3fd2e17526d8586fdeafa376672c9303b7e35e7f
|
||||||
F src/func.c ba6c03f9e440f5693086c08ee88e6e60212b3504
|
F src/func.c ba6c03f9e440f5693086c08ee88e6e60212b3504
|
||||||
F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260
|
F src/global.c bd5a0af3f30b0c01be6db756c626cd3c33a3d260
|
||||||
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
|
F src/hash.c 4263fbc955f26c2e8cdc0cf214bc42435aa4e4f5
|
||||||
@@ -656,7 +656,7 @@ F test/fkey2.test f3d27ecba480a348c328965d154214719bb158a9
|
|||||||
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
|
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
|
||||||
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
|
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
|
||||||
F test/fkey5.test 5a373303f201ac03c22ba1ef17a733d3f56e611a
|
F test/fkey5.test 5a373303f201ac03c22ba1ef17a733d3f56e611a
|
||||||
F test/fkey6.test 6697550baa38505c9952eff130ab26a2d156c0cc
|
F test/fkey6.test d078a1e323a740062bed38df32b8a736fd320dc0
|
||||||
F test/fkey7.test 72e915890ee4a005daaf3002cb208e8fe973ac13
|
F test/fkey7.test 72e915890ee4a005daaf3002cb208e8fe973ac13
|
||||||
F test/fkey8.test 8f08203458321e6c19a263829de4cfc936274ab0
|
F test/fkey8.test 8f08203458321e6c19a263829de4cfc936274ab0
|
||||||
F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
|
F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
|
||||||
@@ -1440,7 +1440,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P 327af5f644a49b2f41d5456958f9d61a2b704e1c e8adeb64d4e463772feb58dbd6f00715b92e735c
|
P 36cb3d6e274a06a78693ca506feaad0b14bde11d
|
||||||
R ed9d6c66302fd811ae6a8e53c4d95620
|
R f0ee48a1a8d6b1b8328a4821e1589857
|
||||||
U drh
|
T *branch * disable-restrict
|
||||||
Z 8662dc0834e686268b7ae44f172fcd73
|
T *sym-disable-restrict *
|
||||||
|
T -sym-sessions *
|
||||||
|
U dan
|
||||||
|
Z 284a240298ca9699332d11236aa182a9
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
36cb3d6e274a06a78693ca506feaad0b14bde11d
|
82470d1c3a41221c78bcdd402b2219c4c21c43af
|
||||||
@@ -1163,6 +1163,9 @@ static Trigger *fkActionTrigger(
|
|||||||
|
|
||||||
action = pFKey->aAction[iAction];
|
action = pFKey->aAction[iAction];
|
||||||
pTrigger = pFKey->apTrigger[iAction];
|
pTrigger = pFKey->apTrigger[iAction];
|
||||||
|
if( (db->flags & SQLITE_DeferFKs) && action==OE_Restrict ){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( action!=OE_None && !pTrigger ){
|
if( action!=OE_None && !pTrigger ){
|
||||||
u8 enableLookaside; /* Copy of db->lookaside.bEnabled */
|
u8 enableLookaside; /* Copy of db->lookaside.bEnabled */
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
set testprefix fkey6
|
||||||
|
|
||||||
ifcapable {!foreignkey} {
|
ifcapable {!foreignkey} {
|
||||||
finish_test
|
finish_test
|
||||||
@@ -171,5 +172,58 @@ do_execsql_test fkey6-2.6 {
|
|||||||
PRAGMA defer_foreign_keys;
|
PRAGMA defer_foreign_keys;
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------
|
||||||
|
# Test that defer_foreign_keys disables RESTRICT.
|
||||||
|
#
|
||||||
|
do_execsql_test 3.1 {
|
||||||
|
CREATE TABLE p2(a PRIMARY KEY, b);
|
||||||
|
CREATE TABLE c2(x, y REFERENCES p2 ON DELETE RESTRICT ON UPDATE RESTRICT);
|
||||||
|
INSERT INTO p2 VALUES(1, 'one');
|
||||||
|
INSERT INTO p2 VALUES(2, 'two');
|
||||||
|
INSERT INTO c2 VALUES('i', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
do_catchsql_test 3.2.1 {
|
||||||
|
BEGIN;
|
||||||
|
UPDATE p2 SET a=a-1;
|
||||||
|
} {1 {FOREIGN KEY constraint failed}}
|
||||||
|
do_execsql_test 3.2.2 { COMMIT }
|
||||||
|
|
||||||
|
do_execsql_test 3.2.3 {
|
||||||
|
BEGIN;
|
||||||
|
PRAGMA defer_foreign_keys = 1;
|
||||||
|
UPDATE p2 SET a=a-1;
|
||||||
|
COMMIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_execsql_test 3.2.4 {
|
||||||
|
BEGIN;
|
||||||
|
PRAGMA defer_foreign_keys = 1;
|
||||||
|
UPDATE p2 SET a=a-1;
|
||||||
|
}
|
||||||
|
do_catchsql_test 3.2.5 {
|
||||||
|
COMMIT;
|
||||||
|
} {1 {FOREIGN KEY constraint failed}}
|
||||||
|
do_execsql_test 3.2.6 { ROLLBACK }
|
||||||
|
|
||||||
|
do_execsql_test 3.3.1 {
|
||||||
|
CREATE TRIGGER p2t AFTER DELETE ON p2 BEGIN
|
||||||
|
INSERT INTO p2 VALUES(old.a, 'deleted!');
|
||||||
|
END;
|
||||||
|
}
|
||||||
|
do_catchsql_test 3.3.2 {
|
||||||
|
BEGIN;
|
||||||
|
DELETE FROM p2 WHERE a=1;
|
||||||
|
} {1 {FOREIGN KEY constraint failed}}
|
||||||
|
do_execsql_test 3.3.3 { COMMIT }
|
||||||
|
|
||||||
|
do_execsql_test 3.3.4 {
|
||||||
|
BEGIN;
|
||||||
|
PRAGMA defer_foreign_keys = 1;
|
||||||
|
DELETE FROM p2 WHERE a=1;
|
||||||
|
COMMIT;
|
||||||
|
SELECT * FROM p2;
|
||||||
|
} {0 one 1 deleted!}
|
||||||
|
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|||||||
Reference in New Issue
Block a user