mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
45199f545c
Cleanup of mi_print_error() handling Deleted 'merge' directory BitKeeper/deleted/.del-mrg_close.c~1fa9230422daa62a: Delete: merge/mrg_close.c BitKeeper/deleted/.del-mrg_create.c~b747c8ec2b801f6: Delete: merge/mrg_create.c BitKeeper/deleted/.del-mrg_delete.c~38b4156885bb4537: Delete: merge/mrg_delete.c BitKeeper/deleted/.del-mrg_extra.c~7eb6181e1761907e: Delete: merge/mrg_extra.c BitKeeper/deleted/.del-mrg_info.c~37728e7238cc5a11: Delete: merge/mrg_info.c BitKeeper/deleted/.del-mrg_locking.c~112756a2d581e1d0: Delete: merge/mrg_locking.c BitKeeper/deleted/.del-mrg_open.c~6e1d5c8bfa62a519: Delete: merge/mrg_open.c BitKeeper/deleted/.del-mrg_panic.c~e204e43cd6d55406: Delete: merge/mrg_panic.c BitKeeper/deleted/.del-mrg_rrnd.c~6087c3dd7ecb77: Delete: merge/mrg_rrnd.c BitKeeper/deleted/.del-mrg_rsame.c~3e8ed4be2a0952b1: Delete: merge/mrg_rsame.c BitKeeper/deleted/.del-mrg_static.c~75a4b78a165dbd0: Delete: merge/mrg_static.c BitKeeper/deleted/.del-mrg_update.c~4110a4f1fbf1ab45: Delete: merge/mrg_update.c BitKeeper/deleted/.del-Makefile.am~41238af048e60515: Delete: merge/Makefile.am BitKeeper/deleted/.del-make-ccc~4f1acbfc127e25d5: Delete: merge/make-ccc BitKeeper/deleted/.del-mrg_def.h~a10557d12a87ef1c: Delete: merge/mrg_def.h BitKeeper/deleted/.del-.cvsignore~2f287ba794db3da7: Delete: merge/.cvsignore include/myisam.h: Added 'share' to st_mi_keydef' to not have to pass 'st_myisam_info' to functions myisam/ft_static.c: Removed compiler warning myisam/mi_delete.c: Cleanup of mi_print_error() handling Break if get_key() return 0 Don't test for HA_ERR_CRASHED; Print errors when my_errno is set myisam/mi_extra.c: Cleanup of mi_print_error() handling myisam/mi_key.c: Cleanup of mi_print_error() handling myisam/mi_keycache.c: Cleanup of mi_print_error() handling myisam/mi_locking.c: Cleanup of mi_print_error() handling myisam/mi_open.c: Added 'my_isam_share' to MI_KEYDEF myisam/mi_page.c: Cleanup of mi_print_error() handling myisam/mi_range.c: get_key() calls mi_print_error() if needed myisam/mi_rkey.c: Cleanup of mi_print_error() handling myisam/mi_search.c: Cleanup of mi_print_error() handling Break if get_key() return 0 Don't test for HA_ERR_CRASHED; Print errors when my_errno is set myisam/mi_update.c: Cleanup of mi_print_error() handling myisam/mi_write.c: Cleanup of mi_print_error() handling Break if get_key() return 0 Don't test for HA_ERR_CRASHED; Print errors when my_errno is set myisam/myisamdef.h: Cleanup of mi_print_error() handling mysql-test/r/grant.result: Update results after merge mysql-test/r/timezone2.result: Update results after merge mysql-test/t/grant.test: New error numbers mysql-test/t/timezone2.test: New error numbers sql/item_func.cc: Remove duplicate include file sql/sql_acl.cc: Remove warnings from valgrind sql/tztime.cc: Print wrong timezone names to log
162 lines
5.2 KiB
C
162 lines
5.2 KiB
C
/* Copyright (C) 2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/*
|
|
Key cache assignments
|
|
*/
|
|
|
|
#include "myisamdef.h"
|
|
|
|
/*
|
|
Assign pages of the index file for a table to a key cache
|
|
|
|
SYNOPSIS
|
|
mi_assign_to_key_cache()
|
|
info open table
|
|
key_map map of indexes to assign to the key cache
|
|
key_cache_ptr pointer to the key cache handle
|
|
assign_lock Mutex to lock during assignment
|
|
|
|
PREREQUESTS
|
|
One must have a READ lock or a WRITE lock on the table when calling
|
|
the function to ensure that there is no other writers to it.
|
|
|
|
The caller must also ensure that one doesn't call this function from
|
|
two different threads with the same table.
|
|
|
|
NOTES
|
|
At present pages for all indexes must be assigned to the same key cache.
|
|
In future only pages for indexes specified in the key_map parameter
|
|
of the table will be assigned to the specified key cache.
|
|
|
|
RETURN VALUE
|
|
0 If a success
|
|
# Error code
|
|
*/
|
|
|
|
int mi_assign_to_key_cache(MI_INFO *info,
|
|
ulonglong key_map __attribute__((unused)),
|
|
KEY_CACHE *key_cache)
|
|
{
|
|
int error= 0;
|
|
MYISAM_SHARE* share= info->s;
|
|
DBUG_ENTER("mi_assign_to_key_cache");
|
|
DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx",
|
|
share->key_cache, key_cache));
|
|
|
|
/*
|
|
Skip operation if we didn't change key cache. This can happen if we
|
|
call this for all open instances of the same table
|
|
*/
|
|
if (share->key_cache == key_cache)
|
|
DBUG_RETURN(0);
|
|
|
|
/*
|
|
First flush all blocks for the table in the old key cache.
|
|
This is to ensure that the disk is consistent with the data pages
|
|
in memory (which may not be the case if the table uses delayed_key_write)
|
|
|
|
Note that some other read thread may still fill in the key cache with
|
|
new blocks during this call and after, but this doesn't matter as
|
|
all threads will start using the new key cache for their next call to
|
|
myisam library and we know that there will not be any changed blocks
|
|
in the old key cache.
|
|
*/
|
|
|
|
if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE))
|
|
{
|
|
error= my_errno;
|
|
mi_print_error(info->s, HA_ERR_CRASHED);
|
|
mi_mark_crashed(info); /* Mark that table must be checked */
|
|
}
|
|
|
|
/*
|
|
Flush the new key cache for this file. This is needed to ensure
|
|
that there is no old blocks (with outdated data) left in the new key
|
|
cache from an earlier assign_to_keycache operation
|
|
|
|
(This can never fail as there is never any not written data in the
|
|
new key cache)
|
|
*/
|
|
(void) flush_key_blocks(key_cache, share->kfile, FLUSH_RELEASE);
|
|
|
|
/*
|
|
ensure that setting the key cache and changing the multi_key_cache
|
|
is done atomicly
|
|
*/
|
|
pthread_mutex_lock(&share->intern_lock);
|
|
/*
|
|
Tell all threads to use the new key cache
|
|
This should be seen at the lastes for the next call to an myisam function.
|
|
*/
|
|
share->key_cache= key_cache;
|
|
|
|
/* store the key cache in the global hash structure for future opens */
|
|
if (multi_key_cache_set(share->unique_file_name, share->unique_name_length,
|
|
share->key_cache))
|
|
error= my_errno;
|
|
pthread_mutex_unlock(&share->intern_lock);
|
|
DBUG_RETURN(error);
|
|
}
|
|
|
|
|
|
/*
|
|
Change all MyISAM entries that uses one key cache to another key cache
|
|
|
|
SYNOPSIS
|
|
mi_change_key_cache()
|
|
old_key_cache Old key cache
|
|
new_key_cache New key cache
|
|
|
|
NOTES
|
|
This is used when we delete one key cache.
|
|
|
|
To handle the case where some other threads tries to open an MyISAM
|
|
table associated with the to-be-deleted key cache while this operation
|
|
is running, we have to call 'multi_key_cache_change()' from this
|
|
function while we have a lock on the MyISAM table list structure.
|
|
|
|
This is safe as long as it's only MyISAM that is using this specific
|
|
key cache.
|
|
*/
|
|
|
|
|
|
void mi_change_key_cache(KEY_CACHE *old_key_cache,
|
|
KEY_CACHE *new_key_cache)
|
|
{
|
|
LIST *pos;
|
|
DBUG_ENTER("mi_change_key_cache");
|
|
|
|
/*
|
|
Lock list to ensure that no one can close the table while we manipulate it
|
|
*/
|
|
pthread_mutex_lock(&THR_LOCK_myisam);
|
|
for (pos=myisam_open_list ; pos ; pos=pos->next)
|
|
{
|
|
MI_INFO *info= (MI_INFO*) pos->data;
|
|
MYISAM_SHARE *share= info->s;
|
|
if (share->key_cache == old_key_cache)
|
|
mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache);
|
|
}
|
|
|
|
/*
|
|
We have to do the following call while we have the lock on the
|
|
MyISAM list structure to ensure that another thread is not trying to
|
|
open a new table that will be associted with the old key cache
|
|
*/
|
|
multi_key_cache_change(old_key_cache, new_key_cache);
|
|
pthread_mutex_unlock(&THR_LOCK_myisam);
|
|
}
|