2006-09-14 19:06:51 +02:00
|
|
|
/* 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; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2006-09-01 17:53:10 +02:00
|
|
|
/*
|
|
|
|
WL#3234 Maria control file
|
|
|
|
First version written by Guilhem Bichot on 2006-04-27.
|
|
|
|
*/
|
|
|
|
|
2007-02-02 09:41:32 +02:00
|
|
|
#ifndef _ma_control_file_h
|
|
|
|
#define _ma_control_file_h
|
2006-09-01 17:53:10 +02:00
|
|
|
|
WL#3234 Maria control file manager.
Fitting ma_control_file_test into the mytap unittest framework:
new directories:
- unittest/storage/ for unit tests of any storage engine
- unittest/storage/maria for ... Maria, containing ma_control_file-t.
Later, older tests like ma_test*, ma_test_all (but which is Unix
dependent in its current form) could move here too.
The plugins macro enable building of unittest/storage/X for any
enabled engine X which has such a directory.
If Falcon wants to have unit tests there too, I may have to merge
this patch into 5.x one day.
config/ac-macros/plugins.m4:
If a storage engine has a directory in unittest/storage, build this
directory.
configure.in:
build storage engines' unit tests.
storage/maria/Makefile.am:
ma_control_file_test moves to unittest/storage/maria
storage/maria/ma_control_file.c:
more error codes when opening the control file fails.
ma_control_file_end() may now return an error if my_close() failed.
storage/maria/ma_control_file.h:
more error codes when opening the control file fails.
unittest/Makefile.am:
adding unit tests for storage engines.
Note that unit.pl simply recurses into "storage", so if a unit test for
storage engine X has been built previously, and now you re-configure
(without making clean) to disable this engine, then the unit test of
X will not be rebuilt but will still be present in storage/X, so will
be run.
unittest/storage/maria/ma_control_file-t.c:
Making the test fit the mytap framework (return all the way up
the stack instead of assert(); use the mytap functions plan(), ok() etc).
Adding test of file too short/long.
unittest/storage/maria/Makefile.am:
a_control_file-t is added to the Maria unit tests.
Later, older tests (ma_test1 etc) could also move here.
unittest/storage/Makefile.am:
New BitKeeper file ``unittest/storage/Makefile.am''
2006-09-11 16:12:31 +02:00
|
|
|
#define CONTROL_FILE_BASE_NAME "maria_control"
|
2006-09-01 17:53:10 +02:00
|
|
|
/*
|
|
|
|
indicate absence of the log file number; first log is always number 1, 0 is
|
|
|
|
impossible.
|
|
|
|
*/
|
|
|
|
#define CONTROL_FILE_IMPOSSIBLE_FILENO 0
|
|
|
|
/* logs always have a header */
|
|
|
|
#define CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET 0
|
|
|
|
/*
|
|
|
|
indicate absence of LSN.
|
|
|
|
*/
|
|
|
|
#define CONTROL_FILE_IMPOSSIBLE_LSN ((LSN){CONTROL_FILE_IMPOSSIBLE_FILENO,CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET})
|
|
|
|
|
|
|
|
/* Here is the interface of this module */
|
|
|
|
|
|
|
|
/*
|
|
|
|
LSN of the last checkoint
|
|
|
|
(if last_checkpoint_lsn.file_no == CONTROL_FILE_IMPOSSIBLE_FILENO
|
|
|
|
then there was never a checkpoint)
|
|
|
|
*/
|
|
|
|
extern LSN last_checkpoint_lsn;
|
|
|
|
/*
|
|
|
|
Last log number (if last_logno ==
|
|
|
|
CONTROL_FILE_IMPOSSIBLE_FILENO then there is no log file yet)
|
|
|
|
*/
|
|
|
|
extern uint32 last_logno;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Looks for the control file. If absent, it's a fresh start, create file.
|
|
|
|
If present, read it to find out last checkpoint's LSN and last log.
|
|
|
|
Called at engine's start.
|
|
|
|
*/
|
WL#3234 Maria control file manager.
Fitting ma_control_file_test into the mytap unittest framework:
new directories:
- unittest/storage/ for unit tests of any storage engine
- unittest/storage/maria for ... Maria, containing ma_control_file-t.
Later, older tests like ma_test*, ma_test_all (but which is Unix
dependent in its current form) could move here too.
The plugins macro enable building of unittest/storage/X for any
enabled engine X which has such a directory.
If Falcon wants to have unit tests there too, I may have to merge
this patch into 5.x one day.
config/ac-macros/plugins.m4:
If a storage engine has a directory in unittest/storage, build this
directory.
configure.in:
build storage engines' unit tests.
storage/maria/Makefile.am:
ma_control_file_test moves to unittest/storage/maria
storage/maria/ma_control_file.c:
more error codes when opening the control file fails.
ma_control_file_end() may now return an error if my_close() failed.
storage/maria/ma_control_file.h:
more error codes when opening the control file fails.
unittest/Makefile.am:
adding unit tests for storage engines.
Note that unit.pl simply recurses into "storage", so if a unit test for
storage engine X has been built previously, and now you re-configure
(without making clean) to disable this engine, then the unit test of
X will not be rebuilt but will still be present in storage/X, so will
be run.
unittest/storage/maria/ma_control_file-t.c:
Making the test fit the mytap framework (return all the way up
the stack instead of assert(); use the mytap functions plan(), ok() etc).
Adding test of file too short/long.
unittest/storage/maria/Makefile.am:
a_control_file-t is added to the Maria unit tests.
Later, older tests (ma_test1 etc) could also move here.
unittest/storage/Makefile.am:
New BitKeeper file ``unittest/storage/Makefile.am''
2006-09-11 16:12:31 +02:00
|
|
|
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_UNKNOWN_ERROR /* any other error */
|
|
|
|
} CONTROL_FILE_ERROR;
|
|
|
|
CONTROL_FILE_ERROR ma_control_file_create_or_open();
|
2006-09-01 17:53:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
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).
|
|
|
|
*/
|
2006-09-04 16:53:09 +02:00
|
|
|
#define CONTROL_FILE_UPDATE_ALL 0
|
|
|
|
#define CONTROL_FILE_UPDATE_ONLY_LSN 1
|
|
|
|
#define CONTROL_FILE_UPDATE_ONLY_LOGNO 2
|
2006-09-01 17:53:10 +02:00
|
|
|
int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno,
|
WL#3234 Maria control file manager.
Fitting ma_control_file_test into the mytap unittest framework:
new directories:
- unittest/storage/ for unit tests of any storage engine
- unittest/storage/maria for ... Maria, containing ma_control_file-t.
Later, older tests like ma_test*, ma_test_all (but which is Unix
dependent in its current form) could move here too.
The plugins macro enable building of unittest/storage/X for any
enabled engine X which has such a directory.
If Falcon wants to have unit tests there too, I may have to merge
this patch into 5.x one day.
config/ac-macros/plugins.m4:
If a storage engine has a directory in unittest/storage, build this
directory.
configure.in:
build storage engines' unit tests.
storage/maria/Makefile.am:
ma_control_file_test moves to unittest/storage/maria
storage/maria/ma_control_file.c:
more error codes when opening the control file fails.
ma_control_file_end() may now return an error if my_close() failed.
storage/maria/ma_control_file.h:
more error codes when opening the control file fails.
unittest/Makefile.am:
adding unit tests for storage engines.
Note that unit.pl simply recurses into "storage", so if a unit test for
storage engine X has been built previously, and now you re-configure
(without making clean) to disable this engine, then the unit test of
X will not be rebuilt but will still be present in storage/X, so will
be run.
unittest/storage/maria/ma_control_file-t.c:
Making the test fit the mytap framework (return all the way up
the stack instead of assert(); use the mytap functions plan(), ok() etc).
Adding test of file too short/long.
unittest/storage/maria/Makefile.am:
a_control_file-t is added to the Maria unit tests.
Later, older tests (ma_test1 etc) could also move here.
unittest/storage/Makefile.am:
New BitKeeper file ``unittest/storage/Makefile.am''
2006-09-11 16:12:31 +02:00
|
|
|
uint objs_to_write);
|
2006-09-01 17:53:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Free resources taken by control file subsystem */
|
WL#3234 Maria control file manager.
Fitting ma_control_file_test into the mytap unittest framework:
new directories:
- unittest/storage/ for unit tests of any storage engine
- unittest/storage/maria for ... Maria, containing ma_control_file-t.
Later, older tests like ma_test*, ma_test_all (but which is Unix
dependent in its current form) could move here too.
The plugins macro enable building of unittest/storage/X for any
enabled engine X which has such a directory.
If Falcon wants to have unit tests there too, I may have to merge
this patch into 5.x one day.
config/ac-macros/plugins.m4:
If a storage engine has a directory in unittest/storage, build this
directory.
configure.in:
build storage engines' unit tests.
storage/maria/Makefile.am:
ma_control_file_test moves to unittest/storage/maria
storage/maria/ma_control_file.c:
more error codes when opening the control file fails.
ma_control_file_end() may now return an error if my_close() failed.
storage/maria/ma_control_file.h:
more error codes when opening the control file fails.
unittest/Makefile.am:
adding unit tests for storage engines.
Note that unit.pl simply recurses into "storage", so if a unit test for
storage engine X has been built previously, and now you re-configure
(without making clean) to disable this engine, then the unit test of
X will not be rebuilt but will still be present in storage/X, so will
be run.
unittest/storage/maria/ma_control_file-t.c:
Making the test fit the mytap framework (return all the way up
the stack instead of assert(); use the mytap functions plan(), ok() etc).
Adding test of file too short/long.
unittest/storage/maria/Makefile.am:
a_control_file-t is added to the Maria unit tests.
Later, older tests (ma_test1 etc) could also move here.
unittest/storage/Makefile.am:
New BitKeeper file ``unittest/storage/Makefile.am''
2006-09-11 16:12:31 +02:00
|
|
|
int ma_control_file_end();
|
2006-09-01 17:53:10 +02:00
|
|
|
|
|
|
|
#endif
|