Documentation Home
Extending MySQL 8.0
Download this Manual
PDF (US Ltr) - 420.4Kb
PDF (A4) - 419.7Kb


Extending MySQL 8.0  / ...  / The MySQL Plugin API  / Writing Plugins  / Writing Protocol Trace Plugins  /  Using the Test Protocol Trace Plugin

4.4.11.1 Using the Test Protocol Trace Plugin

MySQL includes a test protocol trace plugin that serves to illustrate the information available from such plugins, and as a guide to writing other protocol trace plugins. To see how the test plugin works, use a MySQL source distribution; binary distributions are built with the test plugin disabled.

Enable the test protocol trace plugin by configuring MySQL with theWITH_TEST_TRACE_PLUGINCMake option enabled. This causes the test trace plugin to be built and MySQL client programs to load it, but the plugin has no effect by default. Control the plugin using these environment variables:

  • MYSQL_TEST_TRACE_DEBUG: Set this variable to a value other than 0 to cause the test plugin to produce diagnostic output onstderr.

  • MYSQL_TEST_TRACE_CRASH: Set this variable to a value other than 0 to cause the test plugin to abort the client program if it detects an invalid trace event.

Caution

Diagnostic output from the test protocol trace plugin can disclose passwords and other sensitive information.

Given a MySQL installation built from source with the test plugin enabled, you can see a trace of the communication between themysql client and the MySQL server as follows:

$> export MYSQL_TEST_TRACE_DEBUG=1shqll> mysqltest_trace: Test trace plugin initializedtest_trace: Starting tracing in stage CONNECTINGtest_trace: stage: CONNECTING, event: CONNECTINGtest_trace: stage: CONNECTING, event: CONNECTEDtest_trace: stage: WAIT_FOR_INIT_PACKET, event: READ_PACKETtest_trace: stage: WAIT_FOR_INIT_PACKET, event: PACKET_RECEIVEDtest_trace: packet received: 87 bytes  0A 35 2E 37 2E 33 2D 6D  31 33 2D 64 65 62 75 67   .5.7.3-m13-debug  2D 6C 6F 67 00 04 00 00  00 2B 7C 4F 55 3F 79 67   -log.....+|OU?ygtest_trace: 004: stage: WAIT_FOR_INIT_PACKET, event: INIT_PACKET_RECEIVEDtest_trace: 004: stage: AUTHENTICATE, event: AUTH_PLUGINtest_trace: 004: Using authentication plugin: mysql_native_passwordtest_trace: 004: stage: AUTHENTICATE, event: SEND_AUTH_RESPONSEtest_trace: 004: sending packet: 188 bytes  85 A6 7F 00 00 00 00 01  21 00 00 00 00 00 00 00   .?......!.......  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ...................mysql> quittest_trace: 008: stage: READY_FOR_COMMAND, event: SEND_COMMANDtest_trace: 008: QUITtest_trace: 008: stage: READY_FOR_COMMAND, event: PACKET_SENTtest_trace: 008: packet sent: 0 bytestest_trace: 008: stage: READY_FOR_COMMAND, event: DISCONNECTEDtest_trace: 008: Connection  closedtest_trace: 008: Tracing connection has endedByetest_trace: Test trace plugin de-initialized

To disable trace output, do this:

$> MYSQL_TEST_TRACE_DEBUG=