diff options
author | igor@rurik.mysql.com <> | 2003-08-02 02:43:18 -0700 |
---|---|---|
committer | igor@rurik.mysql.com <> | 2003-08-02 02:43:18 -0700 |
commit | 9306f55d8e62aca4e00dab3408a8395af85fb947 (patch) | |
tree | add5cbee3049a38799b03ee640b5ae06fbc34ef1 /sql/sql_table.cc | |
parent | f0ca5d545d801a5c1efdda878a5f85079c30f428 (diff) | |
download | mariadb-git-9306f55d8e62aca4e00dab3408a8395af85fb947.tar.gz |
Many files:
Added key cache assignment
mi_locking.c:
Added key cache assignment: correction
my_sys.h:
Added key cache variable structure
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 28208e4220f..0a873375471 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1577,10 +1577,79 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables) { DBUG_ENTER("mysql_assign_to_keycache"); DBUG_RETURN(mysql_admin_table(thd, tables, 0, - "assign_to_keycache", TL_WRITE, 0, 0, 0, + "assign_to_keycache", TL_READ, 0, + HA_OPEN_TO_ASSIGN, 0, &handler::assign_to_keycache)); } + +/* + Reassign all tables assigned to a key cache to another key cache + + SYNOPSIS + reassign_keycache_tables() + thd Thread object + src_cache Reference to the key cache to clean up + dest_name Name of the cache to assign tables to + remove_fl Flag to destroy key cache when all tables are reassigned + + RETURN VALUES + 0 ok + -1 error +*/ + +int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR* src_cache, + char *dest_name, bool remove_fl) +{ + int rc= 0; + TABLE_LIST table; + KEY_CACHE_ASMT *key_cache_asmt; + + DBUG_ENTER("reassign_keycache_tables"); + + VOID(pthread_mutex_lock(&LOCK_assign)); + for (key_cache_asmt= src_cache->assign_list ; + key_cache_asmt; + key_cache_asmt= key_cache_asmt->next) + key_cache_asmt->to_reassign = 1; + key_cache_asmt= src_cache->assign_list; + while (key_cache_asmt) + { + if (key_cache_asmt->to_reassign) + { + VOID(pthread_mutex_unlock(&LOCK_assign)); + bzero((byte *) &table, sizeof(table)); + table.option= dest_name; + table.lock_type= TL_READ; + table.db= key_cache_asmt->db_name; + table.alias= table.real_name= key_cache_asmt->table_name; + thd->open_options|= HA_OPEN_TO_ASSIGN; + table.table = open_ltable(thd, &table, TL_READ); + thd->open_options&= ~HA_OPEN_TO_ASSIGN; + table.table->pos_in_table_list= &table; + key_cache_asmt->triggered= 1; + rc= table.table->file->assign_to_keycache(thd, 0); + close_thread_tables(thd); + if (rc) + DBUG_RETURN(rc); + VOID(pthread_mutex_lock(&LOCK_assign)); + key_cache_asmt= src_cache->assign_list; + continue; + } + else + key_cache_asmt= key_cache_asmt->next; + } + if (remove_fl && !src_cache->assign_list && src_cache != &dflt_key_cache_var) + { + end_key_cache(&src_cache->cache, 1); + src_cache->buff_size= 0; + src_cache->block_size= 0; + } + VOID(pthread_mutex_unlock(&LOCK_assign)); + DBUG_RETURN(0); +} + + /* Preload specified indexes for a table into key cache |