Add the SQLITE_OMIT_AUTORESET compile-time option which if enabled causes

the sqlite3_step() routine to return SQLITE_MISUSE if it is called after
it has previously returned anything other than SQLITE_ROW, SQLITE_BUSY, or
SQLITE_LOCKED.

FossilOrigin-Name: 053ce76deb356d31358454507ba94947142e20ca
This commit is contained in:
drh 2011-01-17 17:42:37 +00:00
parent c5aae5c90b
commit 602acb4871
9 changed files with 76 additions and 32 deletions

0
install-sh Normal file → Executable file
View File

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Add\sback\san\sALWAYS()\sto\sregain\sfull\stest\scoverage.
D 2011-01-17T02:24:12.610
C Add\sthe\sSQLITE_OMIT_AUTORESET\scompile-time\soption\swhich\sif\senabled\scauses\nthe\ssqlite3_step()\sroutine\sto\sreturn\sSQLITE_MISUSE\sif\sit\sis\scalled\safter\nit\shas\spreviously\sreturned\sanything\sother\sthan\sSQLITE_ROW,\sSQLITE_BUSY,\sor\nSQLITE_LOCKED.
D 2011-01-17T17:42:37.670
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -100,7 +100,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F main.mk 05d0f3475dd331896bd607cfb45c5e21b94589ad
F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a
@ -128,7 +128,7 @@ F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4
F src/build.c 00a327120d81ace6267e714ae8010c997d55de5d
F src/callback.c a1d1b1c9c85415dff013af033e2fed9c8382d33b
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 4f3aadad62c6c9f0d4e5a96718516ac4e3c598df
F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4
F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b
F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd
F src/expr.c 1810f3056b11de99cc10e24629edf00e5fbd3a75
@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c 8a7ba246b0b4bb45df7fbc52681728a0e3deaaa7
F src/shell.c 83c6f0cc5a79a081c7b9ddfe4f557b47e0bad976
F src/sqlite.h.in e93b13af0879dcc56471fc7639dc8efa7d0de832
F src/sqlite.h.in ca8b7b6329937e54a2cce2b897c3a4fa2ec5b3fb
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
F src/sqliteInt.h 3ef5fc89a4c9755a08a68de107493785a284e27c
F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44
@ -199,7 +199,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c 55918873f0a2ebbd5b52417319987f9f99c401fa
F src/test_config.c 9f025a7f3686c94e82dc6d6bd3cbf0f89cd67487
F src/test_demovfs.c 0aed671636735116fc872c5b03706fd5612488b5
F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
F src/test_func.c 13b582345fb1185a93e46c53310fae8547dcce20
@ -234,7 +234,7 @@ F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f
F src/vdbe.c 5d310eaf1a4d8383602126fa82e01291ab7d3cf3
F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2
F src/vdbeInt.h 6e6f28e9bccc6c703dca1372fd661c57b5c15fb0
F src/vdbeapi.c 0f898cc77099f0b0b4d6a045e905c3501f9c8b27
F src/vdbeapi.c 69c82283ab2b64c0c37a07799d771d4058330743
F src/vdbeaux.c 33448d23b857654dd69ed2103611f5c733606f68
F src/vdbeblob.c 18955f0ee6b133cd08e1592010cb9a6b11e9984c
F src/vdbemem.c 411649a35686f54268ccabeda175322c4697f5a6
@ -296,7 +296,7 @@ F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983
F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0
F test/cache.test 754baab2f18089fc9bcba7afaeb4dc907c6c6de2
F test/capi2.test 00032d7504b9c14f1b36331670c5e7b0f73e3c5d
F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360
F test/capi3.test 1945a2ba75e3f4c49d5beb8fc092115b6292d471
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7
@ -384,7 +384,7 @@ F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6
F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e
F test/filefmt.test f77c92141960b7933bc6691631d2ad62257ef40a
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
F test/fkey2.test e028cd80aa0bd38541c99214e3ba2dfccadffe6f
F test/fkey2.test 080969fe219b3b082b0e097ac18c6af2e5b0631f
F test/fkey3.test 42f88d6048d8dc079e2a8cf7baad1cc1483a7620
F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
@ -899,14 +899,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 612e2599d3e1a17c268402fce018a53dee6dffe1
R abd1ddc0cbd80cba70c03c409d8a0a78
P b93f6f3e679c7710f42580a8dd9ce43136376c1d
R 6dc66aed498487341b067c32818edd59
U drh
Z 5deab45f651e1cc367fa113ca51b94f5
Z e50fa3b22eb702afe6aa782a8e86a0c4
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFNM6hQoxKgR168RlERAnmGAJ9VtK6Ab9TW+dU+V6QdM+ALE833cQCfSTjg
+uTHGM0YHNJB4Zg+fvaxE9U=
=b8FC
iD8DBQFNNH+RoxKgR168RlERArkrAKCNKjNRwcXopvvMlZTssdPU/VXRNgCfWDwM
8nE9/3MAUpfOEzl9WxkBTP4=
=RWjs
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
b93f6f3e679c7710f42580a8dd9ce43136376c1d
053ce76deb356d31358454507ba94947142e20ca

View File

@ -174,6 +174,9 @@ static const char * const azCompileOpt[] = {
#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
"OMIT_AUTOMATIC_INDEX",
#endif
#ifdef SQLITE_OMIT_AUTORESET
"OMIT_AUTORESET",
#endif
#ifdef SQLITE_OMIT_AUTOVACUUM
"OMIT_AUTOVACUUM",
#endif

View File

@ -3078,13 +3078,17 @@ const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
** 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].
** For all versions of SQLite up to and including 3.6.23.1, a call to
** [sqlite3_reset()] was required after sqlite3_step() returned anything
** other than [SQLITE_ROW] before any subsequent invocation of
** sqlite3_step(). Failure to reset the prepared statement using
** [sqlite3_reset()] 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]. This is not considered a compatibility
** break because any application that ever receives an SQLITE_MISUSE error
** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option
** can be used to restore the legacy behavior.
**
** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
** API always returns a generic error code, [SQLITE_ERROR], following any

View File

@ -133,6 +133,12 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "autoindex", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_AUTORESET
Tcl_SetVar2(interp, "sqlite_options", "autoreset", "0", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "autoreset", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_AUTOVACUUM
Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY);
#else

View File

@ -345,11 +345,30 @@ static int sqlite3Step(Vdbe *p){
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_step() after any error or after SQLITE_DONE. But beginning
** with version 3.7.0, we changed this so that sqlite3_reset() would
** be called automatically instead of throwing the SQLITE_MISUSE error.
** This "automatic-reset" change is not technically an incompatibility,
** since any application that receives an SQLITE_MISUSE is broken by
** definition.
**
** Nevertheless, some published applications that were originally written
** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE
** returns, and the so were broken by the automatic-reset change. As a
** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
** legacy behavior of returning SQLITE_MISUSE for cases where the
** previous sqlite3_step() returned something other than a SQLITE_LOCKED
** or SQLITE_BUSY error.
*/
#ifdef SQLITE_OMIT_AUTORESET
if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){
sqlite3_reset((sqlite3_stmt*)p);
}else{
return SQLITE_MISUSE_BKPT;
}
#else
sqlite3_reset((sqlite3_stmt*)p);
#endif
}
/* Check that malloc() has not failed. If it has, return early. */

View File

@ -74,9 +74,15 @@ do_test capi2-1.7 {
# This used to be SQLITE_MISUSE. But now we automatically reset prepared
# statements.
do_test capi2-1.8 {
sqlite3_step $VM
} {SQLITE_ROW}
ifcapable autoreset {
do_test capi2-1.8 {
sqlite3_step $VM
} {SQLITE_ROW}
} else {
do_test capi2-1.8 {
sqlite3_step $VM
} {SQLITE_MISUSE}
}
# Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot
# be interrogated for more information. However in v3, since the column

View File

@ -1414,9 +1414,15 @@ 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}
ifcapable autoreset {
do_test fkey2-17.1.3 {
sqlite3_step $STMT
} {SQLITE_CONSTRAINT}
} else {
do_test fkey2-17.1.3 {
sqlite3_step $STMT
} {SQLITE_MISUSE}
}
do_test fkey2-17.1.4 {
sqlite3_finalize $STMT
} {SQLITE_CONSTRAINT}