SQLITE3_TRACE_V2(3) | Library Functions Manual | SQLITE3_TRACE_V2(3)

# NAME

`sqlite3_trace_v2` — SQL trace hook

# SYNOPSIS

`#include <sqlite3.h>`

int
`sqlite3_trace_v2`(sqlite3*, unsigned uMask, int(*xCallback)(unsigned,void*,void*,void*), void *pCtx);

# DESCRIPTION

The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback function X against database connection D, using property mask M and context pointer P. If the X callback is NULL or if the M mask is zero, then tracing is disabled. The M argument should be the bitwise OR-ed combination of zero or more SQLITE_TRACE constants.

Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P) overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P) for the database connection D. Each database connection may have at most one trace callback.

The X callback is invoked whenever any of the events identified by mask M occur. The integer return value from the callback is currently ignored, though this may change in future releases. Callback implementations should return zero to ensure future compatibility.

A trace callback is invoked with four arguments: callback(T,C,P,X). The T argument is one of the SQLITE_TRACE constants to indicate why the callback was invoked. The C argument is a copy of the context pointer. The P and X arguments are pointers whose meanings depend on T.

The sqlite3_trace_v2() interface is intended to replace the legacy interfaces `sqlite3_trace`() and `sqlite3_profile`(), both of which are deprecated.

# IMPLEMENTATION NOTES

These declarations were extracted from the interface documentation at line 3383.

    SQLITE_API int sqlite3_trace_v2(
      sqlite3*,
      unsigned uMask,
      int(*xCallback)(unsigned,void*,void*,void*),
      void *pCtx
    );

# SEE ALSO

sqlite3(3), sqlite3_trace(3), SQLITE_TRACE_STMT(3)

January 24, 2024 | NetBSD 11.0