diff options
author | igor@rurik.mysql.com <> | 2003-08-26 00:13:22 -0700 |
---|---|---|
committer | igor@rurik.mysql.com <> | 2003-08-26 00:13:22 -0700 |
commit | 40193a7fa5c302129669d3071200b117c998d36a (patch) | |
tree | 8f6c56f59666be1b54701f57e779e904575b1a4a /sql/sql_table.cc | |
parent | 5b28d4a9a49a2d1c3225044b2cc82aa9e840687f (diff) | |
parent | 994a1ea3379566fdd4ae085d23a809727a70ce60 (diff) | |
download | mariadb-git-40193a7fa5c302129669d3071200b117c998d36a.tar.gz |
Manual merge
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 37f8d0d7f4f..0803ce5a530 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1564,6 +1564,96 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) /* + Assigned specified indexes for a table into key cache + + SYNOPSIS + mysql_assign_to_keycache() + thd Thread object + tables Table list (one table only) + + RETURN VALUES + 0 ok + -1 error +*/ + +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_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 SYNOPSIS |