描述
注册一个可用于跟踪执行SQL语句的回调函数。
C / C ++语法
void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
PB语法
FUNCTION sqlite3_trace ( _ BYVAL hDbc AS DWORD, _ BYVAL pTraceCallback AS DWORD, _ BYVAL pData AS DWORD _ ) AS DWORD |
参数
hDbc
[in]连接句柄。
pTraceCallback
[in]指向回调函数的指针。
pData
[in]一个可选值,它被转发到每个回调调用的第一个参数。
返回值
先前注册的跟踪回调的pData参数。
备注
sqlite3_trace注册的回调函数在不同的时候被sqlite3_step运行的SQL语句调用。当语句首先开始执行时,将使用SQL语句文本的UTF-8呈现来调用sqlite3_trace回调。每个触发的子程序都会输入sqlite3_trace回调。触发器的回调包含标识触发器的UTF-8 SQL注释。
C ++实现代码
#ifndef SQLITE_OMIT_TRACE
/*
** Register a trace function. The pArg from the previously registered trace
** is returned.
**
** A NULL trace function means that no tracing is executeds. A non-NULL
** trace is a pointer to a function that is invoked at the start of each
** SQL statement.
*/
SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
void *pOld;
sqlite3_mutex_enter(db->mutex);
pOld = db->pTraceArg;
db->xTrace = xTrace;
db->pTraceArg = pArg;
sqlite3_mutex_leave(db->mutex);
return pOld;
}
/*
** Register a profile function. The pArg from the previously registered
** profile function is returned.
**
** A NULL profile function means that no profiling is executes. A non-NULL
** profile is a pointer to a function that is invoked at the conclusion of
** each SQL statement that is run.
*/
SQLITE_API void *sqlite3_profile(
sqlite3 *db,
void (*xProfile)(void*,const char*,sqlite_uint64),
void *pArg
){
void *pOld;
sqlite3_mutex_enter(db->mutex);
pOld = db->pProfileArg;
db->xProfile = xProfile;
db->pProfileArg = pArg;
sqlite3_mutex_leave(db->mutex);
return pOld;
}
#endif /* SQLITE_OMIT_TRACE */