Index: src/backup.c ================================================================== --- src/backup.c +++ src/backup.c @@ -96,14 +96,14 @@ sqlite3Error(pErrorDb, SQLITE_NOMEM, "out of memory"); rc = SQLITE_NOMEM; }else{ pParse->db = pDb; if( sqlite3OpenTempDatabase(pParse) ){ - sqlite3ErrorClear(pParse); sqlite3Error(pErrorDb, pParse->rc, "%s", pParse->zErrMsg); rc = SQLITE_ERROR; } + sqlite3DbFree(pErrorDb, pParse->zErrMsg); sqlite3StackFree(pErrorDb, pParse); } if( rc ){ return 0; } Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -1972,17 +1972,16 @@ if( db->mallocFailed ){ goto exit_drop_table; } assert( pParse->nErr==0 ); assert( pName->nSrc==1 ); + if( noErr ) db->suppressErr++; pTab = sqlite3LocateTable(pParse, isView, pName->a[0].zName, pName->a[0].zDatabase); + if( noErr ) db->suppressErr--; if( pTab==0 ){ - if( noErr ){ - sqlite3ErrorClear(pParse); - } goto exit_drop_table; } iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( iDb>=0 && iDbnDb ); Index: src/printf.c ================================================================== --- src/printf.c +++ src/printf.c @@ -940,25 +940,25 @@ } /* ** Format and write a message to the log if logging is enabled. */ -void sqlite3_log(int iPriority, const char *zFormat, ...){ +void sqlite3_log(int iErrCode, const char *zFormat, ...){ void (*xLog)(void*, int, const char*); /* The global logger function */ void *pLogArg; /* First argument to the logger */ va_list ap; /* Vararg list */ char *zMsg; /* Complete log message */ xLog = sqlite3GlobalConfig.xLog; - if( xLog ){ + if( xLog && zFormat ){ va_start(ap, zFormat); sqlite3BeginBenignMalloc(); zMsg = sqlite3_vmprintf(zFormat, ap); sqlite3EndBenignMalloc(); va_end(ap); pLogArg = sqlite3GlobalConfig.pLogArg; - xLog(pLogArg, iPriority, zMsg ? zMsg : zFormat); + xLog(pLogArg, iErrCode, zMsg ? zMsg : zFormat); sqlite3_free(zMsg); } } #if defined(SQLITE_DEBUG) Index: src/resolve.c ================================================================== --- src/resolve.c +++ src/resolve.c @@ -662,10 +662,13 @@ Expr *pE /* The specific ORDER BY term */ ){ int i; /* Loop counter */ ExprList *pEList; /* The columns of the result set */ NameContext nc; /* Name context for resolving pE */ + sqlite3 *db; /* Database connection */ + int rc; /* Return code from subprocedures */ + u8 savedSuppErr; /* Saved value of db->suppressErr */ assert( sqlite3ExprIsInteger(pE, &i)==0 ); pEList = pSelect->pEList; /* Resolve all names in the ORDER BY term expression @@ -674,14 +677,16 @@ nc.pParse = pParse; nc.pSrcList = pSelect->pSrc; nc.pEList = pEList; nc.allowAgg = 1; nc.nErr = 0; - if( sqlite3ResolveExprNames(&nc, pE) ){ - sqlite3ErrorClear(pParse); - return 0; - } + db = pParse->db; + savedSuppErr = db->suppressErr; + db->suppressErr = 1; + rc = sqlite3ResolveExprNames(&nc, pE); + db->suppressErr = savedSuppErr; + if( rc ) return 0; /* Try to match the ORDER BY expression against an expression ** in the result set. Return an 1-based index of the matching ** result-set entry. */ Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -3655,11 +3655,11 @@ sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const void*) ); -#if SQLITE_HAS_CODEC +#if SQLITE_HAS_CODEC /* ** Specify the key for an encrypted database. This routine should be ** called right after sqlite3_open(). ** ** The code to implement this API is not available in the public release @@ -3685,23 +3685,23 @@ /* ** Specify the activation key for a SEE database. Unless ** activated, none of the SEE routines will work. */ -void sqlite3_activate_see( - const char *zPassPhrase /* Activation phrase */ -); -#endif - -#ifdef SQLITE_ENABLE_CEROD +void sqlite3_activate_see( + const char *zPassPhrase /* Activation phrase */ +); +#endif + +#ifdef SQLITE_ENABLE_CEROD /* ** Specify the activation key for a CEROD database. Unless ** activated, none of the CEROD routines will work. */ -void sqlite3_activate_cerod( - const char *zPassPhrase /* Activation phrase */ -); +void sqlite3_activate_cerod( + const char *zPassPhrase /* Activation phrase */ +); #endif /* ** CAPI3REF: Suspend Execution For A Short Time ** @@ -5673,11 +5673,11 @@ ** The sqlite3_log() interface is intended for use by extensions such as ** virtual tables, collating functions, and SQL functions. While there is ** nothing to prevent an application from calling sqlite3_log(), doing so ** is considered bad form. */ -void sqlite3_log(int iPriority, const char *zFormat, ...); +void sqlite3_log(int iErrCode, const char *zFormat, ...); /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -792,10 +792,11 @@ u8 temp_store; /* 1: file 2: memory 0: default */ u8 mallocFailed; /* True if we have seen a malloc failure */ u8 dfltLockMode; /* Default locking-mode for attached dbs */ u8 dfltJournalMode; /* Default journal mode for attached dbs */ signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ + u8 suppressErr; /* Do not issue error messages if true */ int nextPagesize; /* Pagesize after VACUUM if >0 */ int nTable; /* Number of tables in the database */ CollSeq *pDfltColl; /* The default collating sequence (BINARY) */ i64 lastRowid; /* ROWID of most recent insert (see above) */ u32 magic; /* Magic number for detect library misuse */ @@ -2552,11 +2553,10 @@ #if defined(SQLITE_TEST) void *sqlite3TestTextToPtr(const char*); #endif void sqlite3SetString(char **, sqlite3*, const char*, ...); void sqlite3ErrorMsg(Parse*, const char*, ...); -void sqlite3ErrorClear(Parse*); int sqlite3Dequote(char*); int sqlite3KeywordCode(const unsigned char*, int); int sqlite3RunParser(Parse*, const char*, char **); void sqlite3FinishCoding(Parse*); int sqlite3GetTempReg(Parse*); Index: src/util.c ================================================================== --- src/util.c +++ src/util.c @@ -121,10 +121,11 @@ char *z; va_list ap; va_start(ap, zFormat); z = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); + sqlite3_log(err_code, z); sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC); }else{ sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC); } } @@ -146,27 +147,25 @@ ** stored by this function into the database handle using sqlite3Error(). ** Function sqlite3Error() should be used during statement execution ** (sqlite3_step() etc.). */ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ + char *zMsg; va_list ap; sqlite3 *db = pParse->db; - pParse->nErr++; - sqlite3DbFree(db, pParse->zErrMsg); va_start(ap, zFormat); - pParse->zErrMsg = sqlite3VMPrintf(db, zFormat, ap); + zMsg = sqlite3VMPrintf(db, zFormat, ap); va_end(ap); - pParse->rc = SQLITE_ERROR; -} - -/* -** Clear the error message in pParse, if any -*/ -void sqlite3ErrorClear(Parse *pParse){ - sqlite3DbFree(pParse->db, pParse->zErrMsg); - pParse->zErrMsg = 0; - pParse->nErr = 0; + if( db->suppressErr ){ + sqlite3DbFree(db, zMsg); + }else{ + pParse->nErr++; + sqlite3DbFree(db, pParse->zErrMsg); + pParse->zErrMsg = zMsg; + pParse->rc = SQLITE_ERROR; + sqlite3_log(SQLITE_ERROR, pParse->zErrMsg); + } } /* ** Convert an SQL-style quoted string into a normal string by removing ** the quote characters. The conversion is done in-place. If the