]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove unnecessary OP_Close opcodes for a size reduction and performance
authordrh <drh@noemail.net>
Tue, 22 Nov 2016 01:26:42 +0000 (01:26 +0000)
committerdrh <drh@noemail.net>
Tue, 22 Nov 2016 01:26:42 +0000 (01:26 +0000)
increase.

FossilOrigin-Name: 32be7aae92ee48bf2cd260ea41e79c2bc62738f9

manifest
manifest.uuid
src/btree.c
src/delete.c
src/update.c
src/vdbeblob.c
src/where.c

index cf92f6bee8726d24ae3336016814295b90a22a48..12324450aeb79805ed778b74eb1b0b814cc73111 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sunnecessary\sOP_Close\sopcodes\sat\sthe\send\sof\sINSERT\soperations,\sresulting\nin\ssmaller\sand\sfaster\scode.
-D 2016-11-21T21:33:46.646
+C Remove\sunnecessary\sOP_Close\sopcodes\sfor\sa\ssize\sreduction\sand\sperformance\nincrease.
+D 2016-11-22T01:26:42.349
 F Makefile.in 6b572807415d3f0a379cebc9461416d8df4a12c8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc bb4d970894abbbe0e88d00aac29bd52af8bc95f4
@@ -330,7 +330,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792
 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63
 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
-F src/btree.c a7ed407f879be72c94b81f965d552e51b54a971f
+F src/btree.c 090a13ac2a11bff2fcd30763a7347af998cf468f
 F src/btree.h 01ec45846fa177e929f01ee36a8e34337d653544
 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
 F src/build.c 178f16698cbcb43402c343a9413fe22c99ffee21
@@ -339,7 +339,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
 F src/ctime.c a2a52d6e353f459d8ab0f07321f60fafa47d5421
 F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b
 F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
-F src/delete.c 6cac3a6c3f3c5ad4cacc402aee1610fc94ebc3dc
+F src/delete.c 99949851e8e9ea4e1db739b0d354d360e1f80f2b
 F src/expr.c d8c8277d77e95d7fcce3b6b6d0f66652e482567f
 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
 F src/fkey.c b9ca262f6ad4d030a3cab737ebf9b0b3c8b4ac80
@@ -450,7 +450,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
 F src/tokenize.c 78c8085bc7af1922aa687f0f4bbd716821330de5
 F src/treeview.c 4e44ade3bfe59d82005039f72e09333ce2b4162c
 F src/trigger.c 3419bb9862983d84d70735fb4c94b21b934cd0c5
-F src/update.c bb9854778bdbbbca55d7533e55058733bd3fefe3
+F src/update.c 68714ed42a506d782a3d75ff8f09640706d6a3b2
 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
 F src/util.c 3e2da6101888d073e79ecc6af5e0a2f70fa1e498
 F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
@@ -459,7 +459,7 @@ F src/vdbe.h c044be7050ac6bf596eecc6ab159f5dbc020a3b7
 F src/vdbeInt.h 29b25318a0286c4b2599c0fbef6acf524398489a
 F src/vdbeapi.c 97129bec6b1553da50d8e73f523c278bda66d9f6
 F src/vdbeaux.c 52d9b840859f260ce8418be9333dd77c902e1c74
-F src/vdbeblob.c 3e82a797b60c3b9fed7b8de8c539ca7607874937
+F src/vdbeblob.c ba5b57b9fa47b320ad5c46468e77d8660c931190
 F src/vdbemem.c fcdd73a2001a673f48a244a77b1038928ae729c9
 F src/vdbesort.c 91fda3909326860382b0ca8aa251e609c6a9d62c
 F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
@@ -468,7 +468,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c 7e8557314bcf867ffe3fff1d8ef2d207ace8e065
 F src/wal.h bf03a23da3100ab25e5c0363450233cfee09cfc2
 F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0
-F src/where.c 952f76e7a03727480b274b66ca6641b1657cd591
+F src/where.c 6bbf9284f4f15a6fa48663d033870cc0d7f5ee66
 F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d
 F src/wherecode.c 4ea298998499db5a407ffd70e87e119a86ed7834
 F src/whereexpr.c c19a84ac530835d37217db2181e4fe75901b7b97
@@ -1534,7 +1534,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 9979ba80a649ee61d9d174dc9d9fcab7e9fc1332
-R 92d61cb2d5bdcee0374dbd9c4ae6bd21
+P abeddb6d5a4040e1d0a87a4f32ad79794ba0842b
+R 0b6428f20f271d9267866f8abeb28948
 U drh
-Z 31a59b2224bec36ffef21dc37a376954
+Z c9fbc8dd9eccb05e2261cb73023007c2
index 659aa4015df8d0afa455c863996715c33daaa3d0..aae65b2c2ffaa1cc5680ffadac9d7445527da153 100644 (file)
@@ -1 +1 @@
-abeddb6d5a4040e1d0a87a4f32ad79794ba0842b
\ No newline at end of file
+32be7aae92ee48bf2cd260ea41e79c2bc62738f9
\ No newline at end of file
index 895e8009edb2b9e774157230ccb84e864f10e96b..d4f0e067f06f3dee5f02a8ca3dd722d351ad2b0c 100644 (file)
@@ -8578,27 +8578,7 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
 
   assert( sqlite3BtreeHoldsMutex(p) );
   assert( p->inTrans==TRANS_WRITE );
-
-  /* It is illegal to drop a table if any cursors are open on the
-  ** database. This is because in auto-vacuum mode the backend may
-  ** need to move another root-page to fill a gap left by the deleted
-  ** root page. If an open cursor was using this page a problem would 
-  ** occur.
-  **
-  ** This error is caught long before control reaches this point.
-  */
-  if( NEVER(pBt->pCursor) ){
-    sqlite3ConnectionBlocked(p->db, pBt->pCursor->pBtree->db);
-    return SQLITE_LOCKED_SHAREDCACHE;
-  }
-
-  /*
-  ** It is illegal to drop the sqlite_master table on page 1.  But again,
-  ** this error is caught long before reaching this point.
-  */
-  if( NEVER(iTable<2) ){
-    return SQLITE_CORRUPT_BKPT;
-  }
+  assert( iTable>=2 );
 
   rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
   if( rc ) return rc;
index e16e9485b2101c8297da258d599fb97330ae773e..46af65a361fc10e24bcc092f6ff0cf746368dad9 100644 (file)
@@ -538,14 +538,6 @@ void sqlite3DeleteFrom(
       sqlite3VdbeGoto(v, addrLoop);
       sqlite3VdbeJumpHere(v, addrLoop);
     }     
-  
-    /* Close the cursors open on the table and its indexes. */
-    if( !isView && !IsVirtual(pTab) ){
-      if( !pPk ) sqlite3VdbeAddOp1(v, OP_Close, iDataCur);
-      for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
-        sqlite3VdbeAddOp1(v, OP_Close, iIdxCur + i);
-      }
-    }
   } /* End non-truncate path */
 
   /* Update the sqlite_sequence table by storing the content of the
index 6838c74398eeaf8c11aa59e87177639b51a107ae..b370a4ec1ad431363ab5505a63e2f5249199732b 100644 (file)
@@ -659,15 +659,6 @@ void sqlite3Update(
   }
   sqlite3VdbeResolveLabel(v, labelBreak);
 
-  /* Close all tables */
-  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
-    assert( aRegIdx );
-    if( aToOpen[i+1] ){
-      sqlite3VdbeAddOp2(v, OP_Close, iIdxCur+i, 0);
-    }
-  }
-  if( iDataCur<iIdxCur ) sqlite3VdbeAddOp2(v, OP_Close, iDataCur, 0);
-
   /* Update the sqlite_sequence table by storing the content of the
   ** maximum rowid counter values recorded while inserting into
   ** autoincrement tables.
index 570e253fdb9badc5e8ba8e408a8806b5443577e3..e4cf286865c80f79bc875ebc9bb6b5248716022b 100644 (file)
@@ -262,8 +262,7 @@ int sqlite3_blob_open(
         {OP_Column,         0, 0, 1},  /* 4  */
         {OP_ResultRow,      1, 0, 0},  /* 5  */
         {OP_Goto,           0, 2, 0},  /* 6  */
-        {OP_Close,          0, 0, 0},  /* 7  */
-        {OP_Halt,           0, 0, 0},  /* 8  */
+        {OP_Halt,           0, 0, 0},  /* 7  */
       };
       Vdbe *v = (Vdbe *)pBlob->pStmt;
       int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
index ddcb2fc8817a399078aa7c458977e47ab4fe1f76..81cc1f131b295df30a419855a815964f41f3b711 100644 (file)
@@ -4911,27 +4911,6 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
       continue;
     }
 
-    /* Close all of the cursors that were opened by sqlite3WhereBegin.
-    ** Except, do not close cursors that will be reused by the OR optimization
-    ** (WHERE_OR_SUBCLAUSE).  And do not close the OP_OpenWrite cursors
-    ** created for the ONEPASS optimization.
-    */
-    if( (pTab->tabFlags & TF_Ephemeral)==0
-     && pTab->pSelect==0
-     && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
-    ){
-      int ws = pLoop->wsFlags;
-      if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
-        sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
-      }
-      if( (ws & WHERE_INDEXED)!=0
-       && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 
-       && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]
-      ){
-        sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
-      }
-    }
-
     /* If this scan uses an index, make VDBE code substitutions to read data
     ** from the index instead of from the table where possible.  In some cases
     ** this optimization prevents the table from ever being read, which can