diff options
author | unknown <holyfoot@deer.(none)> | 2006-06-01 17:06:42 +0500 |
---|---|---|
committer | unknown <holyfoot@deer.(none)> | 2006-06-01 17:06:42 +0500 |
commit | eadcf20081b18b28f344552a9902fea2404d55bd (patch) | |
tree | d38087a9ddc2cb5e7182d44fada846bcf265fc41 /libmysql | |
parent | b29e052dbfe5021fefb5d312860a4980c851c24b (diff) | |
download | mariadb-git-eadcf20081b18b28f344552a9902fea2404d55bd.tar.gz |
bug #16017 (memory leaks in embedded server)
There actually was 3 different problems -
hash_user_connections wasn't cleaned
one strdupped database name wasn't freed
and stmt->mem_root wasn't cleaned as it was
replased with mysql->field_alloc for result
For the last one - i made the library using stmt's
fields to store result if it's the case.
include/mysql.h:
statement pointer added to the advanced_command to be checked in
embedded server
include/sql_common.h:
stmt added to the cli_advanced_command interface
libmysql/libmysql.c:
stmt pointer now sent to advanced_command
libmysqld/embedded_priv.h:
it's enough to send database name to check_embedded_connection
libmysqld/lib_sql.cc:
Now we store result directly in the MYSQL_STMT structure to
avoid extra copying
libmysqld/libmysqld.c:
it's enough to only send database pointer to check_embedded_connection
sql-common/client.c:
stmt fake attribute added to cli_advanced_command
sql/sql_parse.cc:
hash_user_connections isn't used if no access checks compiled
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4b8f1c9da1f..0f246b3030e 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2085,7 +2085,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) mysql_use_result it won't be freed in mysql_stmt_free_result and we should get 'Commands out of sync' here. */ - if (simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1)) + if (stmt_command(mysql, COM_CLOSE_STMT, buff, 4, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -2094,7 +2094,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) stmt->state= MYSQL_STMT_INIT_DONE; } - if (simple_command(mysql, COM_PREPARE, query, length, 1)) + if (stmt_command(mysql, COM_PREPARE, query, length, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -2505,7 +2505,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) buff[4]= (char) 0; /* no flags */ int4store(buff+5, 1); /* iteration count */ if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), - packet, length, 1) || + packet, length, 1, NULL) || (*mysql->methods->read_query_result)(mysql)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); @@ -3279,7 +3279,8 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, This is intentional to save bandwidth. */ if ((*mysql->methods->advanced_command)(mysql, COM_LONG_DATA, buff, - sizeof(buff), data, length, 1)) + sizeof(buff), data, length, 1, + NULL)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -4603,7 +4604,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) mysql->status= MYSQL_STATUS_READY; } int4store(buff, stmt->stmt_id); - if ((rc= simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1))) + if ((rc= stmt_command(mysql, COM_CLOSE_STMT, buff, 4, stmt))) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -4641,7 +4642,7 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) mysql= stmt->mysql->last_used_con; int4store(buff, stmt->stmt_id); /* Send stmt id to server */ if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff, - sizeof(buff), 0, 0, 0)) + sizeof(buff), 0, 0, 0, 0)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); |