/ Check-in [047d3475]
Login

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

Overview
Comment:Fix the sqlite3_stmt_busy() interface so that it always returns FALSE after the statement has returned SQLITE_DONE, even for ROLLBACK statements. Clarify the documentation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 047d3475e93d08cf172ad02404a690d5b0c1b833
User & Date: drh 2015-07-31 18:59:56
Context
2015-07-31
19:52
Add support for "fossil deltas" to RBU and "sqldiff --rbu". check-in: e26ef165 user: dan tags: trunk
18:59
Fix the sqlite3_stmt_busy() interface so that it always returns FALSE after the statement has returned SQLITE_DONE, even for ROLLBACK statements. Clarify the documentation. check-in: 047d3475 user: drh tags: trunk
17:48
Remove a duplicate "typedef struct Fts5Global Fts5Global;" from fts5_main.c (duplicate is in fts5Int.h). check-in: 54a771fe user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

  3369   3369   
  3370   3370   /*
  3371   3371   ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  3372   3372   ** METHOD: sqlite3_stmt
  3373   3373   **
  3374   3374   ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  3375   3375   ** [prepared statement] S has been stepped at least once using 
  3376         -** [sqlite3_step(S)] but has not run to completion and/or has not 
         3376  +** [sqlite3_step(S)] but has neither run to completion (returned
         3377  +** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  3377   3378   ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  3378   3379   ** interface returns false if S is a NULL pointer.  If S is not a 
  3379   3380   ** NULL pointer and is not a pointer to a valid [prepared statement]
  3380   3381   ** object, then the behavior is undefined and probably undesirable.
  3381   3382   **
  3382   3383   ** This interface can be used in combination [sqlite3_next_stmt()]
  3383   3384   ** to locate all prepared statements associated with a database 

Changes to src/vdbe.c.

  3004   3004         assert( desiredAutoCommit==1 );
  3005   3005         sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
  3006   3006         db->autoCommit = 1;
  3007   3007       }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
  3008   3008         goto vdbe_return;
  3009   3009       }else{
  3010   3010         db->autoCommit = (u8)desiredAutoCommit;
  3011         -      if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
  3012         -        p->pc = (int)(pOp - aOp);
  3013         -        db->autoCommit = (u8)(1-desiredAutoCommit);
  3014         -        p->rc = rc = SQLITE_BUSY;
  3015         -        goto vdbe_return;
  3016         -      }
         3011  +    }
         3012  +    if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
         3013  +      p->pc = (int)(pOp - aOp);
         3014  +      db->autoCommit = (u8)(1-desiredAutoCommit);
         3015  +      p->rc = rc = SQLITE_BUSY;
         3016  +      goto vdbe_return;
  3017   3017       }
  3018   3018       assert( db->nStatement==0 );
  3019   3019       sqlite3CloseSavepoints(db);
  3020   3020       if( p->rc==SQLITE_OK ){
  3021   3021         rc = SQLITE_DONE;
  3022   3022       }else{
  3023   3023         rc = SQLITE_ERROR;

Changes to test/capi3d.test.

   157    157   do_test capi3d-4.2.1 {
   158    158     set ::s1 [sqlite3_prepare_v2 db "ROLLBACK" -1 notused]
   159    159     sqlite3_step $::s1
   160    160   } {SQLITE_DONE}
   161    161   
   162    162   do_test capi3d-4.2.2 {
   163    163     sqlite3_stmt_busy $::s1
   164         -} {1}
          164  +} {0}
   165    165   
   166    166   do_catchsql_test capi3d-4.2.3 {
   167    167     VACUUM
   168         -} {1 {cannot VACUUM - SQL statements in progress}}
          168  +} {0 {}}
   169    169   
   170    170   do_test capi3d-4.2.4 {
   171    171     sqlite3_reset $::s1
   172    172   } {SQLITE_OK}
   173    173   
   174    174   do_catchsql_test capi3d-4.2.5 {
   175    175     VACUUM