]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplifications and comment cleanup in vdbeaux.c. (CVS 6849)
authordrh <drh@noemail.net>
Mon, 6 Jul 2009 00:44:08 +0000 (00:44 +0000)
committerdrh <drh@noemail.net>
Mon, 6 Jul 2009 00:44:08 +0000 (00:44 +0000)
FossilOrigin-Name: 1636e7831a21d401a48aa74d884444a287f14f72

manifest
manifest.uuid
src/vdbeaux.c

index 983f2c002d49466277b9b9ca8d90842bbb1e92c8..acec4ddbc42e2b409fd4ebef8fe655e88241992f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sunreachable\scode\sfrom\sfunction\sbtreeCursor()\sin\sbtree.c.\s(CVS\s6848)
-D 2009-07-04T17:16:01
+C Simplifications\sand\scomment\scleanup\sin\svdbeaux.c.\s(CVS\s6849)
+D 2009-07-06T00:44:09
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -208,7 +208,7 @@ F src/vdbe.c bdf25930bddbf57b18a0be7b1127b357306d2094
 F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
 F src/vdbeInt.h 831c254a6eef237ef4664c8381a0137586567007
 F src/vdbeapi.c 0ab8ada7260b32031ca97f338caecf0812460624
-F src/vdbeaux.c 3773217a73f93fb292d264b3b1da98c179a0f2f0
+F src/vdbeaux.c f62c8c83e9f21e13df6acaace8851f1de17cadc0
 F src/vdbeblob.c a3f3e0e877fc64ea50165eec2855f5ada4477611
 F src/vdbemem.c 1618f685d19b4bcc96e40b3c478487bafd2ae246
 F src/vtab.c 00902f289521041712fb0293d0bf8688c7af8e48
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 133357d2f070ba303deddff59beead1ec8d10521
-R 59d54d3f3ef42572419a3b06be70cd73
-U danielk1977
-Z 270b59a313a8b2cb36f6d34f9f7ea02b
+P c76a366ed4dc63604ff695b3ee9c183e430a367e
+R ad4ffc2a251f0cb49d86125eb3a3f81a
+U drh
+Z 7f4c0366c55a62863a847bc059dca81a
index e4d09636f6e04f7d8121a58eb22def704eb24d1b..c585d951710900a654ea6f5e3f3a530c787c738d 100644 (file)
@@ -1 +1 @@
-c76a366ed4dc63604ff695b3ee9c183e430a367e
\ No newline at end of file
+1636e7831a21d401a48aa74d884444a287f14f72
\ No newline at end of file
index 455e725bf82cccdd8db0a7338ee0520efb5e1bbb..466b85043649d247bb7335e3f24426836fa72ccd 100644 (file)
@@ -14,7 +14,7 @@
 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
 ** But that file was getting too big so this subroutines were split out.
 **
-** $Id: vdbeaux.c,v 1.467 2009/06/26 16:32:13 shane Exp $
+** $Id: vdbeaux.c,v 1.468 2009/07/06 00:44:09 drh Exp $
 */
 #include "sqliteInt.h"
 #include "vdbeInt.h"
@@ -869,7 +869,7 @@ int sqlite3VdbeList(
   Mem *pMem = p->pResultSet = &p->aMem[1];
 
   assert( p->explain );
-  if( p->magic!=VDBE_MAGIC_RUN ) return SQLITE_MISUSE;
+  assert( p->magic==VDBE_MAGIC_RUN );
   assert( db->magic==SQLITE_MAGIC_BUSY );
   assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
 
@@ -1117,7 +1117,7 @@ void sqlite3VdbeMakeReady(
   ** first time this function is called for a given VDBE, not when it is
   ** being called from sqlite3_reset() to reset the virtual machine.
   */
-  if( nVar>=0 && !db->mallocFailed ){
+  if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
     u8 *zCsr = (u8 *)&p->aOp[p->nOp];
     u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
     int nByte;
@@ -1222,15 +1222,14 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
 }
 
 /*
-** Close all cursors except for VTab cursors that are currently
-** in use.
+** Close all cursors.
 */
-static void closeAllCursorsExceptActiveVtabs(Vdbe *p){
+static void closeAllCursors(Vdbe *p){
   int i;
   if( p->apCsr==0 ) return;
   for(i=0; i<p->nCursor; i++){
     VdbeCursor *pC = p->apCsr[i];
-    if( pC && (!p->inVtabMethod || !pC->pVtabCursor) ){
+    if( pC ){
       sqlite3VdbeFreeCursor(p, pC);
       p->apCsr[i] = 0;
     }
@@ -1248,7 +1247,7 @@ static void Cleanup(Vdbe *p){
   int i;
   sqlite3 *db = p->db;
   Mem *pMem;
-  closeAllCursorsExceptActiveVtabs(p);
+  closeAllCursors(p);
   for(pMem=&p->aMem[1], i=1; i<=p->nMem; i++, pMem++){
     if( pMem->flags & MEM_RowSet ){
       sqlite3RowSetClear(pMem->u.pRowSet);
@@ -1709,7 +1708,7 @@ int sqlite3VdbeHalt(Vdbe *p){
   if( p->db->mallocFailed ){
     p->rc = SQLITE_NOMEM;
   }
-  closeAllCursorsExceptActiveVtabs(p);
+  closeAllCursors(p);
   if( p->magic!=VDBE_MAGIC_RUN ){
     return SQLITE_OK;
   }
@@ -2633,8 +2632,8 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
     goto idx_rowid_corruption;
   }
   lenRowid = sqlite3VdbeSerialTypeLen(typeRowid);
-  testcase( m.n-lenRowid==szHdr );
-  if( unlikely(m.n-lenRowid<szHdr) ){
+  testcase( m.n==szHdr+lenRowid );
+  if( unlikely(m.n<szHdr+lenRowid) ){
     goto idx_rowid_corruption;
   }
 
@@ -2653,22 +2652,19 @@ idx_rowid_corruption:
 }
 
 /*
-** Compare the key of the index entry that cursor pC is point to against
-** the key string in pKey (of length nKey).  Write into *pRes a number
+** Compare the key of the index entry that cursor pC is pointing to against
+** the key string in pUnpacked.  Write into *pRes a number
 ** that is negative, zero, or positive if pC is less than, equal to,
-** or greater than pKey.  Return SQLITE_OK on success.
+** or greater than pUnpacked.  Return SQLITE_OK on success.
 **
-** pKey is either created without a rowid or is truncated so that it
+** pUnpacked is either created without a rowid or is truncated so that it
 ** omits the rowid at the end.  The rowid at the end of the index entry
 ** is ignored as well.  Hence, this routine only compares the prefixes 
 ** of the keys prior to the final rowid, not the entire key.
-**
-** pUnpacked may be an unpacked version of pKey,nKey.  If pUnpacked is
-** supplied it is used in place of pKey,nKey.
 */
 int sqlite3VdbeIdxKeyCompare(
   VdbeCursor *pC,             /* The cursor to compare against */
-  UnpackedRecord *pUnpacked,  /* Unpacked version of pKey and nKey */
+  UnpackedRecord *pUnpacked,  /* Unpacked version of key to compare against */
   int *res                    /* Write the comparison result here */
 ){
   i64 nCellKey = 0;