MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
myrg_panic.c
1 /* Copyright (C) 2000-2001 MySQL AB
2 
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.
6 
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.
11 
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 */
15 
16 #include "myrg_def.h"
17 
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 */
24 
25 
26 int myrg_panic(enum ha_panic_function flag)
27 {
28  int error=0;
29  LIST *list_element,*next_open;
30  MYRG_INFO *info;
31  DBUG_ENTER("myrg_panic");
32 
33  for (list_element=myrg_open_list ; list_element ; list_element=next_open)
34  {
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;
39  }
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);
45 }