xref: /netbsd-src/external/public-domain/sqlite/man/SQLITE_TRACE_STMT.3 (revision b9988867a8ad969c45a52aa7628bc932ec98d46b)
1.Dd January 24, 2024
2.Dt SQLITE_TRACE_STMT 3
3.Os
4.Sh NAME
5.Nm SQLITE_TRACE_STMT ,
6.Nm SQLITE_TRACE_PROFILE ,
7.Nm SQLITE_TRACE_ROW ,
8.Nm SQLITE_TRACE_CLOSE
9.Nd SQL trace event codes
10.Sh SYNOPSIS
11.In sqlite3.h
12.Fd #define SQLITE_TRACE_STMT
13.Fd #define SQLITE_TRACE_PROFILE
14.Fd #define SQLITE_TRACE_ROW
15.Fd #define SQLITE_TRACE_CLOSE
16.Sh DESCRIPTION
17These constants identify classes of events that can be monitored using
18the
19.Fn sqlite3_trace_v2
20tracing logic.
21The M argument to sqlite3_trace_v2(D,M,X,P)
22is an OR-ed combination of one or more of the following constants.
23The first argument to the trace callback is one of the following constants.
24.Pp
25New tracing constants may be added in future releases.
26.Pp
27A trace callback has four arguments: xCallback(T,C,P,X).
28The T argument is one of the integer type codes above.
29The C argument is a copy of the context pointer passed in as the fourth
30argument to
31.Fn sqlite3_trace_v2 .
32The P and X arguments are pointers whose meanings depend on T.
33.Bl -tag -width Ds
34.It SQLITE_TRACE_STMT
35An SQLITE_TRACE_STMT callback is invoked when a prepared statement
36first begins running and possibly at other times during the execution
37of the prepared statement, such as at the start of each trigger subprogram.
38The P argument is a pointer to the prepared statement.
39The X argument is a pointer to a string which is the unexpanded SQL
40text of the prepared statement or an SQL comment that indicates the
41invocation of a trigger.
42The callback can compute the same text that would have been returned
43by the legacy
44.Fn sqlite3_trace
45interface by using the X argument when X begins with "--" and invoking
46sqlite3_expanded_sql(P) otherwise.
47.It SQLITE_TRACE_PROFILE
48An SQLITE_TRACE_PROFILE callback provides approximately the same information
49as is provided by the
50.Fn sqlite3_profile
51callback.
52The P argument is a pointer to the prepared statement
53and the X argument points to a 64-bit integer which is approximately
54the number of nanoseconds that the prepared statement took to run.
55The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
56.It SQLITE_TRACE_ROW
57An SQLITE_TRACE_ROW callback is invoked whenever a prepared statement
58generates a single row of result.
59The P argument is a pointer to the prepared statement
60and the X argument is unused.
61.It SQLITE_TRACE_CLOSE
62An SQLITE_TRACE_CLOSE callback is invoked when a database connection
63closes.
64The P argument is a pointer to the database connection
65object and the X argument is unused.
66.El
67.Pp
68.Sh IMPLEMENTATION NOTES
69These declarations were extracted from the
70interface documentation at line 3326.
71.Bd -literal
72#define SQLITE_TRACE_STMT       0x01
73#define SQLITE_TRACE_PROFILE    0x02
74#define SQLITE_TRACE_ROW        0x04
75#define SQLITE_TRACE_CLOSE      0x08
76.Ed
77.Sh SEE ALSO
78.Xr sqlite3 3 ,
79.Xr sqlite3_stmt 3 ,
80.Xr sqlite3_trace 3 ,
81.Xr sqlite3_trace_v2 3
82