summaryrefslogtreecommitdiff
path: root/sql/ha_myisam.cc
diff options
context:
space:
mode:
authormonty@mashka.mysql.fi <>2003-11-18 13:47:27 +0200
committermonty@mashka.mysql.fi <>2003-11-18 13:47:27 +0200
commitcab1dc628c116f042a3fd8dbc505f7ca2df599a3 (patch)
tree0a23d90c946c5f05a8c160fc7c6ef3f05505fc79 /sql/ha_myisam.cc
parentf277c9f88a4a2e392e44cfdb6b3f4785b6c730d0 (diff)
downloadmariadb-git-cab1dc628c116f042a3fd8dbc505f7ca2df599a3.tar.gz
CLIENT_MULTI_QUERIES -> CLIENT_MULTI_STATEMENTS
New multi-key-cache handling. This was needed becasue the old one didn't work reliable with MERGE tables. ALTER TABLE table_name ... CHARACTER SET ... now changes all char/varchar/text columns to the given character set (One must use ALTER TABLE ... DEFAULT CHARACTER SET ... to change the default character set) Fixed that have_compress is detected properly (fixes problems with func_compress.test on platforms without zlib) New syntax for CACHE INDEX ('keys' is optional if no index name is given and one mentions the key cache name only ones) Removed compiler warnings Added mysql_set_server_option() to allow clients like PHP to easaily set/reset the multi-statement flag.
Diffstat (limited to 'sql/ha_myisam.cc')
-rw-r--r--sql/ha_myisam.cc103
1 files changed, 14 insertions, 89 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 52a5398bdd8..0f22a83a2b4 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -226,15 +226,10 @@ err:
int ha_myisam::open(const char *name, int mode, uint test_if_locked)
{
+ KEY_CACHE_VAR *key_cache;
if (!(file=mi_open(name, mode, test_if_locked)))
return (my_errno ? my_errno : -1);
- /* Synchronize key cache assignment of the handler */
- KEY_CACHE_VAR *key_cache= table->key_cache ? table->key_cache :
- &dflt_key_cache_var;
- VOID(mi_extra(file, HA_EXTRA_SET_KEY_CACHE,
- (void*) &key_cache->cache));
-
if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0));
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
@@ -698,93 +693,48 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
/*
- Assign table indexes to a key cache.
+ Assign table indexes to a specific key cache.
*/
int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
{
- uint len;
- KEY_CACHE_VAR *old_key_cache;
- KEY_CACHE_VAR *new_key_cache;
- const char *errmsg=0;
+ KEY_CACHE_VAR *new_key_cache= check_opt->key_cache;
+ const char *errmsg= 0;
int error= HA_ADMIN_OK;
ulonglong map= ~(ulonglong) 0;
TABLE_LIST *table_list= table->pos_in_table_list;
- const char *new_key_cache_name= table_list->option ?
- (const char *) table_list->option :
- DEFAULT_KEY_CACHE_NAME;
- KEY_CACHE_ASMT *key_cache_asmt= table->key_cache_asmt;
- bool triggered= key_cache_asmt->triggered;
-
DBUG_ENTER("ha_myisam::assign_to_keycache");
- VOID(pthread_mutex_lock(&LOCK_assign));
-
- old_key_cache= key_cache_asmt->key_cache;
-
/* Check validity of the index references */
- if (!triggered && table_list->use_index)
+ if (table_list->use_index)
{
+ /* We only come here when the user did specify an index map */
key_map kmap;
- get_key_map_from_key_list(&kmap, table, table_list->use_index);
- if (kmap.is_set_all())
+ if (get_key_map_from_key_list(&kmap, table, table_list->use_index))
{
errmsg= thd->net.last_error;
error= HA_ADMIN_FAILED;
goto err;
}
- if (!kmap.is_clear_all())
- map= kmap.to_ulonglong();
- }
-
- len= strlen(new_key_cache_name);
- new_key_cache= get_or_create_key_cache(new_key_cache_name, len);
- if (old_key_cache == new_key_cache)
- {
- /* Nothing to do: table is assigned to the same key cache */
- goto ok;
- }
-
- if (!new_key_cache ||
- (!new_key_cache->cache && ha_key_cache(new_key_cache)))
- {
- if (key_cache_asmt->triggered)
- error= HA_ERR_OUT_OF_MEM;
- else
- {
- char buf[ERRMSGSIZE];
- my_snprintf(buf, ERRMSGSIZE,
- "Failed to create key cache %s", new_key_cache_name);
- errmsg= buf;
- error= HA_ADMIN_FAILED;
- }
- goto err;
+ map= kmap.to_ulonglong();
}
- reassign_key_cache(key_cache_asmt, new_key_cache);
-
- VOID(pthread_mutex_unlock(&LOCK_assign));
- error= mi_assign_to_keycache(file, map, new_key_cache, &LOCK_assign);
- VOID(pthread_mutex_lock(&LOCK_assign));
-
- if (error && !key_cache_asmt->triggered)
+ if ((error= mi_assign_to_key_cache(file, map, new_key_cache)))
{
switch (error) {
default:
- char buf[ERRMSGSIZE+20];
- my_snprintf(buf, ERRMSGSIZE,
- "Failed to flush to index file (errno: %d)", my_errno);
+ char buf[80];
+ my_snprintf(buf, sizeof(buf),
+ "Failed to flush to index file (errno: %d)", error);
errmsg= buf;
}
error= HA_ADMIN_CORRUPT;
- goto err;
}
- goto ok;
-
err:
- if (!triggered)
+ if (error != HA_ADMIN_OK)
{
+ /* Send error to user */
MI_CHECK param;
myisamchk_init(&param);
param.thd= thd;
@@ -793,32 +743,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
param.table_name= table->table_name;
param.testflag= 0;
mi_check_print_error(&param, errmsg);
- }
-
- ok:
- if (--key_cache_asmt->requests)
- {
- /* There is a queue of assignments for the table */
-
- /* Remove the first member from the queue */
- struct st_my_thread_var *last= key_cache_asmt->queue;
- struct st_my_thread_var *thread= last->next;
- if (thread->next == thread)
- key_cache_asmt->queue= 0;
- else
- {
- last->next= thread->next;
- last->next->prev= &last->next;
- thread->next= 0;
- }
- /* Signal the first waiting thread to proceed */
- VOID(pthread_cond_signal(&thread->suspend));
}
-
- key_cache_asmt->triggered= 0;
-
- VOID(pthread_mutex_unlock(&LOCK_assign));
-
DBUG_RETURN(error);
}