mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 22:34:18 +01:00
adac9798bf
- new program maria_read_log to display and apply log records found in a Maria log (see file's revision comment) - minor, misc fixes storage/maria/Makefile.am: new program maria_read_log storage/maria/ha_maria.cc: create control file if missing storage/maria/ma_blockrec.c: 0 -> LSN_IMPOSSIBLE; comments storage/maria/ma_checkpoint.h: preparations for Checkpoint module storage/maria/ma_close.c: comment storage/maria/ma_control_file.c: renaming constants. Possibility to say "open control file but don't create it if it's missing" (used by maria_read_log which does not want to create anything) storage/maria/ma_control_file.h: renaming constants storage/maria/ma_create.c: I had duplicated "linkname" and "linkname_ptr", now I see it's not needed, reverting. Indeed those variables don't contain interesting information; fixing log record accordingly (the links are in ci->data/index_file_name). Storing keystart in log record is needed, to know at which size we must extend the file if we replay LOGREC_CREATE_TABLE. storage/maria/ma_loghandler.c: some structures need to be known to maria_read_log.c, taking them to ma_loghandler.h storage/maria/ma_loghandler.h: we have page_store, adding page_korr. translog_lock() made public, because Checkpoint will need it (to write to control file). Some structures moved from ma_loghandler.c because maria_read_log.c needs them (needs to know the execute-in-REDO-phase hooks of each record). storage/maria/ma_loghandler_lsn.h: constants defined in ma_control_file.h serve everywhere, and they relate to LSNs, so putting them in ma_loghandler_lsn.h. Stronger constraints in LSN_VALID(). storage/maria/ma_pagecache.c: renaming constants storage/maria/ma_recovery.h: copyright storage/maria/ma_test1.c: new prototype storage/maria/ma_test2.c: new prototype storage/maria/trnman_public.h: double-inclusion safe storage/maria/unittest/ma_control_file-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_multigroup-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_multithread-t.c: constants renamed, new prototype storage/maria/unittest/ma_test_loghandler_pagecache-t.c: constants renamed, new prototype storage/myisam/mi_close.c: comment storage/maria/maria_read_log.c: program to read and print log records from a Maria transaction log, and optionally apply them to tables. Very basic, early version. Should serve as a base for Recovery's code. Designed to be idempotent. Create a log by running maria.test, then cd to var/master-data and run "maria_read_log --only-display" to see info about records; run "maria_read_log --display-and-apply" to also apply the records to tables (it's more interesting if you first wipe out the tables in var/master-data/test, to see how they get re-created). Only a few records are handled by now: LONG_TRANSACTION_ID, COMMIT, FILE_ID, REDO_CREATE_TABLE; place is ready for REDO_INSERT_ROW_HEAD where I could use Monty's help (search for "Monty" in the file). Note: changes to the index pages, index's header and bitmap pages are not properly logged yet, so don't expect the program to work with that.
76 lines
2.3 KiB
C
76 lines
2.3 KiB
C
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/*
|
|
WL#3234 Maria control file
|
|
First version written by Guilhem Bichot on 2006-04-27.
|
|
*/
|
|
|
|
#define CONTROL_FILE_BASE_NAME "maria_control"
|
|
|
|
/* Here is the interface of this module */
|
|
|
|
/*
|
|
LSN of the last checkoint
|
|
(if last_checkpoint_lsn == LSN_IMPOSSIBLE then there was never a checkpoint)
|
|
*/
|
|
extern LSN last_checkpoint_lsn;
|
|
/*
|
|
Last log number (if last_logno == FILENO_IMPOSSIBLE then there is no log
|
|
file yet)
|
|
*/
|
|
extern uint32 last_logno;
|
|
|
|
extern my_bool maria_multi_threaded;
|
|
|
|
typedef enum enum_control_file_error {
|
|
CONTROL_FILE_OK= 0,
|
|
CONTROL_FILE_TOO_SMALL,
|
|
CONTROL_FILE_TOO_BIG,
|
|
CONTROL_FILE_BAD_MAGIC_STRING,
|
|
CONTROL_FILE_BAD_CHECKSUM,
|
|
CONTROL_FILE_MISSING,
|
|
CONTROL_FILE_UNKNOWN_ERROR /* any other error */
|
|
} CONTROL_FILE_ERROR;
|
|
|
|
#define CONTROL_FILE_UPDATE_ALL 0
|
|
#define CONTROL_FILE_UPDATE_ONLY_LSN 1
|
|
#define CONTROL_FILE_UPDATE_ONLY_LOGNO 2
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
Looks for the control file. If none and creation was requested, creates file.
|
|
If present, reads it to find out last checkpoint's LSN and last log.
|
|
Called at engine's start.
|
|
*/
|
|
CONTROL_FILE_ERROR ma_control_file_create_or_open(my_bool);
|
|
/*
|
|
Write information durably to the control file.
|
|
Called when we have created a new log (after syncing this log's creation)
|
|
and when we have written a checkpoint (after syncing this log record).
|
|
*/
|
|
int ma_control_file_write_and_force(const LSN checkpoint_lsn, uint32 logno,
|
|
uint objs_to_write);
|
|
|
|
|
|
/* Free resources taken by control file subsystem */
|
|
int ma_control_file_end();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|