From 39031f614be9b850a5092f9eab1b5ecced77c8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 31 Mar 2025 17:02:33 +0000 Subject: [PATCH] Uses 0 params in write_query_format_1() 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. --- lib/MySQL_Logger.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 391d4a139..477505e16 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -768,6 +768,11 @@ uint64_t MySQL_Event::write_query_format_1(std::fstream *f) { // Add the raw bytes of the parameter value. total_bytes += value_len; } + } else { + // Deterministic binary logging: always report 0 parameters. + uint16_t num_params = 0; + uint8_t paramCountLen = mysql_encode_length(num_params, buf); + total_bytes += paramCountLen; } } @@ -921,6 +926,11 @@ uint64_t MySQL_Event::write_query_format_1(std::fstream *f) { f->write(convertedValue.data(), value_len); } } + } else { + // Deterministic binary logging: always report 0 parameters. + uint16_t num_params = 0; + uint8_t paramCountLen = mysql_encode_length(num_params, buf); + f->write((char *)buf, paramCountLen); } }