1
/* Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
Most standalone Maria programs (maria_chk, maria_read_log, etc, unit
18
tests) use objects from MyISAM, and end up in link dependencies similar to
20
maria_chk.o needs ft_init_stopwords() => needs storage/myisam/ft_stopwords.o
21
ft_stopwords.o needs ft_stopword_file => needs ft_static.o
22
ft_static.o needs ft_nlq_read_next => needs ft_nlq_search.o
23
ft_nlq_search.o needs mi_readinfo() => needs mi_locking.o
24
mi_locking.o needs mi_state_info_write() => needs mi_open.o
25
mi_open.o needs mi_ck_write => needs mi_write.o
26
mi_write.o needs _mi_report_crashed() and that is a problem because
27
defined only in ha_myisam.o, thus ha_myisam.o is brought in, with its
28
dependencies on mysqld.o, which make linking fail.
29
The solution is to declare a dummy _mi_report_crashed() in the present
30
header file, and include it in Maria standalone programs.
32
Some standalone Maria programs, but less numerous than above, use objects
33
from ma_check.o like maria_repair(). This brings in linking dependencies of
34
ma_check.o, especially _ma_killed_ptr() and
35
_ma_check_print_info|warning|error() which are defined in ha_maria.o, which
36
brings mysqld.o again. To avoid the problem, we define here other versions
37
of those functions, for standalone programs. Those programs can use them by
38
including this header file and defining MA_CHECK_STANDALONE to 1 (this
39
additional step is to allow programs to include only _mi_report_crashed(),
40
when they don't need ma_check.o objects).
43
struct st_myisam_info;
44
typedef struct st_myisam_info MI_INFO;
45
void _mi_report_crashed(MI_INFO *file __attribute__((unused)),
46
const char *message __attribute__((unused)),
47
const char *sfile __attribute__((unused)),
48
uint sline __attribute__((unused)))
53
#if defined(MA_CHECK_STANDALONE) && (MA_CHECK_STANDALONE == 1)
56
Check if check/repair operation was killed by a signal
59
static int not_killed= 0;
61
volatile int *_ma_killed_ptr(HA_CHECK *param __attribute__((unused)))
63
return ¬_killed; /* always NULL */
66
/* print warnings and errors */
69
void _ma_check_print_info(HA_CHECK *param __attribute__((unused)),
73
DBUG_ENTER("_ma_check_print_info");
74
DBUG_PRINT("enter", ("format: %s", fmt));
77
(void)(vfprintf(stdout, fmt, args));
78
(void)(fputc('\n',stdout));
85
void _ma_check_print_warning(HA_CHECK *param, const char *fmt,...)
88
DBUG_ENTER("_ma_check_print_warning");
89
DBUG_PRINT("enter", ("format: %s", fmt));
92
if (!param->warning_printed && !param->error_printed)
94
if (param->testflag & T_SILENT)
95
fprintf(stderr,"%s: MARIA file %s\n",my_progname_short,
96
param->isam_file_name);
97
param->out_flag|= O_DATA_LOST;
99
param->warning_printed=1;
101
fprintf(stderr,"%s: warning: ",my_progname_short);
102
(void)(vfprintf(stderr, fmt, args));
103
(void)(fputc('\n',stderr));
111
void _ma_check_print_error(HA_CHECK *param, const char *fmt,...)
114
DBUG_ENTER("_ma_check_print_error");
115
DBUG_PRINT("enter", ("format: %s", fmt));
118
if (!param->warning_printed && !param->error_printed)
120
if (param->testflag & T_SILENT)
121
fprintf(stderr,"%s: MARIA file %s\n",my_progname_short,param->isam_file_name);
122
param->out_flag|= O_DATA_LOST;
124
param->error_printed|=1;
126
fprintf(stderr,"%s: error: ",my_progname_short);
127
(void)vfprintf(stderr, fmt, args);
128
(void)fputc('\n',stderr);