From f4dd0628dab050f669d544beafa51246ced9cb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sun, 11 Nov 2018 17:19:52 +0200 Subject: [PATCH] Fix COM_CHANGE_USER handling If the service doesn't require collection of complete packets, the user reauthentication done with COM_CHANGE_USER would be skipped. This caused the change_user test to fail. By temporarily switching to full packet collection mode for the duration of the COM_CHANGE_USER, we avoid duplicating the code for the streaming router types. --- .../modules/protocol/MySQL/mariadbclient/mysql_client.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc index 88c55bbd9..cd104ee6d 100644 --- a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc +++ b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc @@ -1019,11 +1019,13 @@ gw_read_normal_data(DCB *dcb, GWBUF *read_buffer, int nbytes_read) /** Ask what type of input the router/filter chain expects */ capabilities = service_get_capabilities(session->service); + MySQLProtocol* proto = static_cast(dcb->protocol); /** If the router requires statement input we need to make sure that * a complete SQL packet is read before continuing. The current command * that is tracked by the protocol module is updated in route_by_statement() */ - if (rcap_type_required(capabilities, RCAP_TYPE_STMT_INPUT)) + if (rcap_type_required(capabilities, RCAP_TYPE_STMT_INPUT) + || proto->current_command == MXS_COM_CHANGE_USER) { uint8_t pktlen[MYSQL_HEADER_LEN]; size_t n_copied = gwbuf_copy_data(read_buffer, 0, MYSQL_HEADER_LEN, pktlen); @@ -1062,7 +1064,6 @@ gw_read_normal_data(DCB *dcb, GWBUF *read_buffer, int nbytes_read) qc_set_server_version(service_get_version(session->service, SERVICE_VERSION_MIN)); spec_com_res_t res = RES_CONTINUE; - MySQLProtocol* proto = static_cast(dcb->protocol); if (!proto->changing_user) { @@ -1137,7 +1138,8 @@ gw_read_finish_processing(DCB *dcb, GWBUF *read_buffer, uint64_t capabilities) /** Reset error handler when routing of the new query begins */ dcb->dcb_errhandle_called = false; - if (rcap_type_required(capabilities, RCAP_TYPE_STMT_INPUT)) + if (rcap_type_required(capabilities, RCAP_TYPE_STMT_INPUT) + || proto->current_command == MXS_COM_CHANGE_USER) { /** * Feed each statement completely and separately to router.