mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
5a2419eb89
Docs/manual.texi: Change log + bug fixes from the mailing list configure.in: added mlockall include/config-win.h: Fix to use SAFE_MUTEX include/ft_global.h: Free memory include/my_pthread.h: Fix for SAFE_MUTEX on windows myisam/Makefile.am: Fix modes myisam/ft_static.c: Fix language problem with fulltext myisam/ft_stopwords.c: Free memory at end myisam/mi_create.c: Fix language problem with fulltext myisam/mi_delete.c: Added optimization to not join blocks when using delete with QUICK myisam/mi_panic.c: Added freeing of memorty myisam/mi_test2.c: Added quick mode myisam/myisamchk.c: Fixed help text myisam/myisamdef.h: Added optimization to not join blocks when using delete with QUICK mysys/mf_format.c: Don't change case for extension mysys/my_wincond.c: Fix for safe mutex mysys/thr_mutex.c: Fix for safe mutex sql-bench/test-insert.sh: Split delete test to get more information about the times sql/ChangeLog: Changelog sql/ha_myisam.cc: Better OPTIMIZE handling sql/log.cc: Cleanup sql/mysql_priv.h: Fix for safe mutex sql/mysqld.cc: Added define for --one-thread option sql/sql_class.h: Fixed lock_time in slow_log sql/sql_delete.cc: Fix for safe mutex sql/sql_parse.cc: Fix processlist message for new process sql/sql_table.cc: Fix windows problem med CREATE INDEX sql/sql_yacc.yy: Fix for safe mutex sql/table.cc: Made code simpler strings/bmove512.c: Small speed fix support-files/mysql.server.sh: Fixed awk usage
114 lines
3.7 KiB
C
114 lines
3.7 KiB
C
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 */
|
|
|
|
#include "fulltext.h"
|
|
|
|
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
|
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
|
all changed data in single user misam is written to file */
|
|
/* if flag == HA_PANIC_READ then all misam files that was locked when
|
|
mi_panic(HA_PANIC_WRITE) was done is locked. A mi_readinfo() is
|
|
done for all single user files to get changes in database */
|
|
|
|
|
|
int mi_panic(enum ha_panic_function flag)
|
|
{
|
|
int error=0;
|
|
LIST *list_element,*next_open;
|
|
MI_INFO *info;
|
|
DBUG_ENTER("mi_panic");
|
|
|
|
pthread_mutex_lock(&THR_LOCK_myisam);
|
|
for (list_element=myisam_open_list ; list_element ; list_element=next_open)
|
|
{
|
|
next_open=list_element->next; /* Save if close */
|
|
info=(MI_INFO*) list_element->data;
|
|
switch (flag) {
|
|
case HA_PANIC_CLOSE:
|
|
pthread_mutex_unlock(&THR_LOCK_myisam); /* Not exactly right... */
|
|
if (mi_close(info))
|
|
error=my_errno;
|
|
pthread_mutex_lock(&THR_LOCK_myisam);
|
|
break;
|
|
case HA_PANIC_WRITE: /* Do this to free databases */
|
|
#ifdef CANT_OPEN_FILES_TWICE
|
|
if (info->s->options & HA_OPTION_READ_ONLY_DATA)
|
|
break;
|
|
#endif
|
|
if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE))
|
|
error=my_errno;
|
|
if (info->opt_flag & WRITE_CACHE_USED)
|
|
if (flush_io_cache(&info->rec_cache))
|
|
error=my_errno;
|
|
if (info->opt_flag & READ_CACHE_USED)
|
|
{
|
|
if (flush_io_cache(&info->rec_cache))
|
|
error=my_errno;
|
|
reinit_io_cache(&info->rec_cache,READ_CACHE,0,
|
|
(pbool) (info->lock_type != F_UNLCK),1);
|
|
}
|
|
if (info->lock_type != F_UNLCK && ! info->was_locked)
|
|
{
|
|
info->was_locked=info->lock_type;
|
|
if (mi_lock_database(info,F_UNLCK))
|
|
error=my_errno;
|
|
}
|
|
#ifdef CANT_OPEN_FILES_TWICE
|
|
if (info->s->kfile >= 0 && my_close(info->s->kfile,MYF(0)))
|
|
error = my_errno;
|
|
if (info->dfile >= 0 && my_close(info->dfile,MYF(0)))
|
|
error = my_errno;
|
|
info->s->kfile=info->dfile= -1; /* Files aren't open anymore */
|
|
break;
|
|
#endif
|
|
case HA_PANIC_READ: /* Restore to before WRITE */
|
|
#ifdef CANT_OPEN_FILES_TWICE
|
|
{ /* Open closed files */
|
|
char name_buff[FN_REFLEN];
|
|
if (info->s->kfile < 0)
|
|
if ((info->s->kfile= my_open(fn_format(name_buff,info->filename,"",
|
|
N_NAME_IEXT,4),info->mode,
|
|
MYF(MY_WME))) < 0)
|
|
error = my_errno;
|
|
if (info->dfile < 0)
|
|
{
|
|
if ((info->dfile= my_open(fn_format(name_buff,info->filename,"",
|
|
N_NAME_DEXT,4),info->mode,
|
|
MYF(MY_WME))) < 0)
|
|
error = my_errno;
|
|
info->rec_cache.file=info->dfile;
|
|
}
|
|
}
|
|
#endif
|
|
if (info->was_locked)
|
|
{
|
|
if (mi_lock_database(info, info->was_locked))
|
|
error=my_errno;
|
|
info->was_locked=0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (flag == HA_PANIC_CLOSE)
|
|
{
|
|
VOID(mi_log(0)); /* Close log if neaded */
|
|
ft_free_stopwords();
|
|
}
|
|
pthread_mutex_unlock(&THR_LOCK_myisam);
|
|
if (!error)
|
|
DBUG_RETURN(0);
|
|
DBUG_RETURN(my_errno=error);
|
|
} /* mi_panic */
|