Skip to content

Query log: add support for logging prepared statement parameters #4861

@renecannao

Description

@renecannao

This is related to #3687

We need to add parameters when logging prepared statement.

Logging must be for both binary format and json format.

Splitting the issue into subteasks

All logging types

  • 4861-all: define the list of all MySQL data types
  • 4861-all: identify the most efficient way to achieve parameters logging without unnecessary overhead (new classes, data copy, etc)

for binary logging

  • 4861-binary : evaluate the best logging format , probably matching MySQL protocol format
  • 4861-binary : define the format for each MySQL data types
  • 4861-binary : implement logging of parameters received with COM_STMT_EXECUTE
  • 4861-binary : implement logging of parameters received with COM_STMT_SEND_LONG_DATA
  • 4861-binary : implement testing for each MySQL data types received via COM_STMT_EXECUTE
  • 4861-binary : implement testing for "long" MySQL data types received via COM_STMT_SEND_LONG_DATA
  • 4861-binary : implement testing of mixing data types received via COM_STMT_EXECUTE and COM_STMT_SEND_LONG_DATA
  • 4861-binary : document in detail the new logging format

for JSON logging

  • 4861-JSON : define the format for each MySQL data types
  • 4861-JSON : implement logging of parameters received with COM_STMT_EXECUTE
  • 4861-JSON : implement logging of parameters received with COM_STMT_SEND_LONG_DATA
  • 4861-JSON : implement testing for each MySQL data types received via COM_STMT_EXECUTE
  • 4861-JSON : implement testing for "long" MySQL data types received via COM_STMT_SEND_LONG_DATA
  • 4861-JSON : implement testing of mixing data types received via COM_STMT_EXECUTE and COM_STMT_SEND_LONG_DATA
  • 4861-JSON : document the extension to JSON format

Notes:

On COM_STMT_SEND_LONG_DATA

Although ProxySQL handles commands COM_STMT_SEND_LONG_DATA received from the client, it efficiently only uses COM_STMT_EXECUTE when executing prepared statements to the backend, reducing the number of network round trips.

Data received via COM_STMT_SEND_LONG_DATA is stored in a StmtLongDataHandler object .
When ProxySQL receives a COM_STMT_EXECUTE , in MySQL_Protocol::get_binds_from_pkt() it also retrieves the data in the StmtLongDataHandler object . This should mean that we shouldn't scan the StmtLongDataHandler object for parameters.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions