Skip to content

Commit

Permalink
Fix bug #897 : crash with PS multiple users
Browse files Browse the repository at this point in the history
COM_CHANGE_USER could try to reset PS already invalidated from the PS manager.
  • Loading branch information
renecannao committed Feb 12, 2017
1 parent 27d2c8a commit 215473e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
32 changes: 30 additions & 2 deletions deps/mariadb-client-library/libmariadb.c.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions lib/MySQL_PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 215473e

Please sign in to comment.