diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sqlite.h.in | 35 | ||||
-rw-r--r-- | src/test1.c | 35 | ||||
-rw-r--r-- | src/vdbeapi.c | 20 |
3 files changed, 87 insertions, 3 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b072c0663..9ea25148d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -30,7 +30,7 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.337 2008/06/19 00:16:08 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.338 2008/06/19 02:52:25 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -4739,6 +4739,39 @@ int sqlite3_get_autocommit(sqlite3*); */ sqlite3 *sqlite3_db_handle(sqlite3_stmt*); +/* +** CAPI3REF: Find the next prepared statement {F13140} +** +** Return a pointer to the next [prepared statement] after pStmt +** associated with [database connection] pDb. If pStmt is NULL +** then return a pointer to the first [prepared statement] associated +** with the [database connection] pDb. If no [prepared statement] +** satisfies the conditions of this routine, return NULL. +** +** INVARIANTS: +** +** {F13143} If D is a [database connection] that holds one or more +** unfinalized [prepared statements] and S is a NULL pointer, +** then [sqlite3_next_stmt(D, S)] routine shall return a pointer +** to one of the [prepared statements] associated with D. +** +** {F13146} If D is a [database connection] that holds no +** unfinalized [prepared statements] and S is a NULL pointer, +** then [sqlite3_next_stmt(D, S)] routine shall return a NULL +** pointer. +** +** {F13149} If S is a [prepared statement] in [database connection] D +** and S is not the last [prepared statement] in D, then +** [sqlite3_next_stmt(D, S)] routine shall return a pointer +** to the next [prepared statement] in D after S. +** +** {F13152} If S is the last [prepared statement] in [database connection] D +** then [sqlite3_next_stmt(D, S)] routine shall return a NULL +** pointer. +** +*/ +sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); + /* ** CAPI3REF: Commit And Rollback Notification Callbacks {F12950} diff --git a/src/test1.c b/src/test1.c index 6174f2b13..f31e5d8ee 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.305 2008/05/29 02:57:48 shane Exp $ +** $Id: test1.c,v 1.306 2008/06/19 02:52:25 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -1899,6 +1899,38 @@ static int test_finalize( } /* +** Usage: sqlite3_next_stmt DB STMT +** +** Return the next statment in sequence after STMT. +*/ +static int test_next_stmt( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_stmt *pStmt; + sqlite3 *db = 0; + char zBuf[50]; + + if( objc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " DB STMT", 0); + return TCL_ERROR; + } + + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt) ) return TCL_ERROR; + pStmt = sqlite3_next_stmt(db, pStmt); + if( pStmt ){ + if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; + Tcl_AppendResult(interp, zBuf, 0); + } + return TCL_OK; +} + + +/* ** Usage: sqlite3_reset STMT ** ** Reset a statement handle. @@ -4605,6 +4637,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_transfer_bindings", test_transfer_bind ,0 }, { "sqlite3_changes", test_changes ,0 }, { "sqlite3_step", test_step ,0 }, + { "sqlite3_next_stmt", test_next_stmt ,0 }, { "sqlite3_release_memory", test_release_memory, 0}, { "sqlite3_soft_heap_limit", test_soft_heap_limit, 0}, diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 8fc3987c6..fea540f43 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -13,7 +13,7 @@ ** This file contains code use to implement APIs that are part of the ** VDBE. ** -** $Id: vdbeapi.c,v 1.133 2008/06/18 17:09:10 danielk1977 Exp $ +** $Id: vdbeapi.c,v 1.134 2008/06/19 02:52:25 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -1256,3 +1256,21 @@ int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){ sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){ return pStmt ? ((Vdbe*)pStmt)->db : 0; } + +/* +** 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. +*/ +sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){ + sqlite3_stmt *pNext; + sqlite3_mutex_enter(pDb->mutex); + if( pStmt==0 ){ + pNext = (sqlite3_stmt*)pDb->pVdbe; + }else{ + pNext = (sqlite3_stmt*)((Vdbe*)pStmt)->pNext; + } + sqlite3_mutex_leave(pDb->mutex); + return pNext; +} |