From 8b00a00ea788c29b0cd37b2c1201d5bfc006df2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 8 Dec 2018 00:53:39 +0200 Subject: [PATCH] MXS-2216: Use correct function in response processing When a response to a prepared statement was processed, the number of EOF packets was used to see whether the response was complete. This code used a function that does not work with the special packet returned by a PS preparation that is similar to an OK packet. The correct method is to count the total number of packets in the response. --- .../protocol/MySQL/mariadbbackend/mysql_backend.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c index 448d1da71..2e3dfdf93 100644 --- a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c @@ -659,24 +659,25 @@ static inline bool complete_ps_response(GWBUF *buffer) if (mxs_mysql_extract_ps_response(buffer, &resp)) { - int expected_eof = 0; + int expected_packets = 1; if (resp.columns > 0) { - expected_eof++; + // Column definition packets plus one for the EOF + expected_packets += resp.columns + 1; } if (resp.parameters > 0) { - expected_eof++; + // Parameter definition packets plus one for the EOF + expected_packets += resp.parameters + 1; } - bool more; - int n_eof = modutil_count_signal_packets(buffer, 0, &more, NULL); + int n_packets = modutil_count_packets(buffer); - MXS_DEBUG("Expecting %u EOF, have %u", n_eof, expected_eof); + MXS_DEBUG("Expecting %u packets, have %u", n_packets, expected_packets); - rval = n_eof == expected_eof; + rval = n_packets == expected_packets; } return rval;