1
/* Copyright (C) 2006-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 */
16
#include "../maria_def.h"
20
#include "../trnman.h"
22
extern my_bool maria_log_remove();
23
extern void translog_example_table_init();
26
static const char *default_dbug_option;
29
#define PCACHE_SIZE (1024*1024*10)
30
#define PCACHE_PAGE TRANSLOG_PAGE_SIZE
31
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
34
static char *first_translog_file= (char*)"maria_log.00000001";
36
int main(int argc __attribute__((unused)), char *argv[])
41
LSN lsn, first_lsn, theor_lsn;
42
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
48
bzero(&pagecache, sizeof(pagecache));
49
maria_data_root= (char *)".";
50
if (maria_log_remove())
52
/* be sure that we have no logs in the directory*/
53
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
54
my_delete(first_translog_file, MYF(0));
59
default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
61
default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace";
65
DBUG_SET(default_dbug_option);
66
DBUG_SET_INITIAL(default_dbug_option);
70
if (ma_control_file_open(TRUE, TRUE))
72
fprintf(stderr, "Can't init control file (%d)\n", errno);
75
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
76
PCACHE_PAGE, 0)) == 0)
78
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
81
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
82
LOG_FLAGS, 0, &translog_example_table_init,
85
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
88
/* Suppressing of automatic record writing */
89
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
91
theor_lsn= translog_first_theoretical_lsn();
94
fprintf(stderr, "Error reading the first log file.");
98
if (theor_lsn == LSN_IMPOSSIBLE)
100
fprintf(stderr, "There is no first log file.");
104
first_lsn= translog_first_lsn_in_log();
105
if (first_lsn != LSN_IMPOSSIBLE)
107
fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).",
108
LSN_IN_PARTS(first_lsn));
112
ok(1, "Empty log response");
115
int4store(long_tr_id, 0);
116
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
117
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
118
if (translog_write_record(&lsn,
119
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
120
&dummy_transaction_object, NULL, 6,
121
TRANSLOG_INTERNAL_PARTS + 1,
124
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
129
theor_lsn= translog_first_theoretical_lsn();
132
fprintf(stderr, "Error reading the first log file\n");
136
if (theor_lsn == LSN_IMPOSSIBLE)
138
fprintf(stderr, "There is no first log file\n");
142
first_lsn= translog_first_lsn_in_log();
143
if (first_lsn != theor_lsn)
145
fprintf(stderr, "Incorrect first lsn: (%lu,0x%lx) "
146
" theoretical first: (%lu,0x%lx)\n",
147
LSN_IN_PARTS(first_lsn), LSN_IN_PARTS(theor_lsn));
152
ok(1, "Full log response");
155
end_pagecache(&pagecache, 1);
156
ma_control_file_end();
157
if (maria_log_remove())
162
#include "../ma_check_standalone.h"