Fix crash when attempting to log failed 'SET NAMES'

Session 'status' and 'client_myds->DSS' should never be modified for a
regular session prior to calling 'RequestEnd'. It's 'RequestEnd'
responsibility to appropriately change these statuses after the rest of
cleanup operations for the request has taken place, including logging.
pull/4232/head
Javier Jaramago Fernández 3 years ago
parent 28d790a6e6
commit ff2e1a2b85

@ -130,9 +130,21 @@ class MySQL_Session
bool handler_CommitRollback(PtrSize_t *);
bool handler_SetAutocommit(PtrSize_t *);
/**
* @brief Performs the cleanup of current session state, and the required operations to the supplied
* 'MySQL_Data_Stream' required for processing further queries.
* @param The 'MySQL_Data_Stream' which executed the previous query and which status should be updated.
* @brief Should execute most of the commands executed when a request is finalized.
* @details Cleanup of current session state, and required operations to the supplied 'MySQL_Data_Stream'
* for further queries processing. Takes care of the following actions:
* - Update the status of the backend connection (if supplied), with previous query actions.
* - Log the query for the required statuses.
* - Cleanup the previous Query_Processor output.
* - Free the resources of the backend connection (if supplied).
* - Reset all the required session status flags. E.g:
* + status
* + client_myds::DSS
* + started_sending_data_to_client
* + previous_hostgroup
* NOTE: Should become the place to hook other functions.
* @param myds If not null, should point to a MySQL_Data_Stream (backend connection) which connection status
* should be updated, and previous query resources cleanup.
*/
void RequestEnd(MySQL_Data_Stream *);
void LogQuery(MySQL_Data_Stream *);

@ -2480,8 +2480,6 @@ bool MySQL_Session::handler_again___status_CHANGING_CHARSET(int *_rc) {
client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,mysql_errno(myconn->mysql),sqlstate,mysql_error(myconn->mysql));
myds->destroy_MySQL_Connection_From_Pool(true);
myds->fd=0;
status=WAITING_CLIENT_DATA;
client_myds->DSS=STATE_SLEEP;
RequestEnd(myds);
}
} else {
@ -7466,8 +7464,6 @@ void MySQL_Session::LogQuery(MySQL_Data_Stream *myds) {
}
}
}
// this should execute most of the commands executed when a request is finalized
// this should become the place to hook other functions
void MySQL_Session::RequestEnd(MySQL_Data_Stream *myds) {
// check if multiplexing needs to be disabled
char *qdt = NULL;

Loading…
Cancel
Save