diff options
author | unknown <igor@rurik.mysql.com> | 2003-10-01 20:20:17 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2003-10-01 20:20:17 -0700 |
commit | 09e7be1d821831eee3bdeb0126a92aa7c23bed7d (patch) | |
tree | 1e1f87443b0524fc4518025161bb250daa10cb18 /sql/handler.cc | |
parent | 7c7ee4d2f4ae29df2167b0ca0e9ab6dfd93a1c07 (diff) | |
download | mariadb-git-09e7be1d821831eee3bdeb0126a92aa7c23bed7d.tar.gz |
Manual merge after improving concurrency for key cache reassignment
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index e14e326792d..1d12171cbd0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -739,6 +739,11 @@ int handler::analyze(THD* thd, HA_CHECK_OPT* check_opt) return HA_ADMIN_NOT_IMPLEMENTED; } +int handler::assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt) +{ + return HA_ADMIN_NOT_IMPLEMENTED; +} + int handler::preload_keys(THD* thd, HA_CHECK_OPT* check_opt) { return HA_ADMIN_NOT_IMPLEMENTED; @@ -1105,27 +1110,61 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, /* Use key cacheing on all databases */ -void ha_key_cache(void) +int ha_key_cache(KEY_CACHE_VAR *key_cache) { - /* - The following mutex is not really needed as long as keybuff_size is - treated as a long value, but we use the mutex here to guard for future - changes. - */ - pthread_mutex_lock(&LOCK_global_system_variables); - long tmp= (long) keybuff_size; - pthread_mutex_unlock(&LOCK_global_system_variables); - if (tmp) - (void) init_key_cache(tmp); + if (!key_cache->cache) + { + /* + The following mutex is not really needed as long as keybuff_size is + treated as a long value, but we use the mutex here to guard for future + changes. + */ + pthread_mutex_lock(&LOCK_global_system_variables); + if (!key_cache->block_size) + key_cache->block_size= dflt_key_cache_block_size; + if (!key_cache->buff_size) + key_cache->buff_size= dflt_key_buff_size; + long tmp_buff_size= (long) key_cache->buff_size; + long tmp_block_size= (long) key_cache->block_size; + pthread_mutex_unlock(&LOCK_global_system_variables); + return !init_key_cache(&key_cache->cache, + tmp_block_size, + tmp_buff_size, + key_cache); + } + return 0; } -void ha_resize_key_cache(void) + if (key_cache->cache) + { + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp_buff_size= (long) key_cache->buff_size; + long tmp_block_size= (long) key_cache->block_size; + pthread_mutex_unlock(&LOCK_global_system_variables); + return !resize_key_cache(&key_cache->cache, tmp_block_size, + tmp_buff_size); + } + return 0; +} + +int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache) +{ + if (key_cache->cache) + { + change_key_cache_param(key_cache->cache); + } + return 0; +} + +int ha_end_key_cache(KEY_CACHE_VAR *key_cache) { - pthread_mutex_lock(&LOCK_global_system_variables); - long tmp= (long) keybuff_size; - pthread_mutex_unlock(&LOCK_global_system_variables); - (void) resize_key_cache(tmp); + if (key_cache->cache) + { + end_key_cache(&key_cache->cache, 1); + return key_cache->cache ? 1 : 0; + } + return 0; } |