Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change sqlite3_step() so that it automatically calls sqlite3_reset() instead of returning SQLITE_MISUSE when invoked on a prepared statement that previously returned any value other than SQLITE_ROW. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3e646e3f4cd0ca288e444561e951cecf |
User & Date: | drh 2010-04-17 12:53:20.000 |
References
2010-04-17
| ||
15:45 | Merge with trunk commit [3e646e3f4c]. (check-in: 43463970f5 user: dan tags: wal) | |
Context
2010-04-23
| ||
14:29 | Merge of notify.c changes from experimental. Reset stored blocking connection when registered unlock_notify callback is cleared. (check-in: e79dac3c2f user: shaneh tags: trunk) | |
2010-04-17
| ||
15:45 | Merge with trunk commit [3e646e3f4c]. (check-in: 43463970f5 user: dan tags: wal) | |
12:53 | Change sqlite3_step() so that it automatically calls sqlite3_reset() instead of returning SQLITE_MISUSE when invoked on a prepared statement that previously returned any value other than SQLITE_ROW. (check-in: 3e646e3f4c user: drh tags: trunk) | |
2010-04-15
| ||
23:24 | Disable query flattening when the outer query is a compound SELECT and the inner query has a LIMIT clause. Ticket [02a8e81d44]. (check-in: f96782b389 user: drh tags: trunk) | |
Changes
Changes to src/sqlite.h.in.
︙ | ︙ | |||
2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 | ** [SQLITE_MISUSE] means that the this routine was called inappropriately. ** Perhaps it was called on a [prepared statement] that has ** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could ** be the case that the same database connection is being used by two or ** more threads at the same moment in time. ** ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements | > > > > > > > > | 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 | ** [SQLITE_MISUSE] means that the this routine was called inappropriately. ** Perhaps it was called on a [prepared statement] that has ** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could ** be the case that the same database connection is being used by two or ** more threads at the same moment in time. ** ** For all versions of SQLite up to and including 3.6.23.1, it was required ** after sqlite3_step() returned anything other than [SQLITE_ROW] that ** [sqlite3_reset()] be called before any subsequent invocation of ** sqlite3_step(). Failure to invoke [sqlite3_reset()] in this way would ** result in an [SQLITE_MISUSE] return from sqlite3_step(). But after ** version 3.6.23.1, sqlite3_step() began calling [sqlite3_reset()] ** automatically in this circumstance rather than returning [SQLITE_MISUSE]. ** ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements |
︙ | ︙ |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
317 318 319 320 321 322 323 | */ static int sqlite3Step(Vdbe *p){ sqlite3 *db; int rc; assert(p); if( p->magic!=VDBE_MAGIC_RUN ){ | | | | > > > | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | */ static int sqlite3Step(Vdbe *p){ sqlite3 *db; int rc; assert(p); if( p->magic!=VDBE_MAGIC_RUN ){ /* We used to require that sqlite3_reset() be called before retrying ** sqlite3_step() after any error. But after 3.6.23, we changed this ** so that sqlite3_reset() would be called automatically instead of ** throwing the error. */ sqlite3_reset((sqlite3_stmt*)p); } /* Check that malloc() has not failed. If it has, return early. */ db = p->db; if( db->mallocFailed ){ p->rc = SQLITE_NOMEM; return SQLITE_NOMEM; |
︙ | ︙ |
Changes to test/capi2.test.
︙ | ︙ | |||
67 68 69 70 71 72 73 | } {name rowid text INTEGER} do_test capi2-1.6 { sqlite3_step $VM } {SQLITE_DONE} do_test capi2-1.7 { list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM] } {2 {} {name rowid text INTEGER}} | > > > | | > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } {name rowid text INTEGER} do_test capi2-1.6 { sqlite3_step $VM } {SQLITE_DONE} do_test capi2-1.7 { list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM] } {2 {} {name rowid text INTEGER}} # This used to be SQLITE_MISUSE. But now we automatically reset prepared # statements. do_test capi2-1.8 { sqlite3_step $VM } {SQLITE_ROW} # Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot # be interrogated for more information. However in v3, since the column # count, names and types are determined at compile time, these are still # accessible after an SQLITE_MISUSE error. do_test capi2-1.9 { sqlite3_reset $VM list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM] } {2 {} {name rowid text INTEGER}} do_test capi2-1.10 { sqlite3_data_count $VM } {0} do_test capi2-1.11 { |
︙ | ︙ |
Changes to test/fkey2.test.
︙ | ︙ | |||
1406 1407 1408 1409 1410 1411 1412 | } {1} do_test fkey2-17.1.2 { set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy] sqlite3_step $STMT } {SQLITE_CONSTRAINT} do_test fkey2-17.1.3 { sqlite3_step $STMT | | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | } {1} do_test fkey2-17.1.2 { set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy] sqlite3_step $STMT } {SQLITE_CONSTRAINT} do_test fkey2-17.1.3 { sqlite3_step $STMT } {SQLITE_CONSTRAINT} do_test fkey2-17.1.4 { sqlite3_finalize $STMT } {SQLITE_CONSTRAINT} do_test fkey2-17.1.5 { execsql { INSERT INTO one VALUES(2, 3, 4); INSERT INTO one VALUES(3, 4, 5); |
︙ | ︙ |