summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-09-22 15:50:07 +0400
committerunknown <konstantin@mysql.com>2004-09-22 15:50:07 +0400
commitccf52b4fd5bd7ae0a418d22f2758cef345b6afa6 (patch)
treee9e451c78db8c48bfcfbf6943d785f85d1b8a6f8 /sql/sql_class.h
parentd594d40d119fd536657be3b1523bd5b48f15fa1e (diff)
downloadmariadb-git-ccf52b4fd5bd7ae0a418d22f2758cef345b6afa6.tar.gz
A fix and test case for Bug#5315 "mysql_change_user() doesn't free
prepared statements." include/hash.h: New declaration for hash_reset() function. The old version was not used. libmysql/client_settings.h: Declaration for mysql_detach_stmt_list(). libmysql/libmysql.c: Fix for bug#5315 "mysql_change_user() doesn't free prepared statements": add call to mysql_detach_stmt_list(prepared statements) to mysql_change_user(): all statements are freed by server, so client counterparts need to be marked as not usable. mysys/hash.c: Fix for bug#5315 "mysql_change_user() doesn't free prepared statements": implementation of hash_reset(), which frees all hash elements and prepares the hash for reuse. sql-common/client.c: Fix for bug#5315 "mysql_change_user() doesn't free prepared statements": implementation of mysql_detach_stmt_list(): zero connection pointer in given statement list, thus marking given statements as not usable. sql/sql_class.cc: Fix for bug#5315 "mysql_change_user() doesn't free prepared statements": reset prepared statements map in THD::change_user(). sql/sql_class.h: Fix for bug#5315 "mysql_change_user() doesn't free prepared statements": implementation of Statement_map::reset(). A little cleanup of ~Statement_map(): first empty names_hash, as st_hash has a free function, which will delete statements. tests/client_test.c: A test case for bug #5315 "mysql_change_user() doesn't free prepared statements".
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 387bba43cad..09b44568f90 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -566,7 +566,7 @@ public:
assignment in Statement::Statement)
Non-empty statement names are unique too: attempt to insert a new statement
with duplicate name causes older statement to be deleted
-
+
Statements are auto-deleted when they are removed from the map and when the
map is deleted.
*/
@@ -575,7 +575,7 @@ class Statement_map
{
public:
Statement_map();
-
+
int insert(Statement *statement);
Statement *find_by_name(LEX_STRING *name)
@@ -608,11 +608,18 @@ public:
}
hash_delete(&st_hash, (byte *) statement);
}
+ /* Erase all statements (calls Statement destructor) */
+ void reset()
+ {
+ hash_reset(&names_hash);
+ hash_reset(&st_hash);
+ last_found_statement= 0;
+ }
~Statement_map()
{
- hash_free(&st_hash);
hash_free(&names_hash);
+ hash_free(&st_hash);
}
private:
HASH st_hash;