From bfeaceb070604629c462ec9207b523cec171ff31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 22 Sep 2017 10:27:34 +0300 Subject: [PATCH] Assert that only complete COM_STMT_PREPARE responses are returned Asserting that only a complete COM_STMT_PREPARE is returned when the prepared statement preparation is extracted will guarantee that the protocol works as expected. --- server/modules/protocol/MySQL/mysql_common.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/modules/protocol/MySQL/mysql_common.c b/server/modules/protocol/MySQL/mysql_common.c index 40eb1b68f..1cdd4481d 100644 --- a/server/modules/protocol/MySQL/mysql_common.c +++ b/server/modules/protocol/MySQL/mysql_common.c @@ -1661,6 +1661,23 @@ bool mxs_mysql_extract_ps_response(GWBUF* buffer, MXS_PS_RESPONSE* out) out->parameters = gw_mysql_get_byte2(params); out->warnings = gw_mysql_get_byte2(warnings); rval = true; + +#ifdef SS_DEBUG + // Make sure that the PS response contains the whole response + bool more; + modutil_state state; + int n_eof = modutil_count_signal_packets(buffer, 0, &more, &state); + int n_expected = 0; + if (out->columns) + { + n_expected++; + } + if (out->parameters) + { + n_expected++; + } + ss_dassert(n_eof == n_expected); +#endif } return rval;