1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Correct handling of compound foreign key constraints that include the

integer primary key as one of the columns.  
Ticket [ce7c133ea6cc9ccdc1]

FossilOrigin-Name: 53902f7d4a46aa70ecc5bf180a01ff888d52686a
This commit is contained in:
drh
2010-07-29 01:50:38 +00:00
parent 078e4084e9
commit 6cbda64d07
4 changed files with 58 additions and 12 deletions

View File

@@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Get\sSQLITE_OMIT_VIRTUALTABLE\sworking\sagain\safter\sbeing\sbroken\sby\srecent\nchanges.
D 2010-07-28T19:17:51
C Correct\shandling\sof\scompound\sforeign\skey\sconstraints\sthat\sinclude\sthe\s\ninteger\sprimary\skey\sas\sone\sof\sthe\scolumns.\s\s\nTicket\s[ce7c133ea6cc9ccdc1]
D 2010-07-29T01:50:39
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -127,7 +127,7 @@ F src/date.c 5dd8448a0bfea8d31fb14cff487d0c06ff8c8b20
F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd
F src/expr.c a0fd9c5e248229851077de92f2e9346f2c43ed46
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c cacfe3e24b311e4e089a9c470bdb73196af6f729
F src/fkey.c 58bbf52c6ddd3f64ca40a3230f9e548a83a5cb16
F src/func.c 75dc1fd91e5692cadb80d257bab68d7343060467
F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
@@ -357,7 +357,7 @@ F test/expr.test 9f521ae22f00e074959f72ce2e55d46b9ed23f68
F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e
F test/filefmt.test 5d271bf467e6557fe7499dcc8203069c9dc5825e
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
F test/fkey2.test 098c06c139a79f690301a43511cd1f6420ae5433
F test/fkey2.test e028cd80aa0bd38541c99214e3ba2dfccadffe6f
F test/fkey3.test 42f88d6048d8dc079e2a8cf7baad1cc1483a7620
F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
@@ -842,14 +842,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P a3401d9ee540828f3efd26d89f6b771e0ecb2777
R eb10d882c7f0c445d545596dbfed0422
P 33b1e862ffa7109480cf4a77ceae8aebe98d3eee
R 1a747cd66c3cb3531b2d422eed64646d
U drh
Z e999ed9036c340aa6dca3b64e8338713
Z f3390b0f32a832cb0283a0a97736cdae
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFMUIJioxKgR168RlERAuXQAJ9FI7fhAyA4RJomQp31Ht8ypo2meACbBmAO
JUSNNYQ1jjZQIsqp8HPdpZw=
=0jgg
iD8DBQFMUN5zoxKgR168RlERAuaoAJsGqWIctdVM52Ga01Y24rzgl5SLEgCeK9O0
mB2frcny0J2mHg1qnqy1X4A=
=UB37
-----END PGP SIGNATURE-----

View File

@@ -1 +1 @@
33b1e862ffa7109480cf4a77ceae8aebe98d3eee
53902f7d4a46aa70ecc5bf180a01ff888d52686a

View File

@@ -500,7 +500,8 @@ static void fkScanChildren(
if( pIdx ){
Column *pCol;
iCol = pIdx->aiColumn[i];
pCol = &pIdx->pTable->aCol[iCol];
pCol = &pTab->aCol[iCol];
if( pTab->iPKey==iCol ) iCol = -1;
pLeft->iTable = regData+iCol+1;
pLeft->affinity = pCol->affinity;
pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl);

View File

@@ -1936,5 +1936,50 @@ do_test fkey2-dd08e5.1.6 {
}
} {1 {foreign key constraint failed}}
#-------------------------------------------------------------------------
# Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba
# fixed.
#
do_test fkey2-ce7c13.1.1 {
execsql {
CREATE TABLE tce71(a INTEGER PRIMARY KEY, b);
CREATE UNIQUE INDEX ice71 ON tce71(a,b);
INSERT INTO tce71 VALUES(100,200);
CREATE TABLE tce72(w, x, y, FOREIGN KEY(x,y) REFERENCES tce71(a,b));
INSERT INTO tce72 VALUES(300,100,200);
UPDATE tce71 set b = 200 where a = 100;
SELECT * FROM tce71, tce72;
}
} {100 200 300 100 200}
do_test fkey2-ce7c13.1.2 {
catchsql {
UPDATE tce71 set b = 201 where a = 100;
}
} {1 {foreign key constraint failed}}
do_test fkey2-ce7c13.1.3 {
catchsql {
UPDATE tce71 set a = 101 where a = 100;
}
} {1 {foreign key constraint failed}}
do_test fkey2-ce7c13.1.4 {
execsql {
CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b));
INSERT INTO tce73 VALUES(100,200);
CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));
INSERT INTO tce74 VALUES(300,100,200);
UPDATE tce73 set b = 200 where a = 100;
SELECT * FROM tce73, tce74;
}
} {100 200 300 100 200}
do_test fkey2-ce7c13.1.5 {
catchsql {
UPDATE tce73 set b = 201 where a = 100;
}
} {1 {foreign key constraint failed}}
do_test fkey2-ce7c13.1.6 {
catchsql {
UPDATE tce73 set a = 101 where a = 100;
}
} {1 {foreign key constraint failed}}
finish_test