Refactored calls to 'mysql_stmt_close' into function holding preparation of 'MYSQL_STMT*' parameter #3525

pull/3544/head
Javier Jaramago Fernández 5 years ago
parent 703d422973
commit 297bc8bae6

@ -229,6 +229,23 @@ inline unsigned long long realtime_time() {
clock_gettime(CLOCK_REALTIME, &ts);
return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
}
/**
* @brief ProxySQL replacement function for 'mysql_stmt_close'. Closes a
* MYSQL_STMT avoiding any blocking commands that are sent by default
* 'mysql_stmt_close'.
*
* NOTE: This function is not safe, caller must check that the supplied
* argument is not NULL.
*
* @param mysql_stmt An already initialized 'MYSQL_STMT'. Caller must ensure
* that the supplied argument is not NULL.
*
* @return The result of calling 'mysql_stmt_close' function over the internally
* modified 'MYSQL_STMT'.
*/
my_bool proxy_mysql_stmt_close(MYSQL_STMT* mysql_stmt);
#endif /* __GEN_FUNCTIONS */
bool Proxy_file_exists(const char *);

@ -691,12 +691,7 @@ MySQL_STMTs_local_v14::~MySQL_STMTs_local_v14() {
it != global_stmt_to_backend_stmt.end(); ++it) {
uint64_t global_stmt_id = it->first;
MYSQL_STMT *stmt = it->second;
if (stmt->mysql) {
stmt->mysql->stmts =
list_delete(stmt->mysql->stmts, &stmt->list);
}
stmt->mysql = NULL;
mysql_stmt_close(stmt);
proxy_mysql_stmt_close(stmt);
GloMyStmt->ref_count_server(global_stmt_id, -1);
}
}

@ -219,3 +219,15 @@ bool Proxy_file_regular(const char *path) {
if (sb.st_mode & S_IFREG) return true;
return false;
}
my_bool proxy_mysql_stmt_close(MYSQL_STMT* stmt) {
// Clean internal structures for 'stmt->mysql->stmts'.
if (stmt->mysql) {
stmt->mysql->stmts =
list_delete(stmt->mysql->stmts, &stmt->list);
}
// Nullify 'mysql' field to avoid sending a blocking command to the server.
stmt->mysql = NULL;
// Perform the regular close operation.
return mysql_stmt_close(stmt);
}

@ -2151,7 +2151,7 @@ void MySQL_Connection::async_free_result() {
// initialized, it must be freed. For more context see #3525.
if (this->async_state_machine == ASYNC_STMT_PREPARE_FAILED) {
if (query.stmt != NULL) {
mysql_stmt_close(query.stmt);
proxy_mysql_stmt_close(query.stmt);
}
}
query.stmt=NULL;

Loading…
Cancel
Save