]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove the sqlite3_reoptimize() API. The same functionality is now provided automatic...
authordan <dan@noemail.net>
Mon, 19 Oct 2009 18:11:09 +0000 (18:11 +0000)
committerdan <dan@noemail.net>
Mon, 19 Oct 2009 18:11:09 +0000 (18:11 +0000)
FossilOrigin-Name: 2c50b3d5aab7cd8cc841d61f8c3b2b34d2f0b54b

manifest
manifest.uuid
src/sqlite.h.in
src/tclsqlite.c
src/test1.c
src/vdbe.h
src/vdbeInt.h
src/vdbeapi.c
src/vdbeaux.c
src/where.c
test/analyze3.test

index 27fc10a44715404208da3f553ee00c94a7d331a3..25f242ed0e7d397b7b612e77ee4ced623065c6ae 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C When\sgenerating\sWHERE\sclause\sterms\sinternally\sfor\sNATURAL\sand\sUSING\sjoins,\sidentify\sthe\stable\sby\sits\sposition\sin\sthe\sFROM\slist,\snot\sby\sits\sname\sor\salias.\sFix\sfor\s[b73fb0bd64].
-D 2009-10-19T15:52:33
+C Remove\sthe\ssqlite3_reoptimize()\sAPI.\sThe\ssame\sfunctionality\sis\snow\sprovided\sautomatically\sto\squeries\sprepared\susing\sprepare_v2().
+D 2009-10-19T18:11:10
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -162,14 +162,14 @@ F src/resolve.c 3ac31c7181fab03732125fdedf7c2091a5c07f1b
 F src/rowset.c c64dafba1f9fd876836c8db8682966b9d197eb1f
 F src/select.c cbe366a0ce114856e66f5daf0f848d7c48a88298
 F src/shell.c 270231b3f587f1f86391b9994fdfcd5d472c3fdf
-F src/sqlite.h.in 02edbab15c4556dc562f6f6b9b9d322e7719c800
+F src/sqlite.h.in 8e1ccddb12b5e983d0a17e1f1477c72b0a72dd84
 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
 F src/sqliteInt.h 3b00a3ce79e60c5a47c342b738c8b75013f3ec84
 F src/sqliteLimit.h 38b2fffcd01faeaeaadea71b2b47695a81580c8b
 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
 F src/table.c cc86ad3d6ad54df7c63a3e807b5783c90411a08d
-F src/tclsqlite.c 00cefd8c37cc934e13cb5238ed53f090391aa99a
-F src/test1.c 92ccdb2e68f8c5b529bfbf833b759b5fa39a88f7
+F src/tclsqlite.c 97e1d25695e47897294bf84f689191052a00fefa
+F src/test1.c 2232a39540a6b72f3be8f84b34d1ca0714f92aee
 F src/test2.c 0de743ec8890ca4f09e0bce5d6d5a681f5957fec
 F src/test3.c 2445c2beb5e7a0c91fd8136dc1339ec369a24898
 F src/test4.c b5fd530f02a6a0dbffb23be202168a690985dedd
@@ -207,15 +207,15 @@ F src/utf.c 99cf927eabb104621ba889ac0dd075fc1657ad30
 F src/util.c 59d4e9456bf1fe581f415a783fa0cee6115c8f35
 F src/vacuum.c f2347520907ee4ec867c9b804d24456b0fd912a7
 F src/vdbe.c f0d6e7dbd4515758c188c9dd7025eb9dfcf021e0
-F src/vdbe.h 1fb725c38df7f79dc60e9a61cb368152d9457e3c
-F src/vdbeInt.h aafda2e9761298e12ef0a3e8b5caed9aaf9c7592
-F src/vdbeapi.c a7669f434f1fb53457343e7e85d06d695f7bb4e8
-F src/vdbeaux.c bd26b3c765dff7c0bc089f550d82510a37f24d6a
+F src/vdbe.h 3fedb2121d026dd127350d33e875a49cf05df2e8
+F src/vdbeInt.h 8e07f4356dd5bfe03ac5991338e59b68c9b3c717
+F src/vdbeapi.c 1124f16bbb1d8c9682d9aaead78b87826c39b262
+F src/vdbeaux.c fc032b050e0500000de534b2b0f0c63642459b8f
 F src/vdbeblob.c 9bfaeab22e261a6a7b6df04e7faaf7d6dfdbef5a
 F src/vdbemem.c 7055a2941a7802094f4704cedc7a28cc88a23749
 F src/vtab.c 3e54fe39374e5feb8b174de32a90e7a21966025d
 F src/walker.c 1edca756275f158b80f20eb6f104c8d3fcc96a04
-F src/where.c 9e8bb75c39adfd85fa0bbfa803836de9485716a8
+F src/where.c acf24024bc00d84bfb83c82daa1d72a907cc8456
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -226,7 +226,7 @@ F test/alter4.test 9386ffd1e9c7245f43eca412b2058d747509cc1f
 F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
 F test/analyze.test ad5329098fe4de4a96852231d53e3e9e6283ad4b
 F test/analyze2.test a2ad7b0a4e13801ee3968fe70f22aff52326569c
-F test/analyze3.test 2f00779be9c1637dd72793de755a17722995d836
+F test/analyze3.test 5c87ca746d3cf52d5172cfbc4890695d526f1e90
 F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb
 F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6
 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e
@@ -760,7 +760,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff x
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f x
-P ca3e41b0574cfd8d971c2be2114e58273a531970
-R cd248a323e6fa543f7b6dc5498e63431
+P 6fe6371175482d38ac4aeea994c7b20c18b7de01
+R f87103fb96f6ce262ce840e0ef0a5e44
 U dan
-Z ef39b99c6d9e839e5c682ef365e81b03
+Z 5a02708d47ce169d35256d399f3d9643
index a20f681b5c54b27971d624819695fe6f1df61b21..d6f052d603ac8ac649395f8cbb32cab9df4ade63 100644 (file)
@@ -1 +1 @@
-6fe6371175482d38ac4aeea994c7b20c18b7de01
\ No newline at end of file
+2c50b3d5aab7cd8cc841d61f8c3b2b34d2f0b54b
\ No newline at end of file
index a2e0382f57ff2dad8a0e19011421be242ddcc34b..877c2c7f286f34907e98910b2033fd6a53a98668 100644 (file)
@@ -5743,37 +5743,6 @@ int sqlite3_unlock_notify(
 */
 int sqlite3_strnicmp(const char *, const char *, int);
 
-/*
-** CAPI3REF: Optimizing for Bound Parameters
-** EXPERIMENTAL
-**
-** If possible, optimize the SQL statement passed as the only argument
-** for the values currently bound to the statements SQL variables.
-**
-** SQLite currently contains two optimizations that depend upon the values 
-** of SQL literals specified as part of a query:
-**
-** <ul>
-**   <li> The [range query optimization], and 
-**   <li> The [LIKE optimization].
-** </ul>
-**
-** Normally, queries that use an SQL [parameter] in the relevant expression 
-** or expressions may not benefit from either of the above optimizations.
-** This function may be used to overcome this limitation.
-**
-** Calling sqlite3_reoptimize() on a statement handle after values have been
-** bound to its SQL parameters causes SQLite to inspect the query and the
-** bound values to determine if either of the above optimizations may be
-** applied to it. If so, a new query plan is formulated to take advantage
-** of the optimizations.
-**
-** If it is determined that neither of the above optimizations may be
-** profitably applied to the query based on the values bound to SQL 
-** parameters, this function is a no-op.
-*/
-int sqlite3_reoptimize(sqlite3_stmt *pStmt);
-
 /*
 ** Undo the hack that converts floating point types to integer for
 ** builds on processors without floating point support.
index 3e7a513e77db0f5345d197a5e0a682cf3c21aace..76e0ee09f03f170d3192cc649c7aff7fe3e08a31 100644 (file)
@@ -1129,15 +1129,6 @@ static int dbPrepareAndBind(
   pPreStmt->nParm = iParm;
   *ppPreStmt = pPreStmt;
 
-  /* Call sqlite3_reoptimize() to optimize the statement according to
-  ** the values just bound to it. If SQLITE_ENABLE_STAT2 is not defined
-  ** or the statement will not benefit from re-optimization, this 
-  ** call is a no-op.  */
-  if( SQLITE_OK!=sqlite3_reoptimize(pPreStmt->pStmt) ){
-    Tcl_SetObjResult(interp, dbTextToObj(sqlite3_errmsg(pDb->db)));
-    return TCL_ERROR;
-  }
-
   return TCL_OK;
 }
 
index 7c0b2ad3d55471bb3a330a2560c249b3ddb78ea0..6ea48e6713e4327170fcf31d8e1c704b248ae681 100644 (file)
@@ -2049,34 +2049,6 @@ static int test_stmt_status(
   return TCL_OK;
 }
 
-/*
-** Usage:  sqlite3_reoptimize  STMT
-**
-** Call sqlite3_reoptimize() on the statement handle passed as the
-** only parameter. Return a string representing the value returned by
-** sqlite3_reoptimize - "SQLITE_OK", "SQLITE_MISUSE" etc.
-*/
-static int test_reoptimize(
-  void * clientData,
-  Tcl_Interp *interp,
-  int objc,
-  Tcl_Obj *CONST objv[]
-){
-  sqlite3_stmt *pStmt;
-  int rc;
-
-  if( objc!=2 ){
-    Tcl_AppendResult(interp, "wrong # args: should be \"", 
-       Tcl_GetString(objv[0]), " STMT", 0);
-    return TCL_ERROR;
-  }
-  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
-  rc = sqlite3_reoptimize(pStmt);
-  Tcl_ResetResult(interp);
-  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
-  return TCL_OK;
-}
-
 /*
 ** Usage:  sqlite3_next_stmt  DB  STMT
 **
@@ -5031,7 +5003,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
      { "sqlite3_step",                  test_step          ,0 },
      { "sqlite3_sql",                   test_sql           ,0 },
      { "sqlite3_next_stmt",             test_next_stmt     ,0 },
-     { "sqlite3_reoptimize",            test_reoptimize    ,0 },
 
      { "sqlite3_release_memory",        test_release_memory,     0},
      { "sqlite3_soft_heap_limit",       test_soft_heap_limit,    0},
index 1ff4d610a2dd4e1362f86e84ed6fa6c21bf41b49..23d8458d09c4561225a42e51fa118b0e085e058f 100644 (file)
@@ -203,7 +203,7 @@ void sqlite3VdbeSwap(Vdbe*,Vdbe*);
 VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
 void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int);
 sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
-void sqlite3VdbeSetVarmask(Vdbe*,int,int);
+void sqlite3VdbeSetVarmask(Vdbe*, int);
 
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
 int sqlite3VdbeReleaseMemory(int);
index fabd78606020a27d884cdebf2116a35eae8ff76d..2b8bb5927bcd79778ee3240440b27357009499e2 100644 (file)
@@ -323,8 +323,6 @@ struct Vdbe {
 #endif
   VdbeFrame *pFrame;      /* Parent frame */
   int nFrame;             /* Number of frames in pFrame list */
-  u8 optimizable;         /* True if VM may benefit from sqlite3_reoptimize() */
-  u32 optmask;            /* Bitmask of vars that may be used by reoptimize() */
   u32 expmask;            /* Binding to these vars invalidates VM */
 };
 
index 107c1eb6ce4e29663c8a3d3ccad275bd20f2fbb3..12d7349acb6a44a447122f0bff5148cb2ceadfd7 100644 (file)
@@ -915,17 +915,10 @@ static int vdbeUnbind(Vdbe *p, int i){
   pVar->flags = MEM_Null;
   sqlite3Error(p->db, SQLITE_OK, 0);
 
-  /* If the bit corresponding to this variable is set in Vdbe.opmask, set 
-  ** the optimizable flag before returning. This tells the sqlite3_reoptimize()
-  ** function that the VM program may benefit from recompilation. 
-  **
-  ** If the bit in Vdbe.expmask is set, then binding a new value to this
-  ** variable invalidates the current query plan. This comes about when the
-  ** variable is the RHS of a LIKE or GLOB operator and the LIKE/GLOB is
-  ** able to use an index.  */
-  if( (i<32 && p->optmask & ((u32)1 << i)) || p->optmask==0xffffffff ){
-    p->optimizable = 1;
-  }
+  /* If the bit corresponding to this variable in Vdbe.expmask is set, then 
+  ** binding a new value to this variable invalidates the current query plan.
+  */
+  assert( p->isPrepareV2 || p->expmask==0 );
   if( (i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff ){
     p->expired = 1;
   }
@@ -1221,24 +1214,3 @@ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
   return v;
 }
 
-/*
-** If possible, optimize the statement for the current bindings.
-*/
-int sqlite3_reoptimize(sqlite3_stmt *pStmt){
-  int rc = SQLITE_OK;
-  Vdbe *v = (Vdbe *)pStmt;
-  sqlite3 *db = v->db;
-
-  sqlite3_mutex_enter(db->mutex);
-  if( v->isPrepareV2==0 || v->pc>0 ){
-    rc = SQLITE_MISUSE;
-  }else if( v->optimizable ){
-    rc = sqlite3Reprepare(v);
-    rc = sqlite3ApiExit(db, rc);
-  }
-  assert( rc!=SQLITE_OK || v->optimizable==0 );
-  sqlite3_mutex_leave(db->mutex);
-
-  return rc;
-}
-
index d25b633dd423e34dbd72e6479ab1bf661b5ac968..e524a53d7dc97ad1563b58a3b6a8187ab2cf313a 100644 (file)
@@ -53,13 +53,14 @@ Vdbe *sqlite3VdbeCreate(sqlite3 *db){
 ** Remember the SQL string for a prepared statement.
 */
 void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
+  assert( isPrepareV2==1 || isPrepareV2==0 );
   if( p==0 ) return;
 #ifdef SQLITE_OMIT_TRACE
   if( !isPrepareV2 ) return;
 #endif
   assert( p->zSql==0 );
   p->zSql = sqlite3DbStrNDup(p->db, z, n);
-  p->isPrepareV2 = isPrepareV2 ? 1 : 0;
+  p->isPrepareV2 = isPrepareV2;
 }
 
 /*
@@ -3053,13 +3054,12 @@ sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
 ** to sqlite3_reoptimize() that re-preparing the statement may result
 ** in a better query plan.
 */
-void sqlite3VdbeSetVarmask(Vdbe *v, int iVar, int isExpire){
-  u32 *mask = (isExpire ? &v->expmask : &v->optmask);
+void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
   assert( iVar>0 );
   if( iVar>32 ){
-    *mask = 0xffffffff;
+    v->expmask = 0xffffffff;
   }else{
-    *mask |= ((u32)1 << (iVar-1));
+    v->expmask |= ((u32)1 << (iVar-1));
   }
 }
 
index 53ec26b84194557a2e7bea4f4e07d22788634f8c..f9cb075704a46ca76153eb858a4cc002b1bfe2f5 100644 (file)
@@ -671,7 +671,7 @@ static int isLikeOrGlob(
     if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
       z = (char *)sqlite3_value_text(pVal);
     }
-    sqlite3VdbeSetVarmask(pParse->pVdbe, pRight->iColumn, 0);
+    sqlite3VdbeSetVarmask(pParse->pVdbe, pRight->iColumn);
     assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
   }else if( op==TK_STRING ){
     z = pRight->u.zToken;
@@ -689,7 +689,7 @@ static int isLikeOrGlob(
       *ppPrefix = pPrefix;
       if( op==TK_VARIABLE ){
         Vdbe *v = pParse->pVdbe;
-        sqlite3VdbeSetVarmask(v, pRight->iColumn, 1);
+        sqlite3VdbeSetVarmask(v, pRight->iColumn);
         if( *pisComplete && pRight->u.zToken[1] ){
           /* If the rhs of the LIKE expression is a variable, and the current
           ** value of the variable means there is no need to invoke the LIKE
@@ -2045,7 +2045,7 @@ static int valueFromExpr(
    || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
   ){
     int iVar = pExpr->iColumn;
-    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar, 0);
+    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
     *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
     return SQLITE_OK;
   }
index 2c56ff742f2ff9df6a2d2773a511bd76218675d0..65d6dfe2f1443674a122c811d2fedd516e02d960 100644 (file)
@@ -10,7 +10,8 @@
 #***********************************************************************
 #
 # This file implements regression tests for SQLite library. This file 
-# implements tests for the sqlite3_reoptimize() functionality.
+# implements tests for range and LIKE constraints that use bound variables
+# instead of literal constant arguments.
 #
 
 set testdir [file dirname $argv0]
@@ -32,12 +33,12 @@ ifcapable !stat2 {
 #               in the same way as constants when planning queries that
 #               use LIKE expressions in the WHERE clause.
 #
-# analyze3-3.*: Test that sqlite3_reoptimize() is a no-op when there is
-#               no way for re-preparing the query to produce a superior 
-#               query plan.
+# analyze3-3.*: Test that binding to a variable does not invalidate the 
+#               query plan when there is no way in which replanning the
+#               query may produce a superior outcome.
 #
 # analyze3-4.*: Test that SQL or authorization callback errors occuring
-#               within sqlite3_reoptimize() are handled correctly.
+#               within sqlite3Reprepare() are handled correctly.
 #
 
 proc getvar {varname} { uplevel #0 set $varname }
@@ -69,8 +70,7 @@ proc sf_execsql {sql {db db}} {
 #
 # analyze3-1.1.4 - 3.1.9
 #   Show that using SQL variables produces the same results as using
-#   literal values to constrain the range scan. This works because the
-#   Tcl interface always calls [sqlite3_reoptimize] after binding values.
+#   literal values to constrain the range scan.
 #
 #   These tests also check that the compiler code considers column 
 #   affinities when estimating the number of rows scanned by the "use 
@@ -267,21 +267,9 @@ do_test analyze3-2.5 {
 
 
 #-------------------------------------------------------------------------
-# This block of tests checks that sqlite3_reoptimize() is a no-op if 
-# the values bound to any parameters that may affect the query plan
-# have not changed since the statement was last compiled.
-#
-# It is possible to tell if sqlite3_reoptimize() is a no-op by registering
-# an authorization callback. If the auth callback is not invoked from
-# within a give call to reoptimize(), then it must have been a no-op.
-#
-# Also test that:
-#
-#   * sqlite3_reoptimize() returns SQLITE_MISUSE if called on a statement
-#     that was prepared using the legacy sqlite3_prepare() interface,
-#
-#   * sqlite3_reoptimize() returns SQLITE_MISUSE if called on a statement
-#     that is not in the "reset" state.
+# This block of tests checks that statements are correctly marked as
+# expired when the values bound to any parameters that may affect the 
+# query plan are modified.
 #
 drop_all_tables
 db auth auth
@@ -290,15 +278,6 @@ proc auth {args} {
   return SQLITE_OK
 }
 
-# Return true if calling reoptimize() on the statement handle passed 
-# as an argument causes the statement to be recompiled.
-#
-proc test_reoptimize {stmt} {
-  set ::auth 0
-  sqlite3_reoptimize $stmt
-  set ::auth
-}
-
 do_test analyze3-3.1 {
   execsql {
     BEGIN;
@@ -314,76 +293,47 @@ do_test analyze3-3.1 {
 
 do_test analyze3-3.2.1 {
   set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b>?" -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.2.2 {
   sqlite3_bind_text $S 1 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
-do_test analyze3-3.2.3 {
-  test_reoptimize $S
-} {0}
 do_test analyze3-3.2.4 {
   sqlite3_finalize $S
 } {SQLITE_OK}
 
-do_test analyze3-3.2.1 {
+do_test analyze3-3.2.5 {
   set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE b=?" -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
-do_test analyze3-3.2.2 {
+do_test analyze3-3.2.6 {
   sqlite3_bind_text $S 1 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
-do_test analyze3-3.2.3 {
-  sqlite3_finalize $S
-} {SQLITE_OK}
-
-do_test analyze3-3.3.1 {
-  set S [sqlite3_prepare db "SELECT * FROM t1 WHERE b=?" -1 dummy]
-  sqlite3_reoptimize $S
-} {SQLITE_MISUSE}
-do_test analyze3-3.3.2 {
-  sqlite3_finalize $S
-} {SQLITE_OK}
-
-do_test analyze3-3.3.1 {
-  set S [sqlite3_prepare_v2 db "SELECT * FROM t1" -1 dummy]
-  sqlite3_reoptimize $S
-} {SQLITE_OK}
-do_test analyze3-3.3.2 {
-  sqlite3_step $S
-} {SQLITE_ROW}
-do_test analyze3-3.3.3 {
-  sqlite3_reoptimize $S
-} {SQLITE_MISUSE}
-do_test analyze3-3.3.4 {
-  while {"SQLITE_ROW" == [sqlite3_step $S]} {}
-  sqlite3_reoptimize $S
-} {SQLITE_MISUSE}
-do_test analyze3-3.3.5 {
+do_test analyze3-3.2.7 {
   sqlite3_finalize $S
 } {SQLITE_OK}
 
 do_test analyze3-3.4.1 {
   set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.4.2 {
   sqlite3_bind_text $S 1 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.4.3 {
   sqlite3_bind_text $S 2 "def" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.4.4 {
   sqlite3_bind_text $S 2 "ghi" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.4.5 {
-  test_reoptimize $S
-} {0}
+  sqlite3_expired $S
+} {1}
 do_test analyze3-3.4.6 {
   sqlite3_finalize $S
 } {SQLITE_OK}
@@ -396,19 +346,16 @@ do_test analyze3-3.5.1 {
       ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31
     ) AND b>?32;
   } -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.5.2 {
   sqlite3_bind_text $S 31 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.5.3 {
   sqlite3_bind_text $S 32 "def" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
-do_test analyze3-3.5.4 {
-  test_reoptimize $S
-} {0}
 do_test analyze3-3.5.5 {
   sqlite3_finalize $S
 } {SQLITE_OK}
@@ -421,19 +368,16 @@ do_test analyze3-3.6.1 {
       ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32
     ) AND b>?33;
   } -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.6.2 {
   sqlite3_bind_text $S 32 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.6.3 {
   sqlite3_bind_text $S 33 "def" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
-do_test analyze3-3.6.4 {
-  test_reoptimize $S
-} {0}
 do_test analyze3-3.6.5 {
   sqlite3_finalize $S
 } {SQLITE_OK}
@@ -447,23 +391,20 @@ breakpoint
       ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32
     ) AND b>?10;
   } -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.7.2 {
   sqlite3_bind_text $S 32 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.7.3 {
   sqlite3_bind_text $S 33 "def" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.7.4 {
   sqlite3_bind_text $S 10 "def" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
-do_test analyze3-3.7.5 {
-  test_reoptimize $S
-} {0}
 do_test analyze3-3.7.6 {
   sqlite3_finalize $S
 } {SQLITE_OK}
@@ -478,49 +419,43 @@ do_test analyze3-3.8.2 {
   set S [sqlite3_prepare_v2 db {
     SELECT * FROM t4 WHERE x != ? AND y LIKE ?
   } -1 dummy]
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.8.3 {
   sqlite3_bind_text $S 1 "abc" 3
-  test_reoptimize $S
+  sqlite3_expired $S
 } {0}
 do_test analyze3-3.8.4 {
   sqlite3_bind_text $S 2 "def" 3
-  test_reoptimize $S
-} {1}
-do_test analyze3-3.8.5 {
-  test_reoptimize $S
-} {0}
-do_test analyze3-3.8.6 {
   sqlite3_expired $S
-} {0}
+} {1}
 do_test analyze3-3.8.7 {
   sqlite3_bind_text $S 2 "ghi%" 4
   sqlite3_expired $S
-} {0}
+} {1}
 do_test analyze3-3.8.8 {
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.9 {
   sqlite3_bind_text $S 2 "ghi%def" 7
   sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.10 {
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.11 {
   sqlite3_bind_text $S 2 "%ab" 3
   sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.12 {
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.12 {
   sqlite3_bind_text $S 2 "%de" 3
   sqlite3_expired $S
-} {0}
+} {1}
 do_test analyze3-3.8.13 {
-  test_reoptimize $S
+  sqlite3_expired $S
 } {1}
 do_test analyze3-3.8.14 {
   sqlite3_finalize $S
@@ -528,24 +463,22 @@ do_test analyze3-3.8.14 {
 
 #-------------------------------------------------------------------------
 # These tests check that errors encountered while repreparing an SQL
-# statement within sqlite3_reoptimize() are handled correctly.
+# statement within sqlite3Reprepare() are handled correctly.
 #
 
-# Check an schema error.
+# Check a schema error.
 #
 do_test analyze3-4.1.1 {
   set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
-  sqlite3_reoptimize $S
-} {SQLITE_OK}
+  sqlite3_step $S
+} {SQLITE_DONE}
 do_test analyze3-4.1.2 {
+  sqlite3_reset $S
   sqlite3_bind_text $S 2 "abc" 3
   execsql { DROP TABLE t1 }
-  sqlite3_reoptimize $S
-} {SQLITE_SCHEMA}
-do_test analyze3-4.1.3 {
   sqlite3_step $S
 } {SQLITE_SCHEMA}
-do_test analyze3-4.1.4 {
+do_test analyze3-4.1.3 {
   sqlite3_finalize $S
 } {SQLITE_SCHEMA}
 
@@ -563,18 +496,16 @@ do_test analyze3-4.2.1 {
   execsql COMMIT
   execsql ANALYZE
   set S [sqlite3_prepare_v2 db "SELECT * FROM t1 WHERE a=? AND b>?" -1 dummy]
-  sqlite3_reoptimize $S
-} {SQLITE_OK}
+  sqlite3_step $S
+} {SQLITE_DONE}
 db auth auth
 proc auth {args} {
   if {[lindex $args 0] == "SQLITE_READ"} {return SQLITE_DENY}
   return SQLITE_OK
 }
 do_test analyze3-4.2.2 {
+  sqlite3_reset $S
   sqlite3_bind_text $S 2 "abc" 3
-  sqlite3_reoptimize $S
-} {SQLITE_SCHEMA}
-do_test analyze3-4.2.3 {
   sqlite3_step $S
 } {SQLITE_SCHEMA}
 do_test analyze3-4.2.4 {
@@ -583,7 +514,7 @@ do_test analyze3-4.2.4 {
 
 # Check the effect of an authorization error that occurs in a re-prepare
 # performed by sqlite3_step() is the same as one that occurs within
-# sqlite3_reoptimize().
+# sqlite3Reprepare().
 #
 do_test analyze3-4.3.1 {
   db auth {}