]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Minor changes (mainly to assert() macros) to handle malloc failure in vtab operations...
authordanielk1977 <danielk1977@noemail.net>
Wed, 18 Apr 2007 14:24:32 +0000 (14:24 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 18 Apr 2007 14:24:32 +0000 (14:24 +0000)
FossilOrigin-Name: 175156d1fcaadab3b955597abb27f6b9043bbb5b

manifest
manifest.uuid
src/insert.c
src/main.c
src/vdbeaux.c
src/vtab.c

index ac905cf0fe3c22daa64b417d05b39421d86ce0f4..8cea4299ad9a255fb534aedc1d298d7d22b86f58 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Bump\sthe\sversion\snumber\sand\supdate\sdocuments\sin\spreparation\sfor\s3.3.16.\s(CVS\s3850)
-D 2007-04-18T13:49:37
+C Minor\schanges\s(mainly\sto\sassert()\smacros)\sto\shandle\smalloc\sfailure\sin\svtab\soperations.\s(CVS\s3851)
+D 2007-04-18T14:24:33
 F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -70,10 +70,10 @@ F src/expr.c 2c32c546006627d70a7b941b318489980fd1912e
 F src/func.c 007d957c057bb42b0d37aa6ad4be0e1c67a8871b
 F src/hash.c 67b23e14f0257b69a3e8aa663e4eeadc1a2b6fd5
 F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
-F src/insert.c f3cd178575bd2a4b65a9a1313f391e1f78221ca3
+F src/insert.c 413cc06990cb3c401e64e596776c1e43934f8841
 F src/legacy.c 2631df6a861f830d6b1c0fe92b9fdd745b2c0cd6
 F src/loadext.c 146fb9b9dc6133e763888d710205c32ebf8eeca2
-F src/main.c a8f5c62b51e7581b814745aee6fef03f8641119f
+F src/main.c e6eb036c3580ba9116fedfe4a8b58ed63d5abb37
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
 F src/os.c 4650e98aadd27abfe1698ff58edf6893c58d4881
 F src/os.h 9240adf088fd55732f8926f9017601ba3430ead8
@@ -128,10 +128,10 @@ F src/vdbe.c cf7808e8db2e5d1547e898ce29531295183ede6e
 F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
 F src/vdbeInt.h 4b19fd8febad3fd14c4c97adaefc06754d323132
 F src/vdbeapi.c 1fca7ff056d03f131caa6b1296bb221da65ed7f4
-F src/vdbeaux.c 0bae26de1ba1683de80c89ba1d4081b4c809d05b
+F src/vdbeaux.c ef59545f53f90394283f2fd003375d3ebbf0bd6e
 F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
 F src/vdbemem.c 981a113405bd9b80aeb71fe246a2f01708e8a8f7
-F src/vtab.c ff222fb87e1215d9a89a357ec985e8523760346f
+F src/vtab.c 24d7b1507a744f3f06b279a874f353548d798f34
 F src/where.c fce0dad6b230eb7ea844e8b8667c074d07e3fdd5
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -459,7 +459,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 61c1d06d10257575e1406303af331bcc4d00deb0
-R bf90195564c15e01a18b297640d49724
-U drh
-Z b3a0f38e60351f7b4cfe8a1f9c0ba5b3
+P 852100a332d9f602e5f6285d2b7e19a3060c6162
+R 2c5025bb9e89555298dde4c0e521837d
+U danielk1977
+Z a40be68094d24301cad1702ed45b3e42
index 8dd86dca9b0351ae07cc3dde96daec8bcee40122..2afe03d58e8a3bc04d58c78b2ab180749cdc6f15 100644 (file)
@@ -1 +1 @@
-852100a332d9f602e5f6285d2b7e19a3060c6162
\ No newline at end of file
+175156d1fcaadab3b955597abb27f6b9043bbb5b
\ No newline at end of file
index e1864ad92920c64e8c8cc28013b882887d788a63..2bb70fc0ce9fcb90e0731000910a8df5ae49e0f5 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle INSERT statements in SQLite.
 **
-** $Id: insert.c,v 1.184 2007/04/10 18:17:55 drh Exp $
+** $Id: insert.c,v 1.185 2007/04/18 14:24:33 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -705,7 +705,7 @@ void sqlite3Insert(
         VdbeOp *pOp;
         sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr);
         pOp = sqlite3VdbeGetOp(v, sqlite3VdbeCurrentAddr(v) - 1);
-        if( pOp->opcode==OP_Null ){
+        if( pOp && pOp->opcode==OP_Null ){
           appendFlag = 1;
           pOp->opcode = OP_NewRowid;
           pOp->p1 = base;
index 12fd3e8c55149fc88935c71de7693134c610fe3b..b3f20ce1e2e071e96262431fd3e645ff4286a662 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.369 2007/04/16 15:06:25 danielk1977 Exp $
+** $Id: main.c,v 1.370 2007/04/18 14:24:33 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -129,6 +129,15 @@ int sqlite3_close(sqlite3 *db){
 
   sqlite3ResetInternalSchema(db, 0);
 
+  /* If a transaction is open, the ResetInternalSchema() call above
+  ** will not have called the xDisconnect() method on any virtual
+  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()
+  ** call will do so. We need to do this before the check for active
+  ** SQL statements below, as the v-table implementation may be storing
+  ** some prepared statements internally.
+  */
+  sqlite3VtabRollback(db);
+
   /* If there are any outstanding VMs, return SQLITE_BUSY. */
   if( db->pVdbe ){
     sqlite3Error(db, SQLITE_BUSY, 
@@ -150,8 +159,6 @@ int sqlite3_close(sqlite3 *db){
     return SQLITE_ERROR;
   }
 
-  sqlite3VtabRollback(db);
-
   for(j=0; j<db->nDb; j++){
     struct Db *pDb = &db->aDb[j];
     if( pDb->pBt ){
index 064849a36a4ffaba45c7faf38ab27852f4687702..6c1af395a0671dd82c69528d992952153e17c213 100644 (file)
@@ -145,7 +145,6 @@ int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){
   VdbeOp *pOp;
 
   i = p->nOp;
-  p->nOp++;
   assert( p->magic==VDBE_MAGIC_INIT );
   if( p->nOpAlloc<=i ){
     resizeOpArray(p, i+1);
@@ -153,6 +152,7 @@ int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){
       return 0;
     }
   }
+  p->nOp++;
   pOp = &p->aOp[i];
   pOp->opcode = op;
   pOp->p1 = p1;
@@ -557,9 +557,8 @@ void sqlite3VdbeChangeP3(Vdbe *p, int addr, const char *zP3, int n){
 */
 void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){
   va_list ap;
-  assert( p->nOp>0 );
-  assert( p->aOp==0 || p->aOp[p->nOp-1].p3==0 
-          || sqlite3MallocFailed() );
+  assert( p->nOp>0 || p->aOp==0 );
+  assert( p->aOp==0 || p->aOp[p->nOp-1].p3==0 || sqlite3MallocFailed() );
   va_start(ap, zFormat);
   sqlite3VdbeChangeP3(p, -1, sqlite3VMPrintf(zFormat, ap), P3_DYNAMIC);
   va_end(ap);
@@ -571,8 +570,8 @@ void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){
 */
 VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
   assert( p->magic==VDBE_MAGIC_INIT );
-  assert( addr>=0 && addr<p->nOp );
-  return &p->aOp[addr];
+  assert( (addr>=0 && addr<p->nOp) || sqlite3MallocFailed() );
+  return ((addr>=0 && addr<p->nOp)?(&p->aOp[addr]):0);
 }
 
 #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \
index 3448d2abf5b834300eeb6d4412bbe43622519dde..c314e146a0e106c82a0ebe45432f1ff48a3ad429 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to help implement virtual tables.
 **
-** $Id: vtab.c,v 1.41 2007/04/16 15:49:41 danielk1977 Exp $
+** $Id: vtab.c,v 1.42 2007/04/18 14:24:34 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_VIRTUALTABLE
 #include "sqliteInt.h"
@@ -311,6 +311,10 @@ static int vtabCallConstructor(
   char *zErr = 0;
   char *zModuleName = sqlite3MPrintf("%s", pTab->zName);
 
+  if( !zModuleName ){
+    return SQLITE_NOMEM;
+  }
+
   assert( !db->pVTab );
   assert( xConstruct );
 
@@ -471,6 +475,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
     pTab->nCol = sParse.pNewTable->nCol;
     sParse.pNewTable->nCol = 0;
     sParse.pNewTable->aCol = 0;
+    db->pVTab = 0;
   } else {
     sqlite3Error(db, SQLITE_ERROR, zErr);
     sqliteFree(zErr);
@@ -481,10 +486,9 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
   sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe);
   sqlite3DeleteTable(sParse.pNewTable);
   sParse.pNewTable = 0;
-  db->pVTab = 0;
 
   assert( (rc&0xff)==rc );
-  return rc;
+  return sqlite3ApiExit(db, rc);
 }
 
 /*