diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 27 | ||||
-rw-r--r-- | src/btreeInt.h | 4 | ||||
-rw-r--r-- | src/build.c | 8 | ||||
-rw-r--r-- | src/insert.c | 8 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/malloc.c | 40 | ||||
-rw-r--r-- | src/prepare.c | 21 | ||||
-rw-r--r-- | src/printf.c | 16 | ||||
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/sqliteInt.h | 6 | ||||
-rw-r--r-- | src/tokenize.c | 6 | ||||
-rw-r--r-- | src/vacuum.c | 5 | ||||
-rw-r--r-- | src/vdbe.c | 31 | ||||
-rw-r--r-- | src/vdbeaux.c | 7 |
14 files changed, 85 insertions, 105 deletions
diff --git a/src/btree.c b/src/btree.c index fa1816372..23df64f0d 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.472 2008/07/08 17:13:59 danielk1977 Exp $ +** $Id: btree.c,v 1.473 2008/07/08 19:34:07 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. @@ -6401,23 +6401,18 @@ static void checkAppendMsg( ... ){ va_list ap; - char *zMsg2; if( !pCheck->mxErr ) return; pCheck->mxErr--; pCheck->nErr++; va_start(ap, zFormat); - zMsg2 = sqlite3VMPrintf(0, zFormat, ap); - va_end(ap); - if( zMsg1==0 ) zMsg1 = ""; - if( pCheck->zErrMsg ){ - char *zOld = pCheck->zErrMsg; - pCheck->zErrMsg = 0; - sqlite3SetString(&pCheck->zErrMsg, zOld, "\n", zMsg1, zMsg2, (char*)0); - sqlite3_free(zOld); - }else{ - sqlite3SetString(&pCheck->zErrMsg, zMsg1, zMsg2, (char*)0); + if( pCheck->errMsg.nChar ){ + sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1); } - sqlite3_free(zMsg2); + if( zMsg1 ){ + sqlite3StrAccumAppend(&pCheck->errMsg, zMsg1, -1); + } + sqlite3VXPrintf(&pCheck->errMsg, 1, zFormat, ap); + va_end(ap); } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ @@ -6733,6 +6728,7 @@ char *sqlite3BtreeIntegrityCheck( int nRef; IntegrityCk sCheck; BtShared *pBt = p->pBt; + char zErr[100]; sqlite3BtreeEnter(p); pBt->db = p->db; @@ -6770,7 +6766,7 @@ char *sqlite3BtreeIntegrityCheck( if( i<=sCheck.nPage ){ sCheck.anRef[i] = 1; } - sCheck.zErrMsg = 0; + sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), 20000); /* Check the integrity of the freelist */ @@ -6826,7 +6822,8 @@ char *sqlite3BtreeIntegrityCheck( sqlite3BtreeLeave(p); sqlite3_free(sCheck.anRef); *pnErr = sCheck.nErr; - return sCheck.zErrMsg; + if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg); + return sqlite3StrAccumFinish(&sCheck.errMsg); } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ diff --git a/src/btreeInt.h b/src/btreeInt.h index f5783fa24..1bb5c6bf5 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btreeInt.h,v 1.22 2008/06/15 02:51:47 drh Exp $ +** $Id: btreeInt.h,v 1.23 2008/07/08 19:34:07 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -612,8 +612,8 @@ struct IntegrityCk { int nPage; /* Number of pages in the database */ int *anRef; /* Number of times each page is referenced */ int mxErr; /* Stop accumulating errors when this reaches zero */ - char *zErrMsg; /* An error message. NULL if no errors seen. */ int nErr; /* Number of messages written to zErrMsg so far */ + StrAccum errMsg; /* Accumulate the error message text here */ }; /* diff --git a/src/build.c b/src/build.c index 30037e3fa..1cff08b1f 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.487 2008/07/08 14:52:08 drh Exp $ +** $Id: build.c,v 1.488 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -2458,15 +2458,11 @@ void sqlite3CreateIndex( goto exit_create_index; } }else{ - char zBuf[30]; int n; Index *pLoop; for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){} - sqlite3_snprintf(sizeof(zBuf),zBuf,"_%d",n); - zName = 0; - sqlite3SetString(&zName, "sqlite_autoindex_", pTab->zName, zBuf, (char*)0); + zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n); if( zName==0 ){ - db->mallocFailed = 1; goto exit_create_index; } } diff --git a/src/insert.c b/src/insert.c index afb391473..bada46654 100644 --- a/src/insert.c +++ b/src/insert.c @@ -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.244 2008/07/04 10:56:08 danielk1977 Exp $ +** $Id: insert.c,v 1.245 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" @@ -1130,10 +1130,10 @@ void sqlite3GenerateConstraintChecks( case OE_Rollback: case OE_Abort: case OE_Fail: { - char *zMsg = 0; + char *zMsg; sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_CONSTRAINT, onError); - sqlite3SetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName, - " may not be NULL", (char*)0); + zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL", + pTab->zName, pTab->aCol[i].zName); sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC); break; } diff --git a/src/main.c b/src/main.c index 74e8aa90c..2f31aa535 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.471 2008/07/08 14:52:10 drh Exp $ +** $Id: main.c,v 1.472 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1737,8 +1737,9 @@ error_out: if( pAutoinc ) *pAutoinc = autoinc; if( SQLITE_OK==rc && !pTab ){ - sqlite3SetString(&zErrMsg, "no such table column: ", zTableName, ".", - zColumnName, 0); + sqlite3_free(zErrMsg); + zErrMsg = sqlite3MPrintf("no such table column: %s.%s", zTableName, + zColumnName); rc = SQLITE_ERROR; } sqlite3Error(db, rc, (zErrMsg?"%s":0), zErrMsg); diff --git a/src/malloc.c b/src/malloc.c index 36f0faefe..351a38ce3 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** ** Memory allocation functions used throughout sqlite. ** -** $Id: malloc.c,v 1.25 2008/06/23 14:03:45 danielk1977 Exp $ +** $Id: malloc.c,v 1.26 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -631,39 +631,19 @@ char *sqlite3DbStrNDup(sqlite3 *db, const char *z, int n){ } /* -** Create a string from the 2nd and subsequent arguments (up to the -** first NULL argument), store the string in memory obtained from -** sqliteMalloc() and make the pointer indicated by the 1st argument -** point to that string. The 1st argument must either be NULL or -** point to memory obtained from sqliteMalloc(). +** Create a string from the zFromat argument and the va_list that follows. +** Store the string in memory obtained from sqliteMalloc() and make *pz +** point to that string. */ -void sqlite3SetString(char **pz, ...){ +void sqlite3SetString(char **pz, sqlite3 *db, const char *zFormat, ...){ va_list ap; - int nByte; - const char *z; - char *zResult; - - assert( pz!=0 ); - nByte = 1; - va_start(ap, pz); - while( (z = va_arg(ap, const char*))!=0 ){ - nByte += strlen(z); - } + char *z; + + va_start(ap, zFormat); + z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); sqlite3_free(*pz); - *pz = zResult = sqlite3Malloc(nByte); - if( zResult==0 ){ - return; - } - *zResult = 0; - va_start(ap, pz); - while( (z = va_arg(ap, const char*))!=0 ){ - int n = strlen(z); - memcpy(zResult, z, n); - zResult += n; - } - zResult[0] = 0; - va_end(ap); + *pz = z; } diff --git a/src/prepare.c b/src/prepare.c index ec2e1c07e..6d984f1ad 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.88 2008/06/23 16:53:47 danielk1977 Exp $ +** $Id: prepare.c,v 1.89 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -29,8 +29,12 @@ static void corruptSchema( ){ if( !pData->db->mallocFailed ){ if( zObj==0 ) zObj = "?"; - sqlite3SetString(pData->pzErrMsg, "malformed database schema (", zObj, ")", - zExtra!=0 && zExtra[0]!=0 ? " - " : (char*)0, zExtra, (char*)0); + sqlite3SetString(pData->pzErrMsg, pData->db, + "malformed database schema (%s)", zObj); + if( zExtra && zExtra[0] ){ + *pData->pzErrMsg = sqlite3MPrintf(pData->db, "%z - %s", + *pData->pzErrMsg, zExtra); + } } pData->rc = SQLITE_CORRUPT; } @@ -215,7 +219,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ sqlite3BtreeEnter(pDb->pBt); rc = sqlite3BtreeCursor(pDb->pBt, MASTER_ROOT, 0, 0, curMain); if( rc!=SQLITE_OK && rc!=SQLITE_EMPTY ){ - sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0); + sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc)); goto leave_error_out; } @@ -242,7 +246,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ rc = sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]); } if( rc ){ - sqlite3SetString(pzErrMsg, sqlite3ErrStr(rc), (char*)0); + sqlite3SetString(pzErrMsg, db, "%s", sqlite3ErrStr(rc)); goto leave_error_out; } }else{ @@ -263,8 +267,8 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ }else{ /* If opening an attached database, the encoding much match ENC(db) */ if( meta[4]!=ENC(db) ){ - sqlite3SetString(pzErrMsg, "attached databases must use the same" - " text encoding as main database", (char*)0); + sqlite3SetString(pzErrMsg, db, "attached databases must use the same" + " text encoding as main database"); rc = SQLITE_ERROR; goto leave_error_out; } @@ -293,7 +297,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ pDb->pSchema->file_format = 1; } if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){ - sqlite3SetString(pzErrMsg, "unsupported file format", (char*)0); + sqlite3SetString(pzErrMsg, db, "unsupported file format"); rc = SQLITE_ERROR; goto leave_error_out; } @@ -340,7 +344,6 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ #endif } if( db->mallocFailed ){ - /* sqlite3SetString(pzErrMsg, "out of memory", (char*)0); */ rc = SQLITE_NOMEM; sqlite3ResetInternalSchema(db, 0); } diff --git a/src/printf.c b/src/printf.c index dc8d71105..5a75fca22 100644 --- a/src/printf.c +++ b/src/printf.c @@ -5,7 +5,7 @@ ** an historical reference. Most of the "enhancements" have been backed ** out so that the functionality is now the same as standard printf(). ** -** $Id: printf.c,v 1.87 2008/06/16 20:51:16 drh Exp $ +** $Id: printf.c,v 1.88 2008/07/08 19:34:07 drh Exp $ ** ************************************************************************** ** @@ -221,7 +221,7 @@ static void appendSpace(StrAccum *pAccum, int N){ ** seems to make a big difference in determining how fast this beast ** will run. */ -static void vxprintf( +void sqlite3VXPrintf( StrAccum *pAccum, /* Accumulate results here */ int useExtended, /* Allow extended %-conversions */ const char *fmt, /* Format string */ @@ -794,14 +794,14 @@ char *sqlite3StrAccumFinish(StrAccum *p){ void sqlite3StrAccumReset(StrAccum *p){ if( p->zText!=p->zBase ){ sqlite3_free(p->zText); - p->zText = 0; } + p->zText = 0; } /* ** Initialize a string accumulator */ -static void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){ +void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){ p->zText = p->zBase = zBase; p->nChar = 0; p->nAlloc = n; @@ -821,7 +821,7 @@ char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){ StrAccum acc; sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH); - vxprintf(&acc, 1, zFormat, ap); + sqlite3VXPrintf(&acc, 1, zFormat, ap); z = sqlite3StrAccumFinish(&acc); if( acc.mallocFailed && db ){ db->mallocFailed = 1; @@ -852,7 +852,7 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){ StrAccum acc; sqlite3_initialize(); sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH); - vxprintf(&acc, 0, zFormat, ap); + sqlite3VXPrintf(&acc, 0, zFormat, ap); z = sqlite3StrAccumFinish(&acc); return z; } @@ -888,7 +888,7 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ sqlite3StrAccumInit(&acc, zBuf, n, 0); acc.useMalloc = 0; va_start(ap,zFormat); - vxprintf(&acc, 0, zFormat, ap); + sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); z = sqlite3StrAccumFinish(&acc); return z; @@ -907,7 +907,7 @@ void sqlite3DebugPrintf(const char *zFormat, ...){ sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0); acc.useMalloc = 0; va_start(ap,zFormat); - vxprintf(&acc, 0, zFormat, ap); + sqlite3VXPrintf(&acc, 0, zFormat, ap); va_end(ap); sqlite3StrAccumFinish(&acc); fprintf(stdout,"%s", zBuf); diff --git a/src/select.c b/src/select.c index 6effc49d5..f7c5780ad 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.449 2008/07/08 18:05:26 drh Exp $ +** $Id: select.c,v 1.450 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" @@ -1111,7 +1111,7 @@ static void generateColumnNames( zTab = pTabList->a[j].zAlias; if( fullNames || zTab==0 ) zTab = pTab->zName; - sqlite3SetString(&zName, zTab, ".", zCol, (char*)0); + zName = sqlite3MPrintf(db, "%s.%s", zTab, zCol); sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, P4_DYNAMIC); }else{ sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, strlen(zCol)); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7be67939b..e56f6f514 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.735 2008/07/08 14:52:10 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.736 2008/07/08 19:34:07 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1826,6 +1826,7 @@ void sqlite3StatusSet(int, int); int sqlite3IsNaN(double); +void sqlite3VXPrintf(StrAccum*, int, const char*, va_list); char *sqlite3MPrintf(sqlite3*,const char*, ...); char *sqlite3VMPrintf(sqlite3*,const char*, va_list); #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) @@ -1834,7 +1835,7 @@ char *sqlite3VMPrintf(sqlite3*,const char*, va_list); #if defined(SQLITE_TEST) void *sqlite3TextToPtr(const char*); #endif -void sqlite3SetString(char **, ...); +void sqlite3SetString(char **, sqlite3*, const char*, ...); void sqlite3ErrorMsg(Parse*, const char*, ...); void sqlite3ErrorClear(Parse*); void sqlite3Dequote(char*); @@ -2146,6 +2147,7 @@ int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, int sqlite3ApiExit(sqlite3 *db, int); int sqlite3OpenTempDatabase(Parse *); +void sqlite3StrAccumInit(StrAccum*, char*, int, int); void sqlite3StrAccumAppend(StrAccum*,const char*,int); char *sqlite3StrAccumFinish(StrAccum*); void sqlite3StrAccumReset(StrAccum*); diff --git a/src/tokenize.c b/src/tokenize.c index 05622dae1..c7769f97f 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.145 2008/07/08 00:06:50 drh Exp $ +** $Id: tokenize.c,v 1.146 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -421,7 +421,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ case TK_COMMENT: { if( db->u1.isInterrupted ){ pParse->rc = SQLITE_INTERRUPT; - sqlite3SetString(pzErrMsg, "interrupt", (char*)0); + sqlite3SetString(pzErrMsg, db, "interrupt"); goto abort_parse; } break; @@ -460,7 +460,7 @@ abort_parse: pParse->rc = SQLITE_NOMEM; } if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){ - sqlite3SetString(&pParse->zErrMsg, sqlite3ErrStr(pParse->rc), (char*)0); + sqlite3SetString(&pParse->zErrMsg, db, "%s", sqlite3ErrStr(pParse->rc)); } if( pParse->zErrMsg ){ if( *pzErrMsg==0 ){ diff --git a/src/vacuum.c b/src/vacuum.c index 89e9a2803..45bc61e21 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -14,7 +14,7 @@ ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** -** $Id: vacuum.c,v 1.80 2008/06/17 01:03:26 drh Exp $ +** $Id: vacuum.c,v 1.81 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -96,8 +96,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){ db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks; if( !db->autoCommit ){ - sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction", - (char*)0); + sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction"); rc = SQLITE_ERROR; goto end_of_vacuum; } diff --git a/src/vdbe.c b/src/vdbe.c index 255ce71c7..69bf41865 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.758 2008/07/07 17:13:09 danielk1977 Exp $ +** $Id: vdbe.c,v 1.759 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -830,7 +830,7 @@ case OP_Halt: { p->pc = pc; p->errorAction = pOp->p2; if( pOp->p4.z ){ - sqlite3SetString(&p->zErrMsg, pOp->p4.z, (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); } rc = sqlite3VdbeHalt(p); assert( rc==SQLITE_BUSY || rc==SQLITE_OK ); @@ -1361,7 +1361,7 @@ case OP_Function: { /* If the function returned an error, throw an exception */ if( ctx.isError ){ - sqlite3SetString(&p->zErrMsg, sqlite3_value_text(&ctx.s), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s)); rc = ctx.isError; } @@ -2447,8 +2447,9 @@ case OP_AutoCommit: { ** still running, and a transaction is active, return an error indicating ** that the other VMs must complete first. */ - sqlite3SetString(&p->zErrMsg, "cannot ", rollback?"rollback":"commit", - " transaction - SQL statements in progress", (char*)0); + sqlite3SetString(&p->zErrMsg, db, "cannot %s transaction - " + "SQL statements in progress", + rollback ? "rollback" : "commit"); rc = SQLITE_ERROR; }else if( i!=db->autoCommit ){ if( pOp->p2 ){ @@ -2471,10 +2472,10 @@ case OP_AutoCommit: { } goto vdbe_return; }else{ - sqlite3SetString(&p->zErrMsg, + sqlite3SetString(&p->zErrMsg, db, (!i)?"cannot start a transaction within a transaction":( (rollback)?"cannot rollback - no transaction is active": - "cannot commit - no transaction is active"), (char*)0); + "cannot commit - no transaction is active")); rc = SQLITE_ERROR; } @@ -4473,7 +4474,7 @@ case OP_AggStep: { } (ctx.pFunc->xStep)(&ctx, n, apVal); if( ctx.isError ){ - sqlite3SetString(&p->zErrMsg, sqlite3_value_text(&ctx.s), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s)); rc = ctx.isError; } sqlite3VdbeMemRelease(&ctx.s); @@ -4499,7 +4500,7 @@ case OP_AggFinal: { assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 ); rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc); if( rc==SQLITE_ERROR ){ - sqlite3SetString(&p->zErrMsg, sqlite3_value_text(pMem), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(pMem)); } sqlite3VdbeChangeEncoding(pMem, encoding); UPDATE_MAX_BLOBSIZE(pMem); @@ -4589,7 +4590,7 @@ case OP_TableLock: { rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock); if( rc==SQLITE_LOCKED ){ const char *z = pOp->p4.z; - sqlite3SetString(&p->zErrMsg, "database table is locked: ", z, (char*)0); + sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z); } break; } @@ -4912,7 +4913,7 @@ case OP_VUpdate: { int nArg = pOp->p2; assert( pOp->p4type==P4_VTAB ); if( pModule->xUpdate==0 ){ - sqlite3SetString(&p->zErrMsg, "read-only table", 0); + sqlite3SetString(&p->zErrMsg, db, "read-only table"); rc = SQLITE_ERROR; }else{ int i; @@ -5058,7 +5059,7 @@ vdbe_return: ** is encountered. */ too_big: - sqlite3SetString(&p->zErrMsg, "string or blob too big", (char*)0); + sqlite3SetString(&p->zErrMsg, db, "string or blob too big"); rc = SQLITE_TOOBIG; goto vdbe_error_halt; @@ -5066,7 +5067,7 @@ too_big: */ no_mem: db->mallocFailed = 1; - sqlite3SetString(&p->zErrMsg, "out of memory", (char*)0); + sqlite3SetString(&p->zErrMsg, db, "out of memory"); rc = SQLITE_NOMEM; goto vdbe_error_halt; @@ -5083,7 +5084,7 @@ abort_due_to_error: assert( p->zErrMsg==0 ); if( db->mallocFailed ) rc = SQLITE_NOMEM; if( rc!=SQLITE_IOERR_NOMEM ){ - sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(rc)); } goto vdbe_error_halt; @@ -5094,6 +5095,6 @@ abort_due_to_interrupt: assert( db->u1.isInterrupted ); rc = SQLITE_INTERRUPT; p->rc = rc; - sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(rc)); goto vdbe_error_halt; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e2b235bc0..0a7dc6e6f 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -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.393 2008/06/25 00:12:42 drh Exp $ +** $Id: vdbeaux.c,v 1.394 2008/07/08 19:34:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -832,7 +832,7 @@ int sqlite3VdbeList( }else if( db->u1.isInterrupted ){ p->rc = SQLITE_INTERRUPT; rc = SQLITE_ERROR; - sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(p->rc), (char*)0); + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc)); }else{ char *z; Op *pOp = &p->aOp[i]; @@ -1632,7 +1632,8 @@ int sqlite3VdbeHalt(Vdbe *p){ rc = xFunc(pBt); if( rc && (p->rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT) ){ p->rc = rc; - sqlite3SetString(&p->zErrMsg, 0); + sqlite3_free(p->zErrMsg); + p->zErrMsg = 0; } } } |