From 215473ea827aa24a29baa2a2d0d7a5015473752c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 12 Feb 2017 07:43:51 +0000 Subject: [PATCH] Fix bug #897 : crash with PS multiple users COM_CHANGE_USER could try to reset PS already invalidated from the PS manager. --- .../mariadb-client-library/libmariadb.c.patch | 32 +++++++++++++++++-- lib/MySQL_PreparedStatement.cpp | 3 ++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/deps/mariadb-client-library/libmariadb.c.patch b/deps/mariadb-client-library/libmariadb.c.patch index 79772f33a..88f895dbd 100644 --- a/deps/mariadb-client-library/libmariadb.c.patch +++ b/deps/mariadb-client-library/libmariadb.c.patch @@ -16,6 +16,34 @@ if (mysql->client_flag & CLIENT_COMPRESS) net->compress= 1; +@@ -2217,7 +2223,7 @@ + + if (rc==0) + { +- LIST *li_stmt= mysql->stmts; ++ //LIST *li_stmt= mysql->stmts; // see bug #897 + my_free(s_user); + my_free(s_passwd); + my_free(s_db); +@@ -2230,12 +2236,12 @@ + rc= 1; + } + +- for (;li_stmt;li_stmt= li_stmt->next) +- { +- MYSQL_STMT *stmt= (MYSQL_STMT *)li_stmt->data; +- stmt->mysql= NULL; +- SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0); +- }/* detach stmts */ ++ //for (;li_stmt;li_stmt= li_stmt->next) // see bug #897 ++ //{ ++ // MYSQL_STMT *stmt= (MYSQL_STMT *)li_stmt->data; ++ // stmt->mysql= NULL; ++ // SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0); ++ //}/* detach stmts */ + mysql->stmts= NULL; + + } else @@ -2395,6 +2401,36 @@ /* Clear pointers for better safety */ bzero((char*) &mysql->options,sizeof(mysql->options)); @@ -29,11 +57,11 @@ +void STDCALL +mysql_close_no_command(MYSQL *mysql) +{ -+ MYSQL_STMT *stmt; ++ //MYSQL_STMT *stmt; + DBUG_ENTER("mysql_close"); + if (mysql) /* Some simple safety */ + { -+ LIST *li_stmt= mysql->stmts; ++ //LIST *li_stmt= mysql->stmts; + + if (mysql->methods) { + if (mysql->net.vio) { diff --git a/lib/MySQL_PreparedStatement.cpp b/lib/MySQL_PreparedStatement.cpp index b3743914e..6aecca908 100644 --- a/lib/MySQL_PreparedStatement.cpp +++ b/lib/MySQL_PreparedStatement.cpp @@ -70,6 +70,9 @@ MySQL_STMTs_local::~MySQL_STMTs_local() { uint32_t stmt_id=it->first; MYSQL_STMT *stmt=it->second; if (stmt) { // is a server + if (stmt->mysql) { + stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list); + } // we do a hack here: we pretend there is no server associate // the connection will be dropped anyway immediately after stmt->mysql=NULL;