mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Fix some foreign key constraint related problems that occur when a row refers to itself.
FossilOrigin-Name: 9e503e2d0428c9e8df878c7c6594790232cca4e0
This commit is contained in:
@@ -445,17 +445,19 @@ void sqlite3Update(
|
||||
aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);
|
||||
|
||||
/* Do FK constraint checks. */
|
||||
sqlite3FkCheck(pParse, pTab, pChanges, regOldRowid, regNewRowid);
|
||||
sqlite3FkCheck(pParse, pTab, pChanges, regOldRowid, 0);
|
||||
|
||||
/* Delete the index entries associated with the current record. */
|
||||
j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);
|
||||
sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);
|
||||
|
||||
/* If changing the record number, delete the old record. */
|
||||
if( chngRowid ){
|
||||
if( hasFK || chngRowid ){
|
||||
sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);
|
||||
}
|
||||
sqlite3VdbeJumpHere(v, j1);
|
||||
|
||||
sqlite3FkCheck(pParse, pTab, pChanges, 0, regNewRowid);
|
||||
|
||||
/* Insert the new index entries and the new record. */
|
||||
sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user