mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add the sqlite_trace() hook for tracing the SQL that an application executes.
The plan is to leave this API undocumented for the time being, in case we want to make changes to it later. (CVS 836) FossilOrigin-Name: f67bff8ff3db9694f87daf1a549d24ea9612da6b
This commit is contained in:
25
src/main.c
25
src/main.c
@@ -14,7 +14,7 @@
|
||||
** other files are for internal use by SQLite and should not be
|
||||
** accessed by users of the library.
|
||||
**
|
||||
** $Id: main.c,v 1.106 2003/01/12 18:02:18 drh Exp $
|
||||
** $Id: main.c,v 1.107 2003/01/16 16:28:54 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -602,6 +602,9 @@ int sqlite_exec(
|
||||
){
|
||||
Parse sParse;
|
||||
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
if( db->xTrace ) db->xTrace(db->pTraceArg, zSql);
|
||||
#endif
|
||||
if( pzErrMsg ) *pzErrMsg = 0;
|
||||
if( sqliteSafetyOn(db) ) goto exec_misuse;
|
||||
if( (db->flags & SQLITE_Initialized)==0 ){
|
||||
@@ -858,6 +861,26 @@ int sqlite_function_type(sqlite *db, const char *zName, int dataType){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Register a trace function. The pArg from the previously registered trace
|
||||
** is returned.
|
||||
**
|
||||
** A NULL trace function means that no tracing is executes. A non-NULL
|
||||
** trace is a pointer to a function that is invoked at the start of each
|
||||
** sqlite_exec().
|
||||
*/
|
||||
void *sqlite_trace(sqlite *db, void (*xTrace)(void*,const char*), void *pArg){
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
void *pOld = db->pTraceArg;
|
||||
db->xTrace = xTrace;
|
||||
db->pTraceArg = pArg;
|
||||
return pOld;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Attempt to open the file named in the argument as the auxiliary database
|
||||
** file. The auxiliary database file is used to store TEMP tables. But
|
||||
|
Reference in New Issue
Block a user