MXS-852: Fix execution of COM_STMT_FETCH

The COM_STMT_FETCH queries are always executed when the result has not
been fully read. This means that the statement queuing code needs to allow
COM_STMT_FETCH commands to pass if a statement is being executed but the
command queue is empty.
This commit is contained in:
Markus Mäkelä
2017-06-23 13:40:15 +03:00
parent 5c94610b68
commit 16201592a2
3 changed files with 8 additions and 4 deletions

View File

@ -1654,5 +1654,6 @@ bool mxs_mysql_command_will_respond(uint8_t cmd)
{ {
return cmd != MYSQL_COM_STMT_SEND_LONG_DATA && return cmd != MYSQL_COM_STMT_SEND_LONG_DATA &&
cmd != MYSQL_COM_QUIT && cmd != MYSQL_COM_QUIT &&
cmd != MYSQL_COM_STMT_CLOSE; cmd != MYSQL_COM_STMT_CLOSE &&
cmd != MYSQL_COM_STMT_FETCH;
} }

View File

@ -919,8 +919,10 @@ static int routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session,
} }
else else
{ {
if ((rses->expected_responses == 0 && rses->query_queue == NULL) || if (rses->query_queue == NULL &&
rses->load_data_state == LOAD_DATA_ACTIVE) (rses->expected_responses == 0 ||
mxs_mysql_get_command(querybuf) == MYSQL_COM_STMT_FETCH ||
rses->load_data_state == LOAD_DATA_ACTIVE))
{ {
/** No active or pending queries */ /** No active or pending queries */
if (route_single_stmt(inst, rses, querybuf)) if (route_single_stmt(inst, rses, querybuf))

View File

@ -1076,7 +1076,8 @@ static inline bool query_creates_reply(mysql_server_cmd_t cmd)
{ {
return cmd != MYSQL_COM_QUIT && return cmd != MYSQL_COM_QUIT &&
cmd != MYSQL_COM_STMT_SEND_LONG_DATA && cmd != MYSQL_COM_STMT_SEND_LONG_DATA &&
cmd != MYSQL_COM_STMT_CLOSE; cmd != MYSQL_COM_STMT_CLOSE &&
cmd != MYSQL_COM_STMT_FETCH; // Fetch is done mid-result
} }
/** /**