MXS-1776: Handle recursive COM_STMT_EXECUTE commands
Readwritesplit would not handle multiple overlapping COM_STMT_EXECUTE commands properly if they opened cursors. This was due to the fact that the result would not be marked as complete and COM_STMT_FETCH commands were executed as if they did not return results. The correct implementation is to consider a COM_STMT_EXECUTE that opens a cursor complete only when the first EOF packet is read (that is, when the resultset header is read). This allows subsequent COM_STMT_FETCH commands to be handled separately. The separate COM_STMT_FETCH handling must count the number of packets that are being fetched. This allows correct tracking of the state of a COM_STMT_FETCH by checking that the number of packets is correct or the second EOF/ERR packet is read.
This commit is contained in:
@ -1068,6 +1068,21 @@ int modutil_count_statements(GWBUF* buffer)
|
||||
return num;
|
||||
}
|
||||
|
||||
int modutil_count_packets(GWBUF* buffer)
|
||||
{
|
||||
int packets = 0;
|
||||
size_t offset = 0;
|
||||
uint8_t len[3];
|
||||
|
||||
while (gwbuf_copy_data(buffer, offset, 3, len) == 3)
|
||||
{
|
||||
++packets;
|
||||
offset += gw_mysql_get_byte3(len) + MYSQL_HEADER_LEN;
|
||||
}
|
||||
|
||||
return packets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the PCRE2 patterns used when converting MySQL wildcards to PCRE syntax.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user