diff --git a/include/MySQL_Logger.hpp b/include/MySQL_Logger.hpp index eda0c7cb7..b50a1fe9a 100644 --- a/include/MySQL_Logger.hpp +++ b/include/MySQL_Logger.hpp @@ -429,6 +429,7 @@ public: * @brief Logs a request event. * @param sess A pointer to the MySQL_Session object. * @param myds A pointer to the MySQL_Data_Stream object. + * @param errmsg A pointer to an error, if present. * * This function logs information about a MySQL request, including the query, timestamps, user information, and other relevant details. * It creates a MySQL_Event object, populates it with data from the session and data stream, and writes it to the event log file and/or the circular buffer. @@ -439,7 +440,7 @@ public: * The function uses mutexes to protect shared resources and avoid race conditions. * The function assumes ownership of the dynamically allocated memory for the `MySQL_Event` object created within this function. */ - void log_request(MySQL_Session* sess, MySQL_Data_Stream* myds); + void log_request(MySQL_Session* sess, MySQL_Data_Stream* myds, const char * errmsg = nullptr); /** * @brief Logs an audit entry. diff --git a/include/MySQL_Session.h b/include/MySQL_Session.h index 2a593d3ce..8c58ecdba 100644 --- a/include/MySQL_Session.h +++ b/include/MySQL_Session.h @@ -197,8 +197,8 @@ class MySQL_Session * @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 *); + void RequestEnd(MySQL_Data_Stream * myds, const char * errmsg = nullptr); + void LogQuery(MySQL_Data_Stream * myds, const char * errmsg = nullptr); void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session(); int handler_again___status_PINGING_SERVER(); diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 72e283b88..dab147cca 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -739,7 +739,7 @@ void MySQL_Logger::audit_set_datadir(char *s) { flush_log(); }; -void MySQL_Logger::log_request(MySQL_Session *sess, MySQL_Data_Stream *myds) { +void MySQL_Logger::log_request(MySQL_Session *sess, MySQL_Data_Stream *myds, const char * errmsg) { int elmhs = mysql_thread___eventslog_buffer_history_size; if (elmhs == 0) { if (events.enabled==false) return; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index b40d92253..099649774 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -8002,24 +8002,24 @@ unsigned long long MySQL_Session::IdleTime() { // this is called either from RequestEnd(), or at the end of executing // prepared statements -void MySQL_Session::LogQuery(MySQL_Data_Stream *myds) { +void MySQL_Session::LogQuery(MySQL_Data_Stream *myds, const char * errmsg) { // we need to access statistics before calling CurrentQuery.end() // so we track the time here CurrentQuery.end_time=thread->curtime; if (qpo) { if (qpo->log==1) { - GloMyLogger->log_request(this, myds); // we send for logging only if logging is enabled for this query + GloMyLogger->log_request(this, myds, errmsg); // we send for logging only if logging is enabled for this query } else { if (qpo->log==-1) { if (mysql_thread___eventslog_default_log==1) { - GloMyLogger->log_request(this, myds); // we send for logging only if enabled by default + GloMyLogger->log_request(this, myds, errmsg); // we send for logging only if enabled by default } } } } } -void MySQL_Session::RequestEnd(MySQL_Data_Stream *myds) { +void MySQL_Session::RequestEnd(MySQL_Data_Stream *myds, const char * errmsg) { // check if multiplexing needs to be disabled char *qdt = NULL; @@ -8040,7 +8040,7 @@ void MySQL_Session::RequestEnd(MySQL_Data_Stream *myds) { break; default: if (session_fast_forward==false) { - LogQuery(myds); + LogQuery(myds, errmsg); } break; }