MySQL 8.4.2
Source Code Documentation
|
#include "mysql_trace.h"
#include <assert.h>
#include "my_inttypes.h"
#include "my_sys.h"
#include "mysql.h"
#include "mysql/service_mysql_alloc.h"
Macros | |
#define | GET_DATA(TI) (TI)->trace_plugin_data |
#define | GET_STAGE(TI) (TI)->stage |
#define | TEST_STAGE(TI, X) (GET_STAGE(TI) == PROTOCOL_STAGE_##X) |
#define | protocol_stage_get_name(X) |
#define | trace_event_get_name(X) |
Functions | |
void | mysql_trace_start (MYSQL *m) |
Initialize tracing in a given connection. More... | |
void | mysql_trace_trace (MYSQL *m, enum trace_event ev, struct st_trace_event_args args) |
Report a protocol trace event to trace plugin. More... | |
const char * | protocol_stage_name (enum protocol_stage stage) |
const char * | trace_event_name (enum trace_event ev) |
Variables | |
struct st_mysql_client_plugin_TRACE * | trace_plugin = nullptr |
The global trace_plugin pointer. More... | |
If a plugin of type MYSQL_CLIENT_TRACE_PLUGIN is loaded into libmysql and its instance is pointed by the global trace_plugin pointer, this plugin is notified of various protocol trace events. See include/mysql/plugin_trace.h for documentation of trace plugin methods and the list of possible trace events.
These trace events are generated with MYSQL_TRACE() macro put in relevant places in libmysql code. The macro calls mysql_trace_trace() function defined here. This function calls trace plugin's trace_event() method, if it is defined.
For each traced connection, the state is kept in st_mysql_trace_info structure (see mysql_trace.h).
To correctly interpret each trace event, trace plugin is informed of the current protocol stage (see include/mysql/plugin_trace.h for list of stages). The current protocol stage is part of the connection tracing state. It is updated with MYSQL_TRACE_STAGE() hooks within libmysql code.
#define GET_DATA | ( | TI | ) | (TI)->trace_plugin_data |
#define GET_STAGE | ( | TI | ) | (TI)->stage |
#define protocol_stage_get_name | ( | X | ) |
void mysql_trace_start | ( | MYSQL * | m | ) |
Initialize tracing in a given connection.
This function is called from MYSQL_TRACE_STAGE() when the initial CONNECTING stage is reported. It allocates and initializes trace_info structure which is then attached to the connection handle.
void mysql_trace_trace | ( | MYSQL * | m, |
enum trace_event | ev, | ||
struct st_trace_event_args | args | ||
) |
Report a protocol trace event to trace plugin.
Calls plugin's trace_event() method, if it is defined, passing to it the event, the current protocol stage and event arguments (if any).
Terminates tracing of the connection when appropriate.
m | MYSQL connection handle |
ev | trace event to be reported |
args | trace event arguments |
const char * protocol_stage_name | ( | enum protocol_stage | stage | ) |
const char * trace_event_name | ( | enum trace_event | ev | ) |
struct st_mysql_client_plugin_TRACE* trace_plugin = nullptr |
The global trace_plugin pointer.
If it is not NULL, it points at a loaded trace plugin which should be used to trace all connections made to the server.