aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/insert.c b/src/insert.c
index adf6ef2ed..98f00bfe3 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -1287,9 +1287,17 @@ void sqlite3GenerateConstraintChecks(
sqlite3GenerateRowDelete(
pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
);
- }else if( pTab->pIndex ){
- sqlite3MultiWrite(pParse);
- sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
+ }else{
+ /* This OP_Delete opcode fires the pre-update-hook only. It does
+ ** not modify the b-tree. It is more efficient to let the coming
+ ** OP_Insert replace the existing entry than it is to delete the
+ ** existing entry and then insert a new one. */
+ sqlite3VdbeAddOp2(v, OP_Delete, baseCur, OPFLAG_ISNOOP);
+ sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
+ if( pTab->pIndex ){
+ sqlite3MultiWrite(pParse);
+ sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
+ }
}
seenReplace = 1;
break;