Fix multi-statement execution in readwritesplit
A multi-statements can return multiple resultsets in one response. To accommodate for this, both the readwritesplit and modutil code must be altered. By ignoring complete resultsets in readwritesplit, the code can deduce whether a result is complete or not.
This commit is contained in:

committed by
Johan Wikman

parent
3afc89ae80
commit
97d0cc7482
@ -628,10 +628,9 @@ GWBUF* modutil_get_complete_packets(GWBUF **p_readbuf)
|
||||
return complete;
|
||||
}
|
||||
|
||||
int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_dest, modutil_state* state)
|
||||
int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_out, modutil_state* state)
|
||||
{
|
||||
unsigned int len = gwbuf_length(reply);
|
||||
ss_debug(int real_offset = 0);
|
||||
int eof = 0;
|
||||
int err = 0;
|
||||
size_t offset = 0;
|
||||
@ -661,18 +660,18 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_dest, mod
|
||||
|
||||
if (command == MYSQL_REPLY_ERR)
|
||||
{
|
||||
err++;
|
||||
/** Any errors in the packet stream mean that the result set
|
||||
* generation was aborted due to an error. No more results will
|
||||
* follow after this. */
|
||||
*more_out = false;
|
||||
return 2;
|
||||
}
|
||||
else if (command == MYSQL_REPLY_EOF && pktlen == MYSQL_EOF_PACKET_LEN)
|
||||
{
|
||||
eof++;
|
||||
}
|
||||
else if (more && command == MYSQL_REPLY_OK)
|
||||
else if (command == MYSQL_REPLY_OK && pktlen >= MYSQL_OK_PACKET_MIN_LEN)
|
||||
{
|
||||
// This should not be the first packet
|
||||
ss_dassert(pktlen >= MYSQL_OK_PACKET_MIN_LEN);
|
||||
ss_dassert(real_offset > 0);
|
||||
|
||||
uint8_t data[payloadlen - 1];
|
||||
gwbuf_copy_data(reply, offset + MYSQL_HEADER_LEN + 1, sizeof(data), data);
|
||||
|
||||
@ -693,7 +692,6 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_dest, mod
|
||||
}
|
||||
|
||||
offset += pktlen;
|
||||
ss_debug(real_offset += pktlen);
|
||||
|
||||
if (offset >= GWBUF_LENGTH(reply) && reply->next)
|
||||
{
|
||||
@ -709,7 +707,7 @@ int modutil_count_signal_packets(GWBUF *reply, int n_found, bool* more_dest, mod
|
||||
state->state = skip_next;
|
||||
}
|
||||
|
||||
*more_dest = more;
|
||||
*more_out = more;
|
||||
return total;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user