mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
ccf52b4fd5
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".
65 lines
2.2 KiB
C
65 lines
2.2 KiB
C
/* Copyright (C) 2000 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/* Dynamic hashing of record with different key-length */
|
|
|
|
#ifndef _hash_h
|
|
#define _hash_h
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
Overhead to store an element in hash
|
|
Can be used to approximate memory consumption for a hash
|
|
*/
|
|
#define HASH_OVERHEAD (sizeof(char*)*2)
|
|
|
|
typedef byte *(*hash_get_key)(const byte *,uint*,my_bool);
|
|
typedef void (*hash_free_key)(void *);
|
|
|
|
typedef struct st_hash {
|
|
uint key_offset,key_length; /* Length of key if const length */
|
|
uint records,blength,current_record;
|
|
uint flags;
|
|
DYNAMIC_ARRAY array; /* Place for hash_keys */
|
|
hash_get_key get_key;
|
|
void (*free)(void *);
|
|
CHARSET_INFO *charset;
|
|
} HASH;
|
|
|
|
#define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO)
|
|
my_bool _hash_init(HASH *hash, CHARSET_INFO *charset,
|
|
uint default_array_elements, uint key_offset,
|
|
uint key_length, hash_get_key get_key,
|
|
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
|
|
void hash_free(HASH *tree);
|
|
void hash_reset(HASH *hash);
|
|
byte *hash_element(HASH *hash,uint idx);
|
|
gptr hash_search(HASH *info,const byte *key,uint length);
|
|
gptr hash_next(HASH *info,const byte *key,uint length);
|
|
my_bool my_hash_insert(HASH *info,const byte *data);
|
|
my_bool hash_delete(HASH *hash,byte *record);
|
|
my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
|
|
void hash_replace(HASH *hash, uint idx, byte *new_row);
|
|
my_bool hash_check(HASH *hash); /* Only in debug library */
|
|
|
|
#define hash_inited(H) ((H)->array.buffer != 0)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|