summaryrefslogtreecommitdiff
path: root/sql/ha_myisam.cc
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2003-06-12 04:29:02 -0700
committerunknown <igor@rurik.mysql.com>2003-06-12 04:29:02 -0700
commitf7aed0240511510dfe51083bd7ff12482d8716bc (patch)
tree0a5a6a2ab9cef24b378ef32a9096714667680cc5 /sql/ha_myisam.cc
parent767f0a9f0e124667275a3a4f4a4874974444b842 (diff)
downloadmariadb-git-f7aed0240511510dfe51083bd7ff12482d8716bc.tar.gz
Many files:
New feature: preload indexes into key cache. mi_preload.c: new file Many files: Added preload statement. sql/ha_myisam.h: Added preload statement. sql/handler.cc: Added preload statement. sql/lex.h: Added preload statement. sql/mysql_priv.h: Added preload statement. sql/sql_lex.h: Added preload statement. sql/sql_base.cc: Added preload statement. sql/sql_table.cc: New feature: preload indexes into key cache. sql/sql_parse.cc: New feature: preload indexes into key cache. sql/mysqld.cc: New feature: preload indexes into key cache. sql/set_var.cc: New feature: preload indexes into key cache. sql/sql_yacc.yy: New feature: preload indexes into key cache. sql/ha_myisam.cc: New feature: preload indexes into key cache. sql/table.h: New feature: preload indexes into key cache. mysys/mf_keycache.c: New feature: preload indexes into key cache. myisam/myisamdef.h: New feature: preload indexes into key cache. myisam/mi_extra.c: New feature: preload indexes into key cache. myisam/Makefile.am: New feature: preload indexes into key cache. include/my_base.h: New feature: preload indexes into key cache. include/my_sys.h: New feature: preload indexes into key cache. include/myisam.h: New feature: preload indexes into key cache.
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r--sql/ha_myisam.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 213f5baf388..d9b9f3130de 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -675,6 +675,72 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
/*
+ Preload pages of the index file for a table into the key cache.
+*/
+
+int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
+{
+ int error;
+ const char *errmsg;
+ ulonglong map= ~(ulonglong) 0;
+ TABLE_LIST *table_list= table->pos_in_table_list;
+ my_bool ignore_leaves= table_list->ignore_leaves;
+
+ DBUG_ENTER("ha_myisam::preload_keys");
+
+ /* Check validity of the index references */
+ if (table_list->use_index)
+ {
+ key_map kmap= get_key_map_from_key_list(table, table_list->use_index);
+ if (kmap == ~(key_map) 0)
+ {
+ errmsg= thd->net.last_error;
+ error= HA_ADMIN_FAILED;
+ goto err;
+ }
+ if (kmap)
+ map= kmap;
+ }
+
+ mi_extra(file, HA_EXTRA_PRELOAD_BUFFER_SIZE,
+ (void *) &thd->variables.preload_buff_size);
+
+ if ((error= mi_preload(file, map, ignore_leaves)))
+ {
+ switch (error) {
+ case HA_ERR_NON_UNIQUE_BLOCK_SIZE:
+ errmsg= "Indexes use different block sizes";
+ break;
+ case HA_ERR_OUT_OF_MEM:
+ errmsg= "Failed to allocate buffer";
+ break;
+ default:
+ char buf[ERRMSGSIZE+20];
+ my_snprintf(buf, ERRMSGSIZE,
+ "Failed to read from index file (errno: %d)", my_errno);
+ errmsg= buf;
+ }
+ error= HA_ADMIN_FAILED;
+ goto err;
+ }
+
+ DBUG_RETURN(HA_ADMIN_OK);
+
+ err:
+ {
+ MI_CHECK param;
+ myisamchk_init(&param);
+ param.thd= thd;
+ param.op_name= (char*)"preload_keys";
+ param.db_name= table->table_cache_key;
+ param.table_name= table->table_name;
+ param.testflag= 0;
+ mi_check_print_error(&param, errmsg);
+ DBUG_RETURN(error);
+ }
+}
+
+/*
Deactive all not unique index that can be recreated fast
SYNOPSIS