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:
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) );
|
||||
|
||||
Reference in New Issue
Block a user