diff --git a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c index 6dcdb18ca..6913e23d1 100644 --- a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c @@ -377,9 +377,20 @@ mxs_auth_state_t handle_server_response(DCB *dcb, GWBUF *buffer) static inline void prepare_for_write(DCB *dcb, GWBUF *buffer) { MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol; + uint64_t capabilities = service_get_capabilities(dcb->session->service); - /** Copy the current command being executed to this backend */ - if (dcb->session->client_dcb && dcb->session->client_dcb->protocol) + /** + * Copy the current command being executed to this backend. For statement + * based routers, this is tracked by using the current command being executed. + * For routers that stream data, the client protocol command tracking data + * is used which does not guarantee that the correct command is tracked if + * something queues commands internally. + */ + if (rcap_type_required(capabilities, RCAP_TYPE_STMT_INPUT)) + { + proto->current_command = (mxs_mysql_cmd_t)MYSQL_GET_COMMAND(GWBUF_DATA(buffer)); + } + else if (dcb->session->client_dcb && dcb->session->client_dcb->protocol) { MySQLProtocol *client_proto = (MySQLProtocol*)dcb->session->client_dcb->protocol; proto->current_command = client_proto->current_command;