diff options
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 5f5517ac2..3e7a513e7 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -1128,6 +1128,16 @@ 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; } |