1
/* Copyright (C) 2006,2007,2008 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
Q: Why isn't ma_recovery_util.c simply moved to ma_recovery.c ?
19
A: ma_recovery.c, because it invokes objects from ma_check.c (like
20
maria_chk_init()) causes the following problem:
21
if a source file a.c of a program invokes a function defined in
22
ma_recovery.c, then a.o depends on ma_recovery.o which depends on
23
ma_check.o: linker thus brings in ma_check.o. That brings in the
24
dependencies of ma_check.o which are definitions of _ma_check_print_info()
25
etc; if a.o does not define them then the ones of ha_maria.o are used
26
i.e. ha_maria.o is linked into the program, and this brings in dependencies
27
of ha_maria.o on mysqld.o into the program's linking which thus fails, as
28
the program is not linked with mysqld.o.
29
Thus, while several functions defined in ma_recovery.c could be useful to
30
other files, they cannot be used by them.
31
So we are going to gradually move a great share of ma_recovery.c's exported
32
functions into the present file, to isolate the problematic components and
36
#include "maria_def.h"
39
struct st_dirty_page /* used only in the REDO phase */
41
uint64 file_and_page_id;
45
LSN after which dirty pages list does not apply. Can be slightly before
46
when ma_checkpoint_execute() started.
48
LSN checkpoint_start= LSN_IMPOSSIBLE;
50
/** @todo looks like duplicate of recovery_message_printed */
51
my_bool procent_printed;
52
FILE *tracef; /**< trace file for debugging */
55
/** @brief Prints to a trace file if it is not NULL */
56
void tprint(FILE *trace_file __attribute__ ((unused)),
57
const char *format __attribute__ ((unused)), ...)
60
va_start(args, format);
61
DBUG_PRINT("info", ("%s", format));
62
if (trace_file != NULL)
67
fputc('\n', trace_file);
69
vfprintf(trace_file, format, args);
75
void eprint(FILE *trace_file __attribute__ ((unused)),
76
const char *format __attribute__ ((unused)), ...)
79
va_start(args, format);
80
DBUG_PRINT("error", ("%s", format));
86
/* In silent mode, print on another line than the 0% 10% 20% line */
88
fputc('\n', trace_file);
90
vfprintf(trace_file , format, args);
91
fputc('\n', trace_file);
92
if (trace_file != stderr)
94
va_start(args, format);
95
my_printv_error(HA_ERR_INITIALIZATION, format, MYF(0), args);
103
Tells if the dirty pages list found in checkpoint record allows to ignore a
104
REDO for a certain page.
106
@param shortid short id of the table
107
@param lsn REDO record's LSN
108
@param page page number
109
@param index TRUE if index page, FALSE if data page
112
my_bool _ma_redo_not_needed_for_page(uint16 shortid, LSN lsn,
113
pgcache_page_no_t page,
116
if (cmp_translog_addr(lsn, checkpoint_start) < 0)
119
64-bit key is formed like this:
120
Most significant byte: 0 if data page, 1 if index page
121
Next 2 bytes: table's short id
122
Next 5 bytes: page number
124
uint64 file_and_page_id=
125
(((uint64)((index << 16) | shortid)) << 40) | page;
126
struct st_dirty_page *dirty_page= (struct st_dirty_page *)
127
hash_search(&all_dirty_pages,
128
(uchar *)&file_and_page_id, sizeof(file_and_page_id));
129
DBUG_PRINT("info", ("in dirty pages list: %d", dirty_page != NULL));
130
if ((dirty_page == NULL) ||
131
cmp_translog_addr(lsn, dirty_page->rec_lsn) < 0)
133
tprint(tracef, ", ignoring because of dirty_pages list\n");