summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorigor@rurik.mysql.com <>2003-10-30 10:45:28 -0800
committerigor@rurik.mysql.com <>2003-10-30 10:45:28 -0800
commitf29ed57531b99b09a81b6f68b570ef3a5a26d865 (patch)
treebfd8508896ec045400e82650920bcfd37e53a8f1 /sql/sql_table.cc
parent2dadbb3153f7d2f98f4ef37f7758e59e3959a831 (diff)
parentf17ff0bc39135b417a3a120dbb59d5a9389d8221 (diff)
downloadmariadb-git-f29ed57531b99b09a81b6f68b570ef3a5a26d865.tar.gz
Merge
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc106
1 files changed, 106 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3d07c7e04de..ba172aa6bda 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1588,6 +1588,112 @@ 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)
+ {
+ bool refresh;
+ VOID(pthread_mutex_unlock(&LOCK_assign));
+ bzero((byte *) &table, sizeof(table));
+ table.option= dest_name;
+ table.db= key_cache_asmt->db_name;
+ table.alias= table.real_name= key_cache_asmt->table_name;
+ thd->open_options|= HA_OPEN_TO_ASSIGN;
+ while (!(table.table=open_table(thd,table.db,
+ table.real_name,table.alias,
+ &refresh)) && refresh) ;
+ thd->open_options&= ~HA_OPEN_TO_ASSIGN;
+ if (!table.table)
+ DBUG_RETURN(-1);
+ 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;
+ }
+
+ while (src_cache->assignments)
+ {
+ struct st_my_thread_var *waiting_thread= my_thread_var;
+ pthread_cond_wait(&waiting_thread->suspend, &LOCK_assign);
+ }
+ if (src_cache->extra_info)
+ {
+ my_free((char *) src_cache->extra_info, MYF(0));
+ src_cache->extra_info= 0;
+ }
+
+ 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