[MYSQL] logging of prepared statement parameters #4861#4895
Merged
renecannao merged 13 commits intov3.0from Apr 14, 2025
Merged
[MYSQL] logging of prepared statement parameters #4861#4895renecannao merged 13 commits intov3.0from
renecannao merged 13 commits intov3.0from
Conversation
Adding session Addin a placeholder for extractStmtExecuteMetadataToJson()
Added: * bufferTypeInfoMap : to map mysql type to typename and function to convert to JSON * extractStmtExecuteMetadataToJson() : function to generate a JSON with parameters Modified write_query_format_1() to write parameters. This is still a WIP
Added inline documentation in write_query_format_1() related to the logging of parameters when COM_STMT_EXECUTE is logged
Added detailed documentation for Logging of prepared statements parameters
When logging COM_STMT_EXECUTE parameters, we check stored parameters. In the unexpected event (it should never happen) that either `session` or `session->CurrentQuery.stmt_meta` are `nullptr` , we log 0 parameters to ensure a deterministic format in the query logging file.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces documentation updates that describe enhanced logging for prepared statement parameters in MySQL queries using both binary and JSON formats.
- Adds a comprehensive markdown guide explaining how prepared statement parameters are logged, including details on parameter counts, null bitmaps, and value encoding.
- Provides a detailed JSON example to illustrate the expected output for parameter logging.
Files not reviewed (1)
- include/MySQL_Logger.hpp: Language not supported
Comments suppressed due to low confidence (1)
doc/internal/MySQL_Logging_Prepared_Statements_Parameters.md:56
- The JSON example appears to be missing a comma after the 'starttime' field, which results in invalid JSON format. Please insert the missing comma to ensure the example is syntactically correct.
"starttime": "2021-03-31 12:32:00.000000"
eventlog_reader_to_json.cpp is the first iteration of a tool able to read an eventlog in binary format and generate a JSON
Still not completed. We still need an automatic way to verify the generated files.
In write_query_format_1() : * write the number of parameters (previously erroneously skipped) * write null_bitmap only if there are parameters * write the parameters values (this was previously erroneously skipped) In test_ps_logging-t.cpp : * verify that query logging is configured to file In eventlog_reader_to_json.cpp : * added verbose logging * added enum `log_event_type` for properly identifying event type * parse all events in the input file
Extending test_ps_logging-t with more data types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For MySQL queries, two logging formats are supported:
write_query_format_1()write_query_format_2_json()For prepared statements (i.e.
COM_STMT_EXECUTEevents), the logging functions now log extra parameter details.Both formats encode the number of parameters and, for each parameter, log its type and a human-readable string value, with special handling for
NULLvalues.