SQLite

Check-in [d986e92893]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Test coverage enhancements. Additional documentation detail on the new sqlite3_log() interface.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d986e9289388fd72257b26cb2f9c972177255cd4
User & Date: drh 2010-02-25 21:27:59.000
Context
2010-02-25
23:44
Fix to the database connection validity checker. Other test coverage enhancements. (check-in: 0f6291bbbd user: drh tags: trunk)
21:27
Test coverage enhancements. Additional documentation detail on the new sqlite3_log() interface. (check-in: d986e92893 user: drh tags: trunk)
19:09
Add experimental fix for corruption detection problem. This may well be revised yet. (check-in: 1cc4be7ebc user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/printf.c.
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
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 && zFormat ){
    va_start(ap, zFormat);
    sqlite3BeginBenignMalloc();
    zMsg = sqlite3_vmprintf(zFormat, ap);
    sqlite3EndBenignMalloc();
    va_end(ap);
    pLogArg = sqlite3GlobalConfig.pLogArg;
    xLog(pLogArg, iErrCode, zMsg ? zMsg : zFormat);







|







945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
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 ){
    va_start(ap, zFormat);
    sqlite3BeginBenignMalloc();
    zMsg = sqlite3_vmprintf(zFormat, ap);
    sqlite3EndBenignMalloc();
    va_end(ap);
    pLogArg = sqlite3GlobalConfig.pLogArg;
    xLog(pLogArg, iErrCode, zMsg ? zMsg : zFormat);
Changes to src/sqlite.h.in.
5692
5693
5694
5695
5696
5697
5698


5699
5700
5701
5702
5703


5704
5705
5706
5707
5708
5709
5710

/*
** CAPI3REF: Error Logging Interface
** EXPERIMENTAL
**
** ^The [sqlite3_log()] interface writes a message into the error log
** established by the [SQLITE_CONFIG_ERRORLOG] option to [sqlite3_config()].


**
** 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 iErrCode, const char *zFormat, ...);

/*
** Undo the hack that converts floating point types to integer for
** builds on processors without floating point support.
*/







>
>





>
>







5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714

/*
** CAPI3REF: Error Logging Interface
** EXPERIMENTAL
**
** ^The [sqlite3_log()] interface writes a message into the error log
** established by the [SQLITE_CONFIG_ERRORLOG] option to [sqlite3_config()].
** ^If logging is enabled, the zFormat string and subsequent arguments are
** passed through to [sqlite3_vmprintf()] to generate the final output string.
**
** 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.
**
** The zFormat string must not be NULL.
*/
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.
*/
Changes to src/vdbeapi.c.
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
  db = p->db;
  if( db->mallocFailed ){
    p->rc = SQLITE_NOMEM;
    return SQLITE_NOMEM;
  }

  if( p->pc<=0 && p->expired ){
    if( p->rc==SQLITE_OK ){
      p->rc = SQLITE_SCHEMA;
    }
    rc = SQLITE_ERROR;
    goto end_of_step;
  }
  if( p->pc<0 ){
    /* If there are no other statements currently running, then
    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt
    ** from interrupting a statement that has not yet started.







<
|
<







330
331
332
333
334
335
336

337

338
339
340
341
342
343
344
  db = p->db;
  if( db->mallocFailed ){
    p->rc = SQLITE_NOMEM;
    return SQLITE_NOMEM;
  }

  if( p->pc<=0 && p->expired ){

    p->rc = SQLITE_SCHEMA;

    rc = SQLITE_ERROR;
    goto end_of_step;
  }
  if( p->pc<0 ){
    /* If there are no other statements currently running, then
    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt
    ** from interrupting a statement that has not yet started.
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
  sqlite3_mutex_enter(db->mutex);
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < 5
         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){
    sqlite3_reset(pStmt);
    v->expired = 0;
  }
  if( rc2!=SQLITE_OK && v->isPrepareV2 && db->pErr ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 
    ** into the database handle. This block copies the error message 
    ** from the database handle into the statement and sets the statement
    ** program counter to 0 to ensure that when the statement is 
    ** finalized or reset the parser error message is available via
    ** sqlite3_errmsg() and sqlite3_errcode().







|







429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
  sqlite3_mutex_enter(db->mutex);
  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
         && cnt++ < 5
         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){
    sqlite3_reset(pStmt);
    v->expired = 0;
  }
  if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){
    /* This case occurs after failing to recompile an sql statement. 
    ** The error message from the SQL compiler has already been loaded 
    ** into the database handle. This block copies the error message 
    ** from the database handle into the statement and sets the statement
    ** program counter to 0 to ensure that when the statement is 
    ** finalized or reset the parser error message is available via
    ** sqlite3_errmsg() and sqlite3_errcode().