~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to storage/maria/ma_check_standalone.h

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/*
 
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
 
19
  this one:
 
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.
 
31
 
 
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).
 
41
*/
 
42
 
 
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)))
 
49
{
 
50
}
 
51
 
 
52
 
 
53
#if defined(MA_CHECK_STANDALONE) && (MA_CHECK_STANDALONE == 1)
 
54
 
 
55
/*
 
56
  Check if check/repair operation was killed by a signal
 
57
*/
 
58
 
 
59
static int not_killed= 0;
 
60
 
 
61
volatile int *_ma_killed_ptr(HA_CHECK *param __attribute__((unused)))
 
62
{
 
63
  return &not_killed;                   /* always NULL */
 
64
}
 
65
 
 
66
        /* print warnings and errors */
 
67
        /* VARARGS */
 
68
 
 
69
void _ma_check_print_info(HA_CHECK *param __attribute__((unused)),
 
70
                         const char *fmt,...)
 
71
{
 
72
  va_list args;
 
73
  DBUG_ENTER("_ma_check_print_info");
 
74
  DBUG_PRINT("enter", ("format: %s", fmt));
 
75
 
 
76
  va_start(args,fmt);
 
77
  (void)(vfprintf(stdout, fmt, args));
 
78
  (void)(fputc('\n',stdout));
 
79
  va_end(args);
 
80
  DBUG_VOID_RETURN;
 
81
}
 
82
 
 
83
/* VARARGS */
 
84
 
 
85
void _ma_check_print_warning(HA_CHECK *param, const char *fmt,...)
 
86
{
 
87
  va_list args;
 
88
  DBUG_ENTER("_ma_check_print_warning");
 
89
  DBUG_PRINT("enter", ("format: %s", fmt));
 
90
 
 
91
  fflush(stdout);
 
92
  if (!param->warning_printed && !param->error_printed)
 
93
  {
 
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;
 
98
  }
 
99
  param->warning_printed=1;
 
100
  va_start(args,fmt);
 
101
  fprintf(stderr,"%s: warning: ",my_progname_short);
 
102
  (void)(vfprintf(stderr, fmt, args));
 
103
  (void)(fputc('\n',stderr));
 
104
  fflush(stderr);
 
105
  va_end(args);
 
106
  DBUG_VOID_RETURN;
 
107
}
 
108
 
 
109
/* VARARGS */
 
110
 
 
111
void _ma_check_print_error(HA_CHECK *param, const char *fmt,...)
 
112
{
 
113
  va_list args;
 
114
  DBUG_ENTER("_ma_check_print_error");
 
115
  DBUG_PRINT("enter", ("format: %s", fmt));
 
116
 
 
117
  fflush(stdout);
 
118
  if (!param->warning_printed && !param->error_printed)
 
119
  {
 
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;
 
123
  }
 
124
  param->error_printed|=1;
 
125
  va_start(args,fmt);
 
126
  fprintf(stderr,"%s: error: ",my_progname_short);
 
127
  (void)vfprintf(stderr, fmt, args);
 
128
  (void)fputc('\n',stderr);
 
129
  fflush(stderr);
 
130
  va_end(args);
 
131
  DBUG_VOID_RETURN;
 
132
}
 
133
 
 
134
#endif