Fix handling of collected results

The result collection did not reset properly when a non-resultset was
returned for a request. As collected result need to be distinguishable
from single packet responses, a new buffer type was added.

The new buffer type is used by readwritesplit which uses result collection
for preparation of prepared statements.

Moved the current command tracking to the RWBackend class as the command
tracked by the protocol is can change before a response to the executed
command is received.

Removed a false debug assertion in the mxs_mysql_extract_ps_response
function that was triggered when a very large prepared statement response
was processed in multiple parts.
This commit is contained in:
Markus Mäkelä
2017-10-06 03:06:50 +03:00
parent f26203cec4
commit 5f13f1d358
6 changed files with 50 additions and 35 deletions

View File

@ -758,14 +758,16 @@ gw_read_and_write(DCB *dcb)
if (collecting_resultset(proto, capabilities))
{
if (expecting_resultset(proto) &&
mxs_mysql_is_result_set(read_buffer))
if (expecting_resultset(proto))
{
bool more = false;
if (modutil_count_signal_packets(read_buffer, 0, &more, NULL) != 2)
if (mxs_mysql_is_result_set(read_buffer))
{
dcb_readq_prepend(dcb, read_buffer);
return 0;
bool more = false;
if (modutil_count_signal_packets(read_buffer, 0, &more, NULL) != 2)
{
dcb_readq_prepend(dcb, read_buffer);
return 0;
}
}
// Collected the complete result
@ -937,6 +939,12 @@ gw_read_and_write(DCB *dcb)
if (session_ok_to_route(dcb))
{
if (result_collected)
{
// Mark that this is a buffer containing a collected result
gwbuf_set_type(stmt, GWBUF_TYPE_RESULT);
}
session->service->router->clientReply(session->service->router_instance,
session->router_session,
stmt, dcb);

View File

@ -1648,23 +1648,6 @@ bool mxs_mysql_extract_ps_response(GWBUF* buffer, MXS_PS_RESPONSE* out)
out->parameters = gw_mysql_get_byte2(params);
out->warnings = gw_mysql_get_byte2(warnings);
rval = true;
#ifdef SS_DEBUG
// Make sure that the PS response contains the whole response
bool more;
modutil_state state;
int n_eof = modutil_count_signal_packets(buffer, 0, &more, &state);
int n_expected = 0;
if (out->columns)
{
n_expected++;
}
if (out->parameters)
{
n_expected++;
}
ss_dassert(n_eof == n_expected);
#endif
}
return rval;