Fix resultset handling with binary data

When binary data was processed, it was possible that the values were
misinterpreted as OK packets which caused debug assertions to trigger.

In addition to this, readwritesplit did not handle the case when all
packets were routed individually.
This commit is contained in:
Markus Mäkelä
2017-10-10 22:31:41 +03:00
committed by Johan Wikman
parent 96aadcbe83
commit 9c03a785ce
2 changed files with 17 additions and 2 deletions

View File

@ -649,10 +649,12 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modu
if (payloadlen == GW_MYSQL_MAX_PACKET_LEN)
{
only_ok = false;
skip_next = true;
}
else if (skip_next)
{
only_ok = false;
skip_next = false;
}
else
@ -670,9 +672,12 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modu
else if (command == MYSQL_REPLY_EOF && pktlen == MYSQL_EOF_PACKET_LEN)
{
eof++;
only_ok = false;
}
else if (command == MYSQL_REPLY_OK && pktlen >= MYSQL_OK_PACKET_MIN_LEN)
else if (command == MYSQL_REPLY_OK && pktlen >= MYSQL_OK_PACKET_MIN_LEN &&
(eof + n_found) % 2 == 0)
{
// An OK packet that is not in the middle of a resultset stream
uint8_t data[payloadlen - 1];
gwbuf_copy_data(reply, offset + MYSQL_HEADER_LEN + 1, sizeof(data), data);