MXS-2562: Fix out-of-order error during COM_CHANGE_USER

If an error is generated while a COM_CHANGE_USER is being done, it would
always use the sequence number 1. To properly handle this case and send
the correct sequence number, the COM_CHANGE_USER progress needs to be
tracked at the session level.

The information needs to be shared between the backend and client
protocols as the final OK to the COM_CHANGE_USER, with the sequence number
3, is the one that the backend server returns. Only after this response
has been received and routed to the client can the COM_CHANGE_USER
processing stop.
This commit is contained in:
Markus Mäkelä
2019-06-27 23:28:46 +03:00
parent 3b6387c952
commit 40f35618ad
4 changed files with 26 additions and 10 deletions

View File

@ -142,14 +142,15 @@ typedef enum
*/
typedef struct mysql_session
{
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
int auth_token_len; /*< token length */
uint8_t* auth_token; /*< token */
bool correct_authenticator; /*< is session using mysql_native_password? */
uint8_t next_sequence; /*< Next packet sequence */
bool auth_switch_sent; /*< Expecting a response to AuthSwitchRequest? */
uint8_t client_sha1[MYSQL_SCRAMBLE_LEN]; /*< SHA1(password) */
char user[MYSQL_USER_MAXLEN + 1]; /*< username */
char db[MYSQL_DATABASE_MAXLEN + 1]; /*< database */
int auth_token_len; /*< token length */
uint8_t* auth_token; /*< token */
bool correct_authenticator; /*< is session using mysql_native_password? */
uint8_t next_sequence; /*< Next packet sequence */
bool auth_switch_sent; /*< Expecting a response to AuthSwitchRequest? */
bool changing_user; /*< True if a COM_CHANGE_USER is in progress */
} MYSQL_session;
/** Protocol packing macros. */