From 801f55d837dc353f9bb0b4031849d2538cd56b3f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 4 Jan 2017 22:02:56 +0000 Subject: [PATCH] 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 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/insert.c | 22 ++++++++++++++-------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index a9b1e4263e..c942787502 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Possible\sfix\sfor\s30027b61.\sThere\smay\sstill\sbe\sproblems\ssurrounding\sforeign\skey\nprocessing. -D 2017-01-04T20:13:51.856 +C Improved\sthe\scomment\son\sthe\sblock\sof\scode\sthe\sprovides\sthe\sperformance\noptimization\soriginally\sadded\sby\scheck-in\s[925840cfdb].\s\sThe\soriginal\ncheck-in\somitted\scondition\s4,\swhich\swas\sthe\scause\sof\sbug\s[30027b613b]. +D 2017-01-04T22:02:56.715 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -350,7 +350,7 @@ F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 1e0c2b61265518a31929a10ca28102a7911d2e69 +F src/insert.c 895995aca4c6de8118d405c6c2d5fa7fd05bdb58 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0 @@ -1542,10 +1542,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8d670973595bd01ffc9b2ab53b965e6d6d22c573 -R 18f979ea5ceac35d70bae9aad4eb77f0 -T *branch * replace-fix -T *sym-replace-fix * -T -sym-trunk * -U dan -Z a4497840837bb26a5ad3bdf1e588e388 +P 71ccb1f4c490fdebc7008e884384e7809b849742 +R c29c3a3cb5ccbc5f6d29ccf66ed137b5 +U drh +Z 68ffb3e06be0aa51c5e3b069bb78bd06 diff --git a/manifest.uuid b/manifest.uuid index 56c42e692c..a921fd8581 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71ccb1f4c490fdebc7008e884384e7809b849742 \ No newline at end of file +c6506b82aa6583ccde5f673c79526d5f3920b67a \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 2cc0457a99..bd6efe68b4 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);