]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved presentation on the new code that prevents unnecessary writes to
authordrh <drh@noemail.net>
Sun, 16 Sep 2018 15:01:25 +0000 (15:01 +0000)
committerdrh <drh@noemail.net>
Sun, 16 Sep 2018 15:01:25 +0000 (15:01 +0000)
expressions on indexes during an UPDATE when the expression does not reference
any of the columns that are changing.

FossilOrigin-Name: c9f045295c4577752b0847ff2027b44661e6cb15bb08b942ccb3a0ef396f3dec

manifest
manifest.uuid
src/update.c

index 440891880d743958884a67929c82a3c6023674fb..8eb0bd6afc3bd2b726a6c170a688585743e7c439 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Increase\sthe\sversion\snumber\sto\s3.26.0\sas\swe\sstart\sthe\snext\sdevelopment\scycle.
-D 2018-09-15T21:43:14.220
+C Improved\spresentation\son\sthe\snew\scode\sthat\sprevents\sunnecessary\swrites\sto\nexpressions\son\sindexes\sduring\san\sUPDATE\swhen\sthe\sexpression\sdoes\snot\sreference\nany\sof\sthe\scolumns\sthat\sare\schanging.
+D 2018-09-16T15:01:25.994
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 6b650013511fd9d8b094203ac268af9220d292cc7d4e1bc9fbca15aacd8c7995
@@ -567,7 +567,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
 F src/tokenize.c 9f55961518f77793edd56eee860ecf035d4370ebbb0726ad2f6cada6637fd16b
 F src/treeview.c e7a7f90552bb418533cdd0309b5eb71d4effa50165b880fc8c2001e613577e5f
 F src/trigger.c d3d78568f37fb2e6cdcc2d1e7b60156f15b0b600adec55b83c5d42f6cad250bd
-F src/update.c deb215e3532be46e1e2b6aa38ed9e3eb96e42ebc4cbe7a498cd365788220a432
+F src/update.c 74feccd67570dcb731b6b6ee9960710a5e8a59c8403f2fa88f5eb82dbb8e36fa
 F src/upsert.c 0dd81b40206841814d46942a7337786932475f085716042d0cb2fc7791bf8ca4
 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
 F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
@@ -1765,7 +1765,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 a71b101635ed28a4c99734dabb20bd65ef1018c1d63ac143b7321cdb0fafa5d7
-R f789e4a5b00a14bd183ffb1db488fa1d
+P 885f0f8252aae776a86c64bcc7da582f0ed58f2caae8ebff810a83ca339da820
+R 1d15143421504697e5d8ab90a5ba9295
 U drh
-Z 95fb510f742b1570e7d262774a3b689f
+Z 8e73db792f1c5d12613e11c54c1867c6
index f6f159f71e6a9ee44eb86aede70a104235c28d05..ee1b06ef03e124ee8d1b159c9532ef816adcdcb2 100644 (file)
@@ -1 +1 @@
-885f0f8252aae776a86c64bcc7da582f0ed58f2caae8ebff810a83ca339da820
\ No newline at end of file
+c9f045295c4577752b0847ff2027b44661e6cb15bb08b942ccb3a0ef396f3dec
\ No newline at end of file
index c9ec95bb65ac682ce69429c72850407461de663e..2e14f161e0e920f8a7c5336c8fe6c4fa1530329d 100644 (file)
@@ -84,18 +84,22 @@ void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
 ** columns defined by aXRef and chngRowid.  Return true if it does
 ** and false if not.
 **
-** The iCol-th column of pIdx will be an expression.
-**
 ** aXRef[j] will be non-negative if column j of the original table is
 ** being updated.  chngRowid will be true if the rowid of the table is
 ** being updated.
 */
-static int indexExprRefsUpdatedColumn(
-  Index *pIdx,      /* The index containing the expression to analyze */
-  int iCol,         /* Which column of the index is the expression */
+static int indexColumnIsBeingUpdated(
+  Index *pIdx,      /* The index to check */
+  int iCol,         /* Which column of the index to check */
   int *aXRef,       /* aXRef[j]>=0 if column j is being updated */
   int chngRowid     /* true if the rowid is being updated */
 ){
+  i16 iIdxCol = pIdx->aiColumn[iCol];
+  if( iIdxCol>=0 ){
+    return aXRef[iIdxCol]>=0;
+  }
+  if( iIdxCol==XN_ROWID ) return 1;
+  assert( iIdxCol==XN_EXPR );
   assert( pIdx->aColExpr!=0 );
   assert( pIdx->aColExpr->a[iCol].pExpr!=0 );
   return sqlite3ExprReferencesUpdatedColumn(pIdx->aColExpr->a[iCol].pExpr,
@@ -334,12 +338,7 @@ void sqlite3Update(
     }else{
       reg = 0;
       for(i=0; i<pIdx->nKeyCol; i++){
-        i16 iIdxCol = pIdx->aiColumn[i];
-        if( (iIdxCol>=0 && aXRef[iIdxCol]>=0)
-         || iIdxCol==XN_ROWID
-         || (iIdxCol==XN_EXPR
-             && indexExprRefsUpdatedColumn(pIdx,i,aXRef,chngRowid))
-        ){
+        if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
           reg = ++pParse->nMem;
           pParse->nMem += pIdx->nColumn;
           if( (onError==OE_Replace)