diff options
author | konstantin@mysql.com <> | 2004-09-22 15:50:07 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2004-09-22 15:50:07 +0400 |
commit | 36548b10ca2d796c46436ab445569f6e0476ecaf (patch) | |
tree | e9e451c78db8c48bfcfbf6943d785f85d1b8a6f8 /sql-common | |
parent | e7a70ed162f6b208ead1fa93824592f242b015bc (diff) | |
download | mariadb-git-36548b10ca2d796c46436ab445569f6e0476ecaf.tar.gz |
A fix and test case for Bug#5315 "mysql_change_user() doesn't free
prepared statements."
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 930388d2459..43e116eb0b6 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2239,6 +2239,32 @@ static void mysql_close_free(MYSQL *mysql) } +/* + Clear connection pointer of every statement: this is necessary + to give error on attempt to use a prepared statement of closed + connection. + + SYNOPSYS + mysql_detach_stmt_list() + stmt_list pointer to mysql->stmts +*/ + +void mysql_detach_stmt_list(LIST **stmt_list) +{ +#ifdef MYSQL_CLIENT + /* Reset connection handle in all prepared statements. */ + LIST *element= *stmt_list; + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + stmt->mysql= 0; + /* No need to call list_delete for statement here */ + } + *stmt_list= 0; +#endif /* MYSQL_CLIENT */ +} + + void STDCALL mysql_close(MYSQL *mysql) { DBUG_ENTER("mysql_close"); @@ -2255,20 +2281,7 @@ void STDCALL mysql_close(MYSQL *mysql) } mysql_close_free_options(mysql); mysql_close_free(mysql); -#ifdef MYSQL_CLIENT - if (mysql->stmts) - { - /* Reset connection handle in all prepared statements. */ - LIST *element; - for (element= mysql->stmts; element; element= element->next) - { - MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; - stmt->mysql= 0; - /* No need to call list_delete for statement here */ - } - mysql->stmts= 0; - } -#endif /*MYSQL_CLIENT*/ + mysql_detach_stmt_list(&mysql->stmts); #ifndef TO_BE_DELETED /* free/close slave list */ if (mysql->rpl_pivot) |