SQLite

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 Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

3369
3370
3371
3372
3373
3374
3375
3376

3377
3378
3379
3380
3381
3382
3383

/*
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
** METHOD: sqlite3_stmt
**
** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
** [prepared statement] S has been stepped at least once using 
** [sqlite3_step(S)] but has not run to completion and/or has not 

** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
** interface returns false if S is a NULL pointer.  If S is not a 
** NULL pointer and is not a pointer to a valid [prepared statement]
** object, then the behavior is undefined and probably undesirable.
**
** This interface can be used in combination [sqlite3_next_stmt()]
** to locate all prepared statements associated with a database 







|
>







3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384

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

Changes to src/vdbe.c.

3004
3005
3006
3007
3008
3009
3010

3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
      assert( desiredAutoCommit==1 );
      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
      db->autoCommit = 1;
    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
      goto vdbe_return;
    }else{
      db->autoCommit = (u8)desiredAutoCommit;

      if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
        p->pc = (int)(pOp - aOp);
        db->autoCommit = (u8)(1-desiredAutoCommit);
        p->rc = rc = SQLITE_BUSY;
        goto vdbe_return;
      }
    }
    assert( db->nStatement==0 );
    sqlite3CloseSavepoints(db);
    if( p->rc==SQLITE_OK ){
      rc = SQLITE_DONE;
    }else{
      rc = SQLITE_ERROR;







>
|
|
|
|
|
<







3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016

3017
3018
3019
3020
3021
3022
3023
      assert( desiredAutoCommit==1 );
      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
      db->autoCommit = 1;
    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
      goto vdbe_return;
    }else{
      db->autoCommit = (u8)desiredAutoCommit;
    }
    if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
      p->pc = (int)(pOp - aOp);
      db->autoCommit = (u8)(1-desiredAutoCommit);
      p->rc = rc = SQLITE_BUSY;
      goto vdbe_return;

    }
    assert( db->nStatement==0 );
    sqlite3CloseSavepoints(db);
    if( p->rc==SQLITE_OK ){
      rc = SQLITE_DONE;
    }else{
      rc = SQLITE_ERROR;

Changes to test/capi3d.test.

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
do_test capi3d-4.2.1 {
  set ::s1 [sqlite3_prepare_v2 db "ROLLBACK" -1 notused]
  sqlite3_step $::s1
} {SQLITE_DONE}

do_test capi3d-4.2.2 {
  sqlite3_stmt_busy $::s1
} {1}

do_catchsql_test capi3d-4.2.3 {
  VACUUM
} {1 {cannot VACUUM - SQL statements in progress}}

do_test capi3d-4.2.4 {
  sqlite3_reset $::s1
} {SQLITE_OK}

do_catchsql_test capi3d-4.2.5 {
  VACUUM







|



|







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
do_test capi3d-4.2.1 {
  set ::s1 [sqlite3_prepare_v2 db "ROLLBACK" -1 notused]
  sqlite3_step $::s1
} {SQLITE_DONE}

do_test capi3d-4.2.2 {
  sqlite3_stmt_busy $::s1
} {0}

do_catchsql_test capi3d-4.2.3 {
  VACUUM
} {0 {}}

do_test capi3d-4.2.4 {
  sqlite3_reset $::s1
} {SQLITE_OK}

do_catchsql_test capi3d-4.2.5 {
  VACUUM