diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analyze.c | 6 | ||||
-rw-r--r-- | src/attach.c | 6 | ||||
-rw-r--r-- | src/main.c | 51 | ||||
-rw-r--r-- | src/os.c | 6 | ||||
-rw-r--r-- | src/prepare.c | 19 | ||||
-rw-r--r-- | src/sqliteInt.h | 18 | ||||
-rw-r--r-- | src/test_devsym.c | 1 | ||||
-rw-r--r-- | src/util.c | 35 | ||||
-rw-r--r-- | src/vdbe.c | 12 | ||||
-rw-r--r-- | src/vdbeapi.c | 10 | ||||
-rw-r--r-- | src/vdbeaux.c | 12 | ||||
-rw-r--r-- | src/vdbeblob.c | 8 | ||||
-rw-r--r-- | src/vtab.c | 10 | ||||
-rw-r--r-- | src/where.c | 8 |
14 files changed, 107 insertions, 95 deletions
diff --git a/src/analyze.c b/src/analyze.c index b7e917fb6..7fd616265 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code associated with the ANALYZE command. ** -** @(#) $Id: analyze.c,v 1.39 2008/01/17 02:36:28 drh Exp $ +** @(#) $Id: analyze.c,v 1.40 2008/01/23 03:03:05 drh Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" @@ -414,9 +414,9 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ /* Load new statistics out of the sqlite_stat1 table */ zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); sqlite3_free(zSql); return rc; } diff --git a/src/attach.c b/src/attach.c index af2312c8a..63ad3c7b7 100644 --- a/src/attach.c +++ b/src/attach.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.69 2008/01/17 16:22:15 drh Exp $ +** $Id: attach.c,v 1.70 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" @@ -186,11 +186,11 @@ static void attachFunc( ** we found it. */ if( rc==SQLITE_OK ){ - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); sqlite3BtreeEnterAll(db); rc = sqlite3Init(db, &zErrDyn); sqlite3BtreeLeaveAll(db); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); } if( rc ){ int iDb = db->nDb - 1; diff --git a/src/main.c b/src/main.c index 7fa01c2e8..2d9d2ca86 100644 --- a/src/main.c +++ b/src/main.c @@ -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.412 2008/01/22 21:30:53 drh Exp $ +** $Id: main.c,v 1.413 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -134,7 +134,7 @@ int sqlite3_close(sqlite3 *db){ if( !db ){ return SQLITE_OK; } - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -164,21 +164,7 @@ int sqlite3_close(sqlite3 *db){ sqlite3_mutex_leave(db->mutex); return SQLITE_BUSY; } - assert( !sqlite3SafetyCheck(db) ); - - /* FIX ME: db->magic may be set to SQLITE_MAGIC_CLOSED if the database - ** cannot be opened for some reason. So this routine needs to run in - ** that case. But maybe there should be an extra magic value for the - ** "failed to open" state. - ** - ** TODO: Coverage tests do not test the case where this condition is - ** true. It's hard to see how to cause it without messing with threads. - */ - if( db->magic!=SQLITE_MAGIC_CLOSED && sqlite3SafetyOn(db) ){ - /* printf("DID NOT CLOSE\n"); fflush(stdout); */ - sqlite3_mutex_leave(db->mutex); - return SQLITE_ERROR; - } + assert( sqlite3SafetyCheckSickOrOk(db) ); for(j=0; j<db->nDb; j++){ struct Db *pDb = &db->aDb[j]; @@ -240,6 +226,7 @@ int sqlite3_close(sqlite3 *db){ */ sqlite3_free(db->aDb[1].pSchema); sqlite3_mutex_leave(db->mutex); + db->magic = SQLITE_MAGIC_CLOSED; sqlite3_mutex_free(db->mutex); sqlite3_free(db); return SQLITE_OK; @@ -387,7 +374,7 @@ int sqlite3_busy_handler( int (*xBusy)(void*,int), void *pArg ){ - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -410,7 +397,7 @@ void sqlite3_progress_handler( int (*xProgress)(void*), void *pArg ){ - if( !sqlite3SafetyCheck(db) ){ + if( sqlite3SafetyCheckOk(db) ){ sqlite3_mutex_enter(db->mutex); if( nOps>0 ){ db->xProgress = xProgress; @@ -432,7 +419,7 @@ void sqlite3_progress_handler( ** specified number of milliseconds before returning 0. */ int sqlite3_busy_timeout(sqlite3 *db, int ms){ - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } if( ms>0 ){ @@ -448,7 +435,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){ ** Cause any pending operation to stop at its earliest opportunity. */ void sqlite3_interrupt(sqlite3 *db){ - if( db && (db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_BUSY) ){ + if( sqlite3SafetyCheckOk(db) ){ db->u1.isInterrupted = 1; } } @@ -474,7 +461,7 @@ int sqlite3CreateFunc( int nName; assert( sqlite3_mutex_held(db->mutex) ); - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } if( zFunctionName==0 || @@ -798,7 +785,7 @@ const char *sqlite3_errmsg(sqlite3 *db){ if( !db ){ return sqlite3ErrStr(SQLITE_NOMEM); } - if( sqlite3SafetyCheck(db) || db->errCode==SQLITE_MISUSE ){ + if( !sqlite3SafetyCheckSickOrOk(db) || db->errCode==SQLITE_MISUSE ){ return sqlite3ErrStr(SQLITE_MISUSE); } sqlite3_mutex_enter(db->mutex); @@ -840,7 +827,7 @@ const void *sqlite3_errmsg16(sqlite3 *db){ if( !db ){ return (void *)(&outOfMemBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]); } - if( sqlite3SafetyCheck(db) || db->errCode==SQLITE_MISUSE ){ + if( !sqlite3SafetyCheckSickOrOk(db) || db->errCode==SQLITE_MISUSE ){ return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]); } sqlite3_mutex_enter(db->mutex); @@ -865,7 +852,7 @@ int sqlite3_errcode(sqlite3 *db){ if( !db || db->mallocFailed ){ return SQLITE_NOMEM; } - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE; } return db->errCode & db->errMask; @@ -886,7 +873,7 @@ static int createCollation( CollSeq *pColl; int enc2; - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } assert( sqlite3_mutex_held(db->mutex) ); @@ -1000,7 +987,7 @@ static int openDatabase( db->pVfs = sqlite3_vfs_find(zVfs); if( !db->pVfs ){ rc = SQLITE_ERROR; - db->magic = SQLITE_MAGIC_CLOSED; + db->magic = SQLITE_MAGIC_SICK; sqlite3Error(db, rc, "no such vfs: %s", (zVfs?zVfs:"(null)")); goto opendb_out; } @@ -1016,7 +1003,7 @@ static int openDatabase( (db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 6, 0))==0 ){ assert( db->mallocFailed ); - db->magic = SQLITE_MAGIC_CLOSED; + db->magic = SQLITE_MAGIC_SICK; goto opendb_out; } @@ -1037,7 +1024,7 @@ static int openDatabase( &db->aDb[0].pBt); if( rc!=SQLITE_OK ){ sqlite3Error(db, rc, 0); - db->magic = SQLITE_MAGIC_CLOSED; + db->magic = SQLITE_MAGIC_SICK; goto opendb_out; } db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt); @@ -1253,7 +1240,7 @@ int sqlite3_collation_needed( void *pCollNeededArg, void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*) ){ - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -1274,7 +1261,7 @@ int sqlite3_collation_needed16( void *pCollNeededArg, void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*) ){ - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -1358,7 +1345,7 @@ int sqlite3_table_column_metadata( int autoinc = 0; /* Ensure the database schema has been loaded */ - if( sqlite3SafetyOn(db) ){ + if( !sqlite3SafetyCheckOk(db) || sqlite3SafetyOn(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -191,7 +191,9 @@ static sqlite3_vfs *vfsList = 0; ** first VFS on the list. */ sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){ +#ifndef SQLITE_MUTEX_NOOP sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); +#endif sqlite3_vfs *pVfs = 0; static int isInit = 0; sqlite3_mutex_enter(mutex); @@ -233,7 +235,9 @@ static void vfsUnlink(sqlite3_vfs *pVfs){ ** true. */ int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ +#ifndef SQLITE_MUTEX_NOOP sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); +#endif sqlite3_vfs_find(0); /* Make sure we are initialized */ sqlite3_mutex_enter(mutex); vfsUnlink(pVfs); @@ -253,7 +257,9 @@ int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ ** Unregister a VFS so that it is no longer accessible. */ int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){ +#ifndef SQLITE_MUTEX_NOOP sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); +#endif sqlite3_mutex_enter(mutex); vfsUnlink(pVfs); sqlite3_mutex_leave(mutex); diff --git a/src/prepare.c b/src/prepare.c index 324b15afa..a9bc8442e 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.74 2008/01/22 19:34:28 drh Exp $ +** $Id: prepare.c,v 1.75 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -174,7 +174,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ zMasterName = SCHEMA_TABLE(iDb); /* Construct the schema tables. */ - sqlite3SafetyOff(db); azArg[0] = zMasterName; azArg[1] = "1"; azArg[2] = zMasterSchema; @@ -182,9 +181,10 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ initData.db = db; initData.iDb = iDb; initData.pzErrMsg = pzErrMsg; + (void)sqlite3SafetyOff(db); rc = sqlite3InitCallback(&initData, 3, (char **)azArg, 0); + (void)sqlite3SafetyOn(db); if( rc ){ - sqlite3SafetyOn(db); rc = initData.rc; goto error_out; } @@ -192,7 +192,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ if( pTab ){ pTab->readOnly = 1; } - sqlite3SafetyOn(db); /* Create a cursor to hold the database open */ @@ -312,7 +311,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ zSql = sqlite3MPrintf(db, "SELECT name, rootpage, sql FROM '%q'.%s", db->aDb[iDb].zName, zMasterName); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); #ifndef SQLITE_OMIT_AUTHORIZATION { int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); @@ -325,7 +324,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ } #endif if( rc==SQLITE_ABORT ) rc = initData.rc; - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); sqlite3_free(zSql); #ifndef SQLITE_OMIT_ANALYZE if( rc==SQLITE_OK ){ @@ -524,7 +523,7 @@ int sqlite3Prepare( if( rc ){ const char *zDb = db->aDb[i].zName; sqlite3Error(db, SQLITE_LOCKED, "database schema is locked: %s", zDb); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); return SQLITE_LOCKED; } } @@ -536,7 +535,7 @@ int sqlite3Prepare( char *zSqlCopy; if( SQLITE_MAX_SQL_LENGTH>0 && nBytes>SQLITE_MAX_SQL_LENGTH ){ sqlite3Error(db, SQLITE_TOOBIG, "statement too long"); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); return SQLITE_TOOBIG; } zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes); @@ -622,7 +621,7 @@ static int sqlite3LockAndPrepare( const char **pzTail /* OUT: End of parsed string */ ){ int rc; - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); @@ -715,7 +714,7 @@ static int sqlite3Prepare16( const char *zTail8 = 0; int rc = SQLITE_OK; - if( sqlite3SafetyCheck(db) ){ + if( !sqlite3SafetyCheckOk(db) ){ return SQLITE_MISUSE; } sqlite3_mutex_enter(db->mutex); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 1ba3b8de8..1c9951d97 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.653 2008/01/22 21:30:53 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.654 2008/01/23 03:03:05 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -590,6 +590,7 @@ struct sqlite3 { */ #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ #define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ +#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ #define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ @@ -1816,9 +1817,15 @@ Select *sqlite3SelectDup(sqlite3*,Select*); FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); void sqlite3RegisterBuiltinFunctions(sqlite3*); void sqlite3RegisterDateTimeFunctions(sqlite3*); -int sqlite3SafetyOn(sqlite3*); -int sqlite3SafetyOff(sqlite3*); -int sqlite3SafetyCheck(sqlite3*); +#ifdef SQLITE_DEBUG + int sqlite3SafetyOn(sqlite3*); + int sqlite3SafetyOff(sqlite3*); +#else +# define sqlite3SafetyOn(A) 0 +# define sqlite3SafetyOff(A) 0 +#endif +int sqlite3SafetyCheckOk(sqlite3*); +int sqlite3SafetyCheckSickOrOk(sqlite3*); void sqlite3ChangeCookie(Parse*, int); #ifndef SQLITE_OMIT_TRIGGER @@ -2008,8 +2015,7 @@ CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); ** Available fault injectors. Should be numbered beginning with 0. */ #define SQLITE_FAULTINJECTOR_MALLOC 0 -#define SQLITE_FAULTINJECTOR_SAFETY 1 -#define SQLITE_FAULTINJECTOR_COUNT 2 +#define SQLITE_FAULTINJECTOR_COUNT 1 /* ** The interface to the fault injector subsystem. If the fault injector diff --git a/src/test_devsym.c b/src/test_devsym.c index 588f5d286..724b29d34 100644 --- a/src/test_devsym.c +++ b/src/test_devsym.c @@ -344,4 +344,3 @@ void devsym_register(int iDeviceChar, int iSectorSize){ } #endif - diff --git a/src/util.c b/src/util.c index e33bcaeed..f8f02a4d0 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.215 2008/01/22 14:50:17 drh Exp $ +** $Id: util.c,v 1.216 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -660,6 +660,7 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){ ** call to sqlite3_close(db) and db has been deallocated. And we do ** not want to write into deallocated memory. */ +#ifdef SQLITE_DEBUG int sqlite3SafetyOn(sqlite3 *db){ if( db->magic==SQLITE_MAGIC_OPEN ){ db->magic = SQLITE_MAGIC_BUSY; @@ -670,38 +671,54 @@ int sqlite3SafetyOn(sqlite3 *db){ } return 1; } +#endif /* ** Change the magic from SQLITE_MAGIC_BUSY to SQLITE_MAGIC_OPEN. ** Return an error (non-zero) if the magic was not SQLITE_MAGIC_BUSY ** when this routine is called. */ +#ifdef SQLITE_DEBUG int sqlite3SafetyOff(sqlite3 *db){ if( db->magic==SQLITE_MAGIC_BUSY ){ db->magic = SQLITE_MAGIC_OPEN; return 0; - }else { + }else{ db->magic = SQLITE_MAGIC_ERROR; db->u1.isInterrupted = 1; return 1; } } +#endif /* ** Check to make sure we have a valid db pointer. This test is not ** foolproof but it does provide some measure of protection against ** misuse of the interface such as passing in db pointers that are ** NULL or which have been previously closed. If this routine returns -** TRUE it means that the db pointer is invalid and should not be +** 1 it means that the db pointer is valid and 0 if it should not be ** dereferenced for any reason. The calling function should invoke ** SQLITE_MISUSE immediately. +** +** sqlite3SafetyCheckOk() requires that the db pointer be valid for +** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to +** open properly and is not fit for general use but which can be +** used as an argument to sqlite3_errmsg() or sqlite3_close(). */ -int sqlite3SafetyCheck(sqlite3 *db){ +int sqlite3SafetyCheckOk(sqlite3 *db){ int magic; - if( db==0 ) return 1; + if( db==0 ) return 0; magic = db->magic; - if( magic!=SQLITE_MAGIC_CLOSED && - magic!=SQLITE_MAGIC_OPEN && - magic!=SQLITE_MAGIC_BUSY ) return 1; - return 0; + if( magic!=SQLITE_MAGIC_OPEN && + magic!=SQLITE_MAGIC_BUSY ) return 0; + return 1; +} +int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ + int magic; + if( db==0 ) return 0; + magic = db->magic; + if( magic!=SQLITE_MAGIC_SICK && + magic!=SQLITE_MAGIC_OPEN && + magic!=SQLITE_MAGIC_BUSY ) return 0; + return 1; } diff --git a/src/vdbe.c b/src/vdbe.c index a827115b9..0f74f740b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.704 2008/01/22 21:30:53 drh Exp $ +** $Id: vdbe.c,v 1.705 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -3905,7 +3905,7 @@ case OP_ParseSchema: { "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s", db->aDb[iDb].zName, zMaster, pOp->p4.z); if( zSql==0 ) goto no_mem; - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); assert( db->init.busy==0 ); db->init.busy = 1; assert( !db->mallocFailed ); @@ -3913,7 +3913,7 @@ case OP_ParseSchema: { if( rc==SQLITE_ABORT ) rc = initData.rc; sqlite3_free(zSql); db->init.busy = 0; - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); if( rc==SQLITE_NOMEM ){ goto no_mem; } @@ -4798,11 +4798,7 @@ abort_due_to_error: */ abort_due_to_interrupt: assert( db->u1.isInterrupted ); - if( db->magic!=SQLITE_MAGIC_BUSY ){ - rc = SQLITE_MISUSE; - }else{ - rc = SQLITE_INTERRUPT; - } + rc = SQLITE_INTERRUPT; p->rc = rc; sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0); goto vdbe_error_halt; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7d44fb158..df9c75f68 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -44,7 +44,9 @@ int sqlite3_finalize(sqlite3_stmt *pStmt){ rc = SQLITE_OK; }else{ Vdbe *v = (Vdbe*)pStmt; +#ifndef SQLITE_MUTEX_NOOP sqlite3_mutex *mutex = v->db->mutex; +#endif sqlite3_mutex_enter(mutex); rc = sqlite3VdbeFinalize(v); sqlite3_mutex_leave(mutex); @@ -81,12 +83,14 @@ int sqlite3_reset(sqlite3_stmt *pStmt){ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){ int i; int rc = SQLITE_OK; - Vdbe *v = (Vdbe*)pStmt; - sqlite3_mutex_enter(v->db->mutex); +#ifndef SQLITE_MUTEX_NOOP + sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex; +#endif + sqlite3_mutex_enter(mutex); for(i=1; rc==SQLITE_OK && i<=sqlite3_bind_parameter_count(pStmt); i++){ rc = sqlite3_bind_null(pStmt, i); } - sqlite3_mutex_leave(v->db->mutex); + sqlite3_mutex_leave(mutex); return rc; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index dc4cc1a5c..c15207b9b 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1021,9 +1021,9 @@ void sqlite3VdbeFreeCursor(Vdbe *p, Cursor *pCx){ sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor; const sqlite3_module *pModule = pCx->pModule; p->inVtabMethod = 1; - sqlite3SafetyOff(p->db); + (void)sqlite3SafetyOff(p->db); pModule->xClose(pVtabCursor); - sqlite3SafetyOn(p->db); + (void)sqlite3SafetyOn(p->db); p->inVtabMethod = 0; } #endif @@ -1167,9 +1167,9 @@ static int vdbeCommit(sqlite3 *db){ /* If there are any write-transactions at all, invoke the commit hook */ if( needXcommit && db->xCommitCallback ){ - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); rc = db->xCommitCallback(db->pCommitArg); - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); if( rc ){ return SQLITE_CONSTRAINT; } @@ -1617,9 +1617,9 @@ int sqlite3VdbeReset(Vdbe *p){ ** error, then it might not have been halted properly. So halt ** it now. */ - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); sqlite3VdbeHalt(p); - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); /* If the VDBE has be run even partially, then transfer the error code ** and error message from the VDBE into the main database structure. But diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 1fa71f121..6565294c6 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -12,7 +12,7 @@ ** ** This file contains code used to implement incremental BLOB I/O. ** -** $Id: vdbeblob.c,v 1.18 2008/01/10 23:50:11 drh Exp $ +** $Id: vdbeblob.c,v 1.19 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" @@ -109,7 +109,7 @@ int sqlite3_blob_open( } sqlite3_free(sParse.zErrMsg); rc = SQLITE_ERROR; - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } @@ -123,7 +123,7 @@ int sqlite3_blob_open( if( iCol==pTab->nCol ){ sqlite3_snprintf(sizeof(zErr), zErr, "no such column: \"%s\"", zColumn); rc = SQLITE_ERROR; - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } @@ -141,7 +141,7 @@ int sqlite3_blob_open( sqlite3_snprintf(sizeof(zErr), zErr, "cannot open indexed column for writing"); rc = SQLITE_ERROR; - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); sqlite3BtreeLeaveAll(db); goto blob_open_out; } diff --git a/src/vtab.c b/src/vtab.c index 5402695e8..776f36ead 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.62 2008/01/17 16:22:15 drh Exp $ +** $Id: vtab.c,v 1.63 2008/01/23 03:03:05 drh Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -93,12 +93,12 @@ void sqlite3VtabLock(sqlite3_vtab *pVtab){ void sqlite3VtabUnlock(sqlite3 *db, sqlite3_vtab *pVtab){ pVtab->nRef--; assert(db); - assert(!sqlite3SafetyCheck(db)); + assert( sqlite3SafetyCheckOk(db) ); if( pVtab->nRef==0 ){ if( db->magic==SQLITE_MAGIC_BUSY ){ - sqlite3SafetyOff(db); + (void)sqlite3SafetyOff(db); pVtab->pModule->xDisconnect(pVtab); - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); } else { pVtab->pModule->xDisconnect(pVtab); } @@ -594,7 +594,7 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab) if( xDestroy ){ rc = xDestroy(pTab->pVtab); } - sqlite3SafetyOn(db); + (void)sqlite3SafetyOn(db); if( rc==SQLITE_OK ){ pTab->pVtab = 0; } diff --git a/src/where.c b/src/where.c index 1ad296e13..ae8fb4b8c 100644 --- a/src/where.c +++ b/src/where.c @@ -16,7 +16,7 @@ ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.284 2008/01/19 20:11:26 drh Exp $ +** $Id: where.c,v 1.285 2008/01/23 03:03:05 drh Exp $ */ #include "sqliteInt.h" @@ -1381,7 +1381,7 @@ static double bestVirtualIndex( *(int*)&pIdxInfo->nOrderBy = 0; } - sqlite3SafetyOff(pParse->db); + (void)sqlite3SafetyOff(pParse->db); WHERETRACE(("xBestIndex for %s\n", pTab->zName)); TRACE_IDX_INPUTS(pIdxInfo); rc = pTab->pVtab->pModule->xBestIndex(pTab->pVtab, pIdxInfo); @@ -1392,10 +1392,8 @@ static double bestVirtualIndex( }else { sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc)); } - sqlite3SafetyOn(pParse->db); - }else{ - rc = sqlite3SafetyOn(pParse->db); } + (void)sqlite3SafetyOn(pParse->db); *(int*)&pIdxInfo->nOrderBy = nOrderBy; return pIdxInfo->estimatedCost; |