aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-01-04 22:02:56 +0000
committerdrh <drh@noemail.net>2017-01-04 22:02:56 +0000
commit801f55d837dc353f9bb0b4031849d2538cd56b3f (patch)
treefd4215ec9d07cdadd7ff7997e8ba669be494ed10 /src/insert.c
parent4e1f0efb4de9a6bb53b0979d9a5b700a77253277 (diff)
downloadsqlite-801f55d837dc353f9bb0b4031849d2538cd56b3f.tar.gz
sqlite-801f55d837dc353f9bb0b4031849d2538cd56b3f.zip
Improved the comment on the block of code the provides the performance
optimization originally added by check-in [925840cfdb]. The original check-in omitted condition 4, which was the cause of bug [30027b613b]. FossilOrigin-Name: c6506b82aa6583ccde5f673c79526d5f3920b67a
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/insert.c b/src/insert.c
index 2cc0457a9..bd6efe68b 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -1549,16 +1549,22 @@ void sqlite3GenerateConstraintChecks(
onError = OE_Abort;
}
- if( ix==0 && pPk==pIdx && onError==OE_Replace && pPk->pNext==0 ){
- if( 0==(db->flags&SQLITE_RecTriggers)
- || 0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0)
- ){
- sqlite3VdbeResolveLabel(v, addrUniqueOk);
- continue;
- }
+ /* Collision detection may be omitted if all of the following are true:
+ ** (1) The conflict resolution algorithm is REPLACE
+ ** (2) The table is a WITHOUT ROWID table
+ ** (3) There are no secondary indexes on the table
+ ** (4) No delete triggers need to be fired if there is a conflict
+ */
+ if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
+ && pPk==pIdx /* Condition 2 */
+ && onError==OE_Replace /* Condition 1 */
+ && ( 0==(db->flags&SQLITE_RecTriggers) || /* Condition 4 */
+ 0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
+ ){
+ sqlite3VdbeResolveLabel(v, addrUniqueOk);
+ continue;
}
-
/* Check to see if the new index entry will be unique */
sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
regIdx, pIdx->nKeyCol); VdbeCoverage(v);