diff options
author | igor@rurik.mysql.com <> | 2003-06-12 04:29:02 -0700 |
---|---|---|
committer | igor@rurik.mysql.com <> | 2003-06-12 04:29:02 -0700 |
commit | f547f2769f6419384d2def370d579e1d672dec5e (patch) | |
tree | 0a5a6a2ab9cef24b378ef32a9096714667680cc5 /sql/ha_myisam.cc | |
parent | 7009100cde6a20913eee42f9dba6d81ad3014e70 (diff) | |
download | mariadb-git-f547f2769f6419384d2def370d579e1d672dec5e.tar.gz |
Many files:
New feature: preload indexes into key cache.
mi_preload.c:
new file
Many files:
Added preload statement.
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r-- | sql/ha_myisam.cc | 66 |
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 ¶m, 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(¶m); + 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(¶m, errmsg); + DBUG_RETURN(error); + } +} + +/* Deactive all not unique index that can be recreated fast SYNOPSIS |