mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-03 08:01:19 +03:00
Fix for [b1d3a2e531].
FossilOrigin-Name: 3f3acee465a6e390301f9dc588dd1d8e0bd646bd
This commit is contained in:
15
manifest
15
manifest
@@ -1,5 +1,5 @@
|
||||
C When\sretrying\sa\swrite()\safter\san\sEINTR\serror\son\sunix,\sbe\ssure\sto\salso\nrerun\sthe\sprevious\slseek().\s\sTicket\s[e59bdf6116036a]
|
||||
D 2011-08-19T14:54:12.709
|
||||
C Fix\sfor\s[b1d3a2e531].
|
||||
D 2011-08-22T09:54:26.787
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 8c930e7b493d59099ea1304bd0f2aed152eb3315
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -135,7 +135,7 @@ F src/date.c a3c6842bad7ae632281811de112a8ba63ff08ab3
|
||||
F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8
|
||||
F src/expr.c 4bbdfaf66bc614be9254ce0c26a17429067a3e07
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c c8492fed772af1ed61251582707266227612b45b
|
||||
F src/fkey.c c92c8eece2b64efd0966efa0a5bef6d9e1a510fd
|
||||
F src/func.c 59bb046d7e3df1ab512ac339ccb0a6f996a17cb7
|
||||
F src/global.c c70a46f28680f8d7c097dbc0430ccf3b932e90b0
|
||||
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
|
||||
@@ -733,6 +733,7 @@ F test/tkt-8454a207b9.test c583a9f814a82a2b5ba95207f55001c9f0cd816c
|
||||
F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5
|
||||
F test/tkt-94c04eaadb.test be5ea61cb04dfdc047d19b5c5a9e75fa3da67a7f
|
||||
F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67
|
||||
F test/tkt-b1d3a2e531.test 610ef582413171b379652663111b1f996d9f8f78
|
||||
F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0
|
||||
F test/tkt-b72787b1.test e6b62b2b2785c04d0d698d6a603507e384165049
|
||||
F test/tkt-bd484a090c.test 60460bf946f79a79712b71f202eda501ca99b898
|
||||
@@ -960,7 +961,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
|
||||
F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262
|
||||
P 928bcaf0f00a408e2f6c1d85dfab214457f52ad5
|
||||
R 843a68fd8264832950d511247e1afac6
|
||||
U drh
|
||||
Z 08ca15b3cb3d5aca6ddea45758dd9762
|
||||
P 21452f3ae6b5882b03c7cc41e661c7b8144cc3df
|
||||
R 6e7c1928d4170588c7bdf4f235f82163
|
||||
U dan
|
||||
Z 675b337ab718118c5da55278cd8c06b6
|
||||
|
||||
@@ -1 +1 @@
|
||||
21452f3ae6b5882b03c7cc41e661c7b8144cc3df
|
||||
3f3acee465a6e390301f9dc588dd1d8e0bd646bd
|
||||
17
src/fkey.c
17
src/fkey.c
@@ -734,7 +734,24 @@ void sqlite3FkCheck(
|
||||
pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);
|
||||
}
|
||||
if( !pTo || locateFkeyIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
|
||||
assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );
|
||||
if( !isIgnoreErrors || db->mallocFailed ) return;
|
||||
if( isIgnoreErrors && pTo==0 ){
|
||||
/* If isIgnoreErrors is true, then a table is being dropped. In this
|
||||
** case SQLite runs a "DELETE FROM xxx" on the table being dropped
|
||||
** before actually dropping it in order to check FK constraints.
|
||||
** If the parent table of an FK constraint on the current table is
|
||||
** missing, behave as if it is empty. i.e. decrement the relevant
|
||||
** FK counter for each row of the current table with non-NULL keys.
|
||||
*/
|
||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||
int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;
|
||||
for(i=0; i<pFKey->nCol; i++){
|
||||
int iReg = pFKey->aCol[i].iFrom + regOld + 1;
|
||||
sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump);
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
assert( pFKey->nCol==1 || (aiFree && pIdx) );
|
||||
|
||||
109
test/tkt-b1d3a2e531.test
Normal file
109
test/tkt-b1d3a2e531.test
Normal file
@@ -0,0 +1,109 @@
|
||||
# 2011 August 22
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# This file implements tests for foreign keys. Specifically, it tests
|
||||
# that ticket b1d3a2e531 has been fixed.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
ifcapable {!foreignkey||!trigger} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
set testprefix tkt-b1d3a2e531
|
||||
|
||||
do_execsql_test 1.0 { PRAGMA foreign_keys = ON }
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
CREATE TABLE pp(x PRIMARY KEY);
|
||||
CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
|
||||
INSERT INTO pp VALUES('abc');
|
||||
INSERT INTO cc VALUES('abc');
|
||||
}
|
||||
do_execsql_test 1.2 {
|
||||
BEGIN;
|
||||
DROP TABLE pp;
|
||||
DROP TABLE cc;
|
||||
COMMIT;
|
||||
}
|
||||
do_execsql_test 1.3 {
|
||||
CREATE TABLE pp(x PRIMARY KEY);
|
||||
CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
|
||||
INSERT INTO pp VALUES('abc');
|
||||
INSERT INTO cc VALUES('abc');
|
||||
}
|
||||
do_execsql_test 1.4 {
|
||||
BEGIN;
|
||||
DROP TABLE cc;
|
||||
DROP TABLE pp;
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
do_execsql_test 2.1 {
|
||||
CREATE TABLE pp(x PRIMARY KEY);
|
||||
CREATE TABLE cc(
|
||||
y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
INSERT INTO pp VALUES(5);
|
||||
INSERT INTO cc VALUES(5);
|
||||
}
|
||||
do_execsql_test 2.2 {
|
||||
BEGIN;
|
||||
DROP TABLE pp;
|
||||
DROP TABLE cc;
|
||||
COMMIT;
|
||||
}
|
||||
do_execsql_test 2.3 {
|
||||
CREATE TABLE pp(x PRIMARY KEY);
|
||||
CREATE TABLE cc(
|
||||
y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
INSERT INTO pp VALUES(5);
|
||||
INSERT INTO cc VALUES(5);
|
||||
}
|
||||
do_execsql_test 2.4 {
|
||||
BEGIN;
|
||||
DROP TABLE cc;
|
||||
DROP TABLE pp;
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
do_execsql_test 3.1 {
|
||||
CREATE TABLE pp1(x PRIMARY KEY);
|
||||
CREATE TABLE cc1(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
|
||||
|
||||
CREATE TABLE pp2(x PRIMARY KEY);
|
||||
CREATE TABLE cc2(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
|
||||
|
||||
INSERT INTO pp1 VALUES(2200);
|
||||
INSERT INTO cc1 VALUES(NULL);
|
||||
|
||||
INSERT INTO pp2 VALUES(2200);
|
||||
INSERT INTO cc2 VALUES(2200);
|
||||
}
|
||||
do_catchsql_test 3.2 {
|
||||
BEGIN;
|
||||
DELETE FROM pp2;
|
||||
DROP TABLE pp1;
|
||||
DROP TABLE cc1;
|
||||
COMMIT;
|
||||
} {1 {foreign key constraint failed}}
|
||||
do_catchsql_test 3.3 {
|
||||
DROP TABLE cc2;
|
||||
COMMIT;
|
||||
} {0 {}}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
Reference in New Issue
Block a user