From c70e1431e31127ff3f5dcf675667168117b79b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 9 Oct 2017 13:38:12 +0300 Subject: [PATCH] Fix OK packet status extraction in readwritesplit As the row count and last insert ID are length-encoded integers, they need to be handled with the correct functions. --- server/modules/routing/readwritesplit/readwritesplit.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index b84acd831..b16edbe5c 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include "rwsplit_internal.hh" #include "rwsplitsession.hh" @@ -531,7 +532,13 @@ static inline bool more_results_exist(GWBUF* buffer) { ss_dassert(is_eof(buffer, gw_mysql_get_byte3(GWBUF_DATA(buffer))) || mxs_mysql_is_ok_packet(buffer)); - uint16_t status = gw_mysql_get_byte2(GWBUF_DATA(buffer) + MYSQL_HEADER_LEN + 1 + 2); + ss_dassert(GWBUF_IS_CONTIGUOUS(buffer)); + + uint8_t* ptr = GWBUF_DATA(buffer) + MYSQL_HEADER_LEN + 1; + ptr += mxs_leint_bytes(ptr); + ptr += mxs_leint_bytes(ptr); + + uint16_t status = gw_mysql_get_byte2(ptr); return status & SERVER_MORE_RESULTS_EXIST; }