mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / myisammrg / myrg_panic.c
bloba69daba05ef37857d72de3db1a03b366af5ce0c7
1 /* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #include "myrg_def.h"
18 /* if flag == HA_PANIC_CLOSE then all misam files are closed */
19 /* if flag == HA_PANIC_WRITE then all misam files are unlocked and
20 all changed data in single user misam is written to file */
21 /* if flag == HA_PANIC_READ then all misam files that was locked when
22 mi_panic(HA_PANIC_WRITE) was done is locked. A mi_readinfo() is
23 done for all single user files to get changes in database */
26 int myrg_panic(enum ha_panic_function flag)
28 int error=0;
29 LIST *list_element,*next_open;
30 MYRG_INFO *info;
31 DBUG_ENTER("myrg_panic");
33 for (list_element=myrg_open_list ; list_element ; list_element=next_open)
35 next_open=list_element->next; /* Save if close */
36 info=(MYRG_INFO*) list_element->data;
37 if (flag == HA_PANIC_CLOSE && myrg_close(info))
38 error=my_errno;
40 if (myrg_open_list && flag != HA_PANIC_CLOSE)
41 DBUG_RETURN(mi_panic(flag));
42 if (error)
43 my_errno=error;
44 DBUG_RETURN(error);