]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Reduce the size of the VdbeCursor object by a pointer (the pBt pointer used
authordrh <drh@noemail.net>
Thu, 17 Dec 2015 17:30:53 +0000 (17:30 +0000)
committerdrh <drh@noemail.net>
Thu, 17 Dec 2015 17:30:53 +0000 (17:30 +0000)
for ephemeral tables).

FossilOrigin-Name: 98b710c36343fc213c8223f353907934be60b60d

manifest
manifest.uuid
src/btree.c
src/btree.h
src/vdbe.c
src/vdbeInt.h
src/vdbeaux.c
src/vdbesort.c

index 799ac619df5dcf1f68132335d9ad3f954646c7af..db1dc9a1b1e87ac2f8feb8ee115168e271908486 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sspellfix1_scriptcode()\sfunction\sto\signore\swhitespace\sand\spunctuation,\nand\sto\srecognize\shebrew\sand\sarabic\sscripts.
-D 2015-12-17T14:18:21.904
+C Reduce\sthe\ssize\sof\sthe\sVdbeCursor\sobject\sby\sa\spointer\s(the\spBt\spointer\sused\nfor\sephemeral\stables).
+D 2015-12-17T17:30:53.420
 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751
@@ -276,8 +276,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc
 F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf
 F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
-F src/btree.c 84ede51e371a11c3dbb3e24ccc5e3e99594a6c00
-F src/btree.h 2d76dee44704c47eed323356a758662724b674a0
+F src/btree.c cb0ed74a8212a7b31fb967a162658f490a302a18
+F src/btree.h 778f36cd143dae941e8b8d0cbc7b0f43ba35dfef
 F src/btreeInt.h 3ab435ed27adea54d040584b0bcc488ee7db1e38
 F src/build.c e83da4d004a4e050c01acbb821ff7a7b1019c29b
 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
@@ -398,14 +398,14 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3
 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
 F src/util.c e802e8e311a0d6c48cd1b3e89db164f6f0248d70
 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701
-F src/vdbe.c 984c2be6691d3f67deb2e6747c2132150d776f32
+F src/vdbe.c 1879236383d730d99abb825d14b9c06ecfec931d
 F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637
-F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d
+F src/vdbeInt.h 6c879b499dc98dbc0ec5edb92a210fdcc979b919
 F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca
-F src/vdbeaux.c 68082d9991fc1b8625d34c8b5db1775c9dee426e
+F src/vdbeaux.c 7b2db8d1b5042920f9c775b4c0bf23f50b2f5f9d
 F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15
 F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045
-F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d
+F src/vdbesort.c 90a3545ed856e1007c77ca3ac4f9c1975a64ed23
 F src/vdbetrace.c 8befe829faff6d9e6f6e4dee5a7d3f85cc85f1a0
 F src/vtab.c 2a8b44aa372c33f6154208e7a7f6c44254549806
 F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb
@@ -1405,7 +1405,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 85ebd46c701e0a094a4690cd8f1d0cbae9aa257c
-R 70cdc580d7d9b92b032d33f5e0d50f2e
+P 7adfa4a5794e47f97491c08abeaaac90e826b331
+R a16632c6e8507cdeda30edf695604402
+T *branch * optimize-vdbecursor
+T *sym-optimize-vdbecursor *
+T -sym-trunk *
 U drh
-Z 6d4b5ed9cd1870281d7d851922f323d8
+Z 6d89310e965f290e1d3a90698ce47a16
index eebc618153485980aafd38a08d432ec8139d625e..f6f0fb0bc485766405e8ee12bc57b92a21734bd7 100644 (file)
@@ -1 +1 @@
-7adfa4a5794e47f97491c08abeaaac90e826b331
\ No newline at end of file
+98b710c36343fc213c8223f353907934be60b60d
\ No newline at end of file
index 4e384e2c4fa80128819d0dcd6095337ec993aa2e..3d53e56ab4213fdfb934e2e4a5108d0db46c01af 100644 (file)
@@ -4182,6 +4182,14 @@ void sqlite3BtreeCursorZero(BtCursor *p){
   memset(p, 0, offsetof(BtCursor, iPage));
 }
 
+/*
+** Return the Btree object associated with a BtCursor.
+*/
+Btree *sqlite3BtreeOfCursor(BtCursor *p){
+  assert( p!=0 );
+  return p->pBtree;
+}
+
 /*
 ** Close a cursor.  The read lock on the database file is released
 ** when the last cursor is closed.
index 09b713f3dbdc4171f366c317e621caf2d5a86508..7b46bc86bc186201fc6bc011554f8a8d16779164 100644 (file)
@@ -221,6 +221,7 @@ int sqlite3BtreeCursor(
 int sqlite3BtreeCursorSize(void);
 void sqlite3BtreeCursorZero(BtCursor*);
 void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
+Btree *sqlite3BtreeOfCursor(BtCursor*);
 #ifdef SQLITE_ENABLE_CURSOR_HINTS
 void sqlite3BtreeCursorHint(BtCursor*, int, ...);
 #endif
index 894758a01c266ed5ba762edc2d9e33e79e7c0d14..b234a387f2d2c35761c74bfb6de0cadc4df325e3 100644 (file)
@@ -3441,6 +3441,7 @@ case OP_OpenAutoindex:
 case OP_OpenEphemeral: {
   VdbeCursor *pCx;
   KeyInfo *pKeyInfo;
+  Btree *pBt;
 
   static const int vfsFlags = 
       SQLITE_OPEN_READWRITE |
@@ -3453,35 +3454,39 @@ case OP_OpenEphemeral: {
   pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
   if( pCx==0 ) goto no_mem;
   pCx->nullRow = 1;
-  pCx->isEphemeral = 1;
-  rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBt, 
+  rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 
                         BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
   if( rc==SQLITE_OK ){
-    rc = sqlite3BtreeBeginTrans(pCx->pBt, 1);
-  }
-  if( rc==SQLITE_OK ){
-    /* If a transient index is required, create it by calling
-    ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
-    ** opening it. If a transient table is required, just use the
-    ** automatically created table with root-page 1 (an BLOB_INTKEY table).
-    */
-    if( (pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
-      int pgno;
-      assert( pOp->p4type==P4_KEYINFO );
-      rc = sqlite3BtreeCreateTable(pCx->pBt, &pgno, BTREE_BLOBKEY | pOp->p5); 
-      if( rc==SQLITE_OK ){
-        assert( pgno==MASTER_ROOT+1 );
-        assert( pKeyInfo->db==db );
-        assert( pKeyInfo->enc==ENC(db) );
-        pCx->pKeyInfo = pKeyInfo;
-        rc = sqlite3BtreeCursor(pCx->pBt, pgno, BTREE_WRCSR,
-                                pKeyInfo, pCx->uc.pCursor);
+    rc = sqlite3BtreeBeginTrans(pBt, 1);
+    if( rc==SQLITE_OK ){
+      /* If a transient index is required, create it by calling
+      ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
+      ** opening it. If a transient table is required, just use the
+      ** automatically created table with root-page 1 (an BLOB_INTKEY table).
+      */
+      if( (pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
+        int pgno;
+        assert( pOp->p4type==P4_KEYINFO );
+        rc = sqlite3BtreeCreateTable(pBt, &pgno, BTREE_BLOBKEY | pOp->p5); 
+        if( rc==SQLITE_OK ){
+          assert( pgno==MASTER_ROOT+1 );
+          assert( pKeyInfo->db==db );
+          assert( pKeyInfo->enc==ENC(db) );
+          pCx->pKeyInfo = pKeyInfo;
+          rc = sqlite3BtreeCursor(pBt, pgno, BTREE_WRCSR,
+                                  pKeyInfo, pCx->uc.pCursor);
+        }
+        pCx->isTable = 0;
+      }else{
+        rc = sqlite3BtreeCursor(pBt, MASTER_ROOT, BTREE_WRCSR,
+                                0, pCx->uc.pCursor);
+        pCx->isTable = 1;
       }
-      pCx->isTable = 0;
+    }
+    if( rc==SQLITE_OK ){
+      pCx->isEphemeral = 1;
     }else{
-      rc = sqlite3BtreeCursor(pCx->pBt, MASTER_ROOT, BTREE_WRCSR,
-                              0, pCx->uc.pCursor);
-      pCx->isTable = 1;
+      sqlite3BtreeClose(pBt);
     }
   }
   pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
index d1de55eb1c61e61b9e46ec9e6a97fe8aa153e853..6d6426156f6952eca28509ab67aba435cf3765ef 100644 (file)
@@ -95,7 +95,6 @@ struct VdbeCursor {
     int pseudoTableReg;         /* CURTYPE_PSEUDO. Reg holding content. */
     VdbeSorter *pSorter;        /* CURTYPE_SORTER. Sorter object */
   } uc;
-  Btree *pBt;           /* Separate file holding temporary table */
   KeyInfo *pKeyInfo;    /* Info about index keys needed by index cursors */
   int seekResult;       /* Result of previous sqlite3BtreeMoveto() */
   i64 seqCount;         /* Sequence counter */
index a266177ac561c79819640b4f3d0b7e8583905480..7a52bca19d4abc5ecefb29d3c078871530c8fabe 100644 (file)
@@ -1925,19 +1925,19 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
   if( pCx==0 ){
     return;
   }
-  assert( pCx->pBt==0 || pCx->eCurType==CURTYPE_BTREE );
+  assert( pCx->isEphemeral==0 || pCx->eCurType==CURTYPE_BTREE );
   switch( pCx->eCurType ){
     case CURTYPE_SORTER: {
       sqlite3VdbeSorterClose(p->db, pCx);
       break;
     }
     case CURTYPE_BTREE: {
-      if( pCx->pBt ){
-        sqlite3BtreeClose(pCx->pBt);
+      assert( pCx->uc.pCursor!=0 );
+      if( pCx->isEphemeral ){
+        sqlite3BtreeClose(sqlite3BtreeOfCursor(pCx->uc.pCursor));
         /* The pCx->pCursor will be close automatically, if it exists, by
         ** the call above. */
       }else{
-        assert( pCx->uc.pCursor!=0 );
         sqlite3BtreeCloseCursor(pCx->uc.pCursor);
       }
       break;
index 54e538fd50fda188d6d927311e486eaacf1ed25c..40e7454da0cc7cbcd8203facd27b1eaeb5f212fe 100644 (file)
@@ -960,7 +960,7 @@ int sqlite3VdbeSorterInit(
   }
 #endif
 
-  assert( pCsr->pKeyInfo && pCsr->pBt==0 );
+  assert( pCsr->pKeyInfo && !pCsr->isEphemeral );
   assert( pCsr->eCurType==CURTYPE_SORTER );
   szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nField-1)*sizeof(CollSeq*);
   sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);