mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Use the affinity and collation sequence associated with the parent key when finding child table rows to apply a foreign key action to.
FossilOrigin-Name: 9a4b7ec2928307e88783223903c842accaff7ccf
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Check\sthat\sa\sunique\sindex\suses\sthe\sdefault\scollation\ssequences\sfor\seach\scolumn\sbefore\susing\sit\sas\spart\sof\sa\sforeign\skey\sconstraint\soperation.
|
C Use\sthe\saffinity\sand\scollation\ssequence\sassociated\swith\sthe\sparent\skey\swhen\sfinding\schild\stable\srows\sto\sapply\sa\sforeign\skey\saction\sto.
|
||||||
D 2009-09-29T15:41:58
|
D 2009-09-29T16:38:59
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
|
F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -116,7 +116,7 @@ F src/date.c 657ff12ca0f1195b531561afacbb38b772d16638
|
|||||||
F src/delete.c 2a3d6fc0861b2f8dbd9feb7847b390267b281c60
|
F src/delete.c 2a3d6fc0861b2f8dbd9feb7847b390267b281c60
|
||||||
F src/expr.c c7f3f718bd5c392344ec8694a41c1824f30cf375
|
F src/expr.c c7f3f718bd5c392344ec8694a41c1824f30cf375
|
||||||
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
||||||
F src/fkey.c aed9dc4cb046a014f6ea1b6a88cfb440eb9e505d
|
F src/fkey.c e1128e8d2309b91d65b8c6a92b69060da3901bd1
|
||||||
F src/func.c e536218d193b8d326aab91120bc4c6f28aa2b606
|
F src/func.c e536218d193b8d326aab91120bc4c6f28aa2b606
|
||||||
F src/global.c 271952d199a8cc59d4ce840b3bbbfd2f30c8ba32
|
F src/global.c 271952d199a8cc59d4ce840b3bbbfd2f30c8ba32
|
||||||
F src/hash.c ebcaa921ffd9d86f7ea5ae16a0a29d1c871130a7
|
F src/hash.c ebcaa921ffd9d86f7ea5ae16a0a29d1c871130a7
|
||||||
@@ -330,7 +330,7 @@ F test/expr.test 9f521ae22f00e074959f72ce2e55d46b9ed23f68
|
|||||||
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
|
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
|
||||||
F test/filefmt.test 84e3d0fe9f12d0d2ac852465c6f8450aea0d6f43
|
F test/filefmt.test 84e3d0fe9f12d0d2ac852465c6f8450aea0d6f43
|
||||||
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
|
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
|
||||||
F test/fkey2.test dbed32250f12630eba0c7f5753b00163b1894f98
|
F test/fkey2.test df3c11ad1e2fb5410fc7321e24adaaff070d44d3
|
||||||
F test/fkey3.test c17565b40c97a0dd5102610183c744611171b5ec
|
F test/fkey3.test c17565b40c97a0dd5102610183c744611171b5ec
|
||||||
F test/fkey_malloc.test da912d000bb6ceb1cd11b655de1989762fa71ceb
|
F test/fkey_malloc.test da912d000bb6ceb1cd11b655de1989762fa71ceb
|
||||||
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
|
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
|
||||||
@@ -755,7 +755,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 582bd7682831362cd0e2f91ac0dba5ab2b7e2983
|
P 64154174cf8a53bd9be818db53cb0e586c5d24cb
|
||||||
R 3ab2e65e80babb1c9a5df9ed1abb2dff
|
R 106a7bccc4ebf5897fe5a8bdc17cd4b9
|
||||||
U dan
|
U dan
|
||||||
Z 01b8ddbb56d6c81de7ecc57f15cb5ec5
|
Z 024ff679317ae3aeff7b2b65f53c42a0
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
64154174cf8a53bd9be818db53cb0e586c5d24cb
|
9a4b7ec2928307e88783223903c842accaff7ccf
|
||||||
@@ -952,13 +952,16 @@ static Trigger *fkActionTrigger(
|
|||||||
tToCol.n = sqlite3Strlen30(tToCol.z);
|
tToCol.n = sqlite3Strlen30(tToCol.z);
|
||||||
tFromCol.n = sqlite3Strlen30(tFromCol.z);
|
tFromCol.n = sqlite3Strlen30(tFromCol.z);
|
||||||
|
|
||||||
/* Create the expression "zFromCol = OLD.zToCol" */
|
/* Create the expression "OLD.zToCol = zFromCol". It is important
|
||||||
|
** that the "OLD.zToCol" term is on the LHS of the = operator, so
|
||||||
|
** that the affinity and collation sequence associated with the
|
||||||
|
** parent table are used for the comparison. */
|
||||||
pEq = sqlite3PExpr(pParse, TK_EQ,
|
pEq = sqlite3PExpr(pParse, TK_EQ,
|
||||||
sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol),
|
|
||||||
sqlite3PExpr(pParse, TK_DOT,
|
sqlite3PExpr(pParse, TK_DOT,
|
||||||
sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
|
sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
|
||||||
sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
|
sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
|
||||||
, 0)
|
, 0),
|
||||||
|
sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
|
||||||
, 0);
|
, 0);
|
||||||
pWhere = sqlite3ExprAnd(db, pWhere, pEq);
|
pWhere = sqlite3ExprAnd(db, pWhere, pEq);
|
||||||
|
|
||||||
|
|||||||
@@ -656,7 +656,7 @@ do_test fkey2-9.2.3 {
|
|||||||
# The following tests, fkey2-10.*, test "foreign key mismatch" and
|
# The following tests, fkey2-10.*, test "foreign key mismatch" and
|
||||||
# other errors.
|
# other errors.
|
||||||
#
|
#
|
||||||
set tn 1
|
set tn 0
|
||||||
foreach zSql [list {
|
foreach zSql [list {
|
||||||
CREATE TABLE p(a PRIMARY KEY, b);
|
CREATE TABLE p(a PRIMARY KEY, b);
|
||||||
CREATE TABLE c(x REFERENCES p(c));
|
CREATE TABLE c(x REFERENCES p(c));
|
||||||
@@ -672,8 +672,7 @@ foreach zSql [list {
|
|||||||
CREATE TABLE c(x REFERENCES p(a));
|
CREATE TABLE c(x REFERENCES p(a));
|
||||||
}] {
|
}] {
|
||||||
drop_all_tables
|
drop_all_tables
|
||||||
|
do_test fkey2-10.1.[incr tn] {
|
||||||
do_test fkey2-10.1.$tn {
|
|
||||||
execsql $zSql
|
execsql $zSql
|
||||||
catchsql { INSERT INTO c DEFAULT VALUES }
|
catchsql { INSERT INTO c DEFAULT VALUES }
|
||||||
} {1 {foreign key mismatch}}
|
} {1 {foreign key mismatch}}
|
||||||
@@ -770,6 +769,48 @@ do_test fkey2-12.1.7 {
|
|||||||
}
|
}
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
|
drop_all_tables
|
||||||
|
do_test fkey2-12.2.1 {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE t1(x COLLATE NOCASE PRIMARY KEY);
|
||||||
|
CREATE TRIGGER tt1 AFTER DELETE ON t1
|
||||||
|
WHEN EXISTS ( SELECT 1 FROM t2 WHERE old.x = y )
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO t1 VALUES(old.x);
|
||||||
|
END;
|
||||||
|
CREATE TABLE t2(y REFERENCES t1);
|
||||||
|
INSERT INTO t1 VALUES('A');
|
||||||
|
INSERT INTO t1 VALUES('B');
|
||||||
|
INSERT INTO t2 VALUES('a');
|
||||||
|
INSERT INTO t2 VALUES('b');
|
||||||
|
|
||||||
|
SELECT * FROM t1;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
}
|
||||||
|
} {A B a b}
|
||||||
|
do_test fkey2-12.2.2 {
|
||||||
|
execsql { DELETE FROM t1 }
|
||||||
|
execsql {
|
||||||
|
SELECT * FROM t1;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
}
|
||||||
|
} {A B a b}
|
||||||
|
do_test fkey2-12.2.3 {
|
||||||
|
execsql {
|
||||||
|
DROP TABLE t2;
|
||||||
|
CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);
|
||||||
|
INSERT INTO t2 VALUES('a');
|
||||||
|
INSERT INTO t2 VALUES('b');
|
||||||
|
}
|
||||||
|
catchsql { DELETE FROM t1 }
|
||||||
|
} {1 {foreign key constraint failed}}
|
||||||
|
do_test fkey2-12.2.4 {
|
||||||
|
execsql {
|
||||||
|
SELECT * FROM t1;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
}
|
||||||
|
} {A B a b}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# The following tests, fkey2-13.*, test that FK processing is performed
|
# The following tests, fkey2-13.*, test that FK processing is performed
|
||||||
# when rows are REPLACEd.
|
# when rows are REPLACEd.
|
||||||
|
|||||||
Reference in New Issue
Block a user