/ Check-in [61cee3c0]
Login

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

Overview
Comment:Update the sqlite3_stmt_busy() function so that it correctly returns true for "ROLLBACK" statements that have been stepped but not yet reset.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:61cee3c0678f5abd9131a29ab946a5e71f55643e
User & Date: dan 2014-07-19 17:57:10
Context
2014-07-21
15:44
Allow the SQLITE_MAX_ATTACHED compile-time option to be larger than 62. The default limit on the number of attached databases remains 10. check-in: 1a817ae2 user: drh tags: trunk
2014-07-19
20:15
Add new ASCII mode to the shell capable of importing and exporting using the official unit and record separators (i.e. 0x1F and 0x1E, respectively). check-in: 7fe601ea user: mistachkin tags: asciiMode
17:57
Update the sqlite3_stmt_busy() function so that it correctly returns true for "ROLLBACK" statements that have been stepped but not yet reset. check-in: 61cee3c0 user: dan tags: trunk
17:49
Fix harmless compiler warnings in the showdb and showwal tools and in the unicode tokenizer of FTS3. check-in: 574cc8eb user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
}

/*
** Return true if the prepared statement is in need of being reset.
*/
int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
  Vdbe *v = (Vdbe*)pStmt;
  return v!=0 && v->pc>0 && v->magic==VDBE_MAGIC_RUN;
}

/*
** Return a pointer to the next prepared statement after pStmt associated
** with database connection pDb.  If pStmt is NULL, return the first
** prepared statement for the database connection.  Return NULL if there
** are no more.







|







1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
}

/*
** Return true if the prepared statement is in need of being reset.
*/
int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
  Vdbe *v = (Vdbe*)pStmt;
  return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
}

/*
** Return a pointer to the next prepared statement after pStmt associated
** with database connection pDb.  If pStmt is NULL, return the first
** prepared statement for the database connection.  Return NULL if there
** are no more.

Changes to src/vdbeaux.c.

2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
static void checkActiveVdbeCnt(sqlite3 *db){
  Vdbe *p;
  int cnt = 0;
  int nWrite = 0;
  int nRead = 0;
  p = db->pVdbe;
  while( p ){
    if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){
      cnt++;
      if( p->readOnly==0 ) nWrite++;
      if( p->bIsReader ) nRead++;
    }
    p = p->pNext;
  }
  assert( cnt==db->nVdbeActive );







|







2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
static void checkActiveVdbeCnt(sqlite3 *db){
  Vdbe *p;
  int cnt = 0;
  int nWrite = 0;
  int nRead = 0;
  p = db->pVdbe;
  while( p ){
    if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){
      cnt++;
      if( p->readOnly==0 ) nWrite++;
      if( p->bIsReader ) nRead++;
    }
    p = p->pNext;
  }
  assert( cnt==db->nVdbeActive );

Changes to test/capi3d.test.

139
140
141
142
143
144
145
146





































147
  sqlite3_stmt_busy $STMT
} {0}

do_test capi3d-3.99 {
  sqlite3_finalize $STMT
  sqlite3_stmt_busy 0
} {0}






































finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  sqlite3_stmt_busy $STMT
} {0}

do_test capi3d-3.99 {
  sqlite3_finalize $STMT
  sqlite3_stmt_busy 0
} {0}

#--------------------------------------------------------------------------
# Test the sqlite3_stmt_busy() function with ROLLBACK statements.
#
reset_db

do_execsql_test capi3d-4.1 {
  CREATE TABLE t4(x,y);
  BEGIN;
}

do_test capi3d-4.2.1 {
  breakpoint
  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
} {0 {}}

do_test capi3d-4.2.6 {
  sqlite3_finalize $::s1
} {SQLITE_OK}


finish_test