aboutsummaryrefslogtreecommitdiff
path: root/src/tclsqlite.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2007-11-14 06:48:48 +0000
committerdanielk1977 <danielk1977@noemail.net>2007-11-14 06:48:48 +0000
commitd0e2a85436a3d2eeafceae60d9c6ac6a73df86fe (patch)
tree42005f20ab1f5446da5cc0de89be88035c8f5ba3 /src/tclsqlite.c
parent8e556520e95efcd436b408f13738ce5460a72805 (diff)
downloadsqlite-d0e2a85436a3d2eeafceae60d9c6ac6a73df86fe.tar.gz
sqlite-d0e2a85436a3d2eeafceae60d9c6ac6a73df86fe.zip
Add an experimental API for retrieving the SQL source from a compiled statement: sqlite3_sql(). Ticket #2769. (CVS 4543)
FossilOrigin-Name: d31f1e0d74a871d66cf7d3ef35faae5171d5cbc3
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r--src/tclsqlite.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 6a9434131..a151bb6ac 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -12,7 +12,7 @@
** A TCL Interface to SQLite. Append this file to sqlite3.c and
** compile the whole thing to build a TCL-enabled version of SQLite.
**
-** $Id: tclsqlite.c,v 1.206 2007/11/13 10:30:26 danielk1977 Exp $
+** $Id: tclsqlite.c,v 1.207 2007/11/14 06:48:48 danielk1977 Exp $
*/
#include "tcl.h"
#include <errno.h>
@@ -85,7 +85,7 @@ struct SqlPreparedStmt {
SqlPreparedStmt *pPrev; /* Previous on the list */
sqlite3_stmt *pStmt; /* The prepared statement */
int nSql; /* chars in zSql[] */
- char zSql[1]; /* Text of the SQL statement */
+ const char *zSql; /* Text of the SQL statement */
};
typedef struct IncrblobChannel IncrblobChannel;
@@ -1813,12 +1813,13 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
*/
if( pPreStmt==0 ){
len = zLeft - zSql;
- pPreStmt = (SqlPreparedStmt*)Tcl_Alloc( sizeof(*pPreStmt) + len );
+ pPreStmt = (SqlPreparedStmt*)Tcl_Alloc( sizeof(*pPreStmt) );
if( pPreStmt==0 ) return TCL_ERROR;
pPreStmt->pStmt = pStmt;
pPreStmt->nSql = len;
- memcpy(pPreStmt->zSql, zSql, len);
- pPreStmt->zSql[len] = 0;
+ pPreStmt->zSql = sqlite3_sql(pStmt);
+ assert( strlen(pPreStmt->zSql)==len );
+ assert( 0==memcmp(pPreStmt->zSql, zSql, len) );
}
/* Add the prepared statement to the beginning of the cache list