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