mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Rename control file and log files from maria_xxx to aria_xxx when upgrading from MariaDB 5.1
Fix cleanup to really remove 'aria_log' files. Fixes failures in maria unit tests on some platforms. Fixed compiler warnings include/mysql/plugin.h: Changed def_val back to const, to remove compiler warnings. storage/maria/ma_init.c: Rename control file and log files from maria_xxx to aria_xxx when upgrading from MariaDB 5.1 storage/maria/unittest/ma_maria_log_cleanup.c: Fix cleanup to really remove 'aria_log' files. Fixes failures in maria unit tests on some platforms.
This commit is contained in:
@@ -257,7 +257,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
|
|||||||
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
|
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
|
||||||
MYSQL_PLUGIN_VAR_HEADER; \
|
MYSQL_PLUGIN_VAR_HEADER; \
|
||||||
type *value; \
|
type *value; \
|
||||||
type def_val; \
|
const type def_val; \
|
||||||
} MYSQL_SYSVAR_NAME(name)
|
} MYSQL_SYSVAR_NAME(name)
|
||||||
|
|
||||||
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
|
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
|
||||||
@@ -279,7 +279,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
|
|||||||
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
|
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
|
||||||
MYSQL_PLUGIN_VAR_HEADER; \
|
MYSQL_PLUGIN_VAR_HEADER; \
|
||||||
int offset; \
|
int offset; \
|
||||||
type def_val; \
|
const type def_val; \
|
||||||
DECLARE_THDVAR_FUNC(type); \
|
DECLARE_THDVAR_FUNC(type); \
|
||||||
} MYSQL_SYSVAR_NAME(name)
|
} MYSQL_SYSVAR_NAME(name)
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
|
|||||||
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
|
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
|
||||||
MYSQL_PLUGIN_VAR_HEADER; \
|
MYSQL_PLUGIN_VAR_HEADER; \
|
||||||
int offset; \
|
int offset; \
|
||||||
type def_val; \
|
const type def_val; \
|
||||||
DECLARE_THDVAR_FUNC(type); \
|
DECLARE_THDVAR_FUNC(type); \
|
||||||
TYPELIB *typelib; \
|
TYPELIB *typelib; \
|
||||||
} MYSQL_SYSVAR_NAME(name)
|
} MYSQL_SYSVAR_NAME(name)
|
||||||
|
@@ -22,6 +22,9 @@
|
|||||||
#include "ma_checkpoint.h"
|
#include "ma_checkpoint.h"
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
|
||||||
|
static my_bool maria_upgrade();
|
||||||
|
|
||||||
|
|
||||||
void history_state_free(MARIA_STATE_HISTORY_CLOSED *closed_history)
|
void history_state_free(MARIA_STATE_HISTORY_CLOSED *closed_history)
|
||||||
{
|
{
|
||||||
MARIA_STATE_HISTORY *history, *next;
|
MARIA_STATE_HISTORY *history, *next;
|
||||||
@@ -65,6 +68,8 @@ int maria_init(void)
|
|||||||
maria_block_size % MARIA_MIN_KEY_BLOCK_LENGTH == 0);
|
maria_block_size % MARIA_MIN_KEY_BLOCK_LENGTH == 0);
|
||||||
if (!maria_inited)
|
if (!maria_inited)
|
||||||
{
|
{
|
||||||
|
if (maria_upgrade())
|
||||||
|
return 1;
|
||||||
maria_inited= TRUE;
|
maria_inited= TRUE;
|
||||||
pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW);
|
pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW);
|
||||||
_ma_init_block_record_data();
|
_ma_init_block_record_data();
|
||||||
@@ -113,3 +118,72 @@ void maria_end(void)
|
|||||||
hash_free(&maria_stored_state);
|
hash_free(&maria_stored_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Upgrade from older Aria versions:
|
||||||
|
|
||||||
|
- In MariaDB 5.1, the name of the control file and log files had the
|
||||||
|
'maria' prefix, now they have the 'aria' prefix.
|
||||||
|
|
||||||
|
@return: 0 ok
|
||||||
|
1 error
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
static my_bool maria_upgrade()
|
||||||
|
{
|
||||||
|
char name[FN_REFLEN], new_name[FN_REFLEN];
|
||||||
|
DBUG_ENTER("maria_upgrade");
|
||||||
|
|
||||||
|
fn_format(name, "maria_log_control", maria_data_root, "", MYF(MY_WME));
|
||||||
|
|
||||||
|
if (!my_access(name,F_OK))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Old style control file found; Rename the control file and the log files.
|
||||||
|
We start by renaming all log files, so that if we get a crash
|
||||||
|
we will continue from where we left.
|
||||||
|
*/
|
||||||
|
uint i;
|
||||||
|
MY_DIR *dir= my_dir(maria_data_root, MYF(MY_WME));
|
||||||
|
if (!dir)
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
|
my_message(HA_ERR_INITIALIZATION,
|
||||||
|
"Found old style Maria log files; "
|
||||||
|
"Converting them to Aria names",
|
||||||
|
MYF(ME_JUST_INFO));
|
||||||
|
|
||||||
|
for (i= 0; i < dir->number_off_files; i++)
|
||||||
|
{
|
||||||
|
const char *file= dir->dir_entry[i].name;
|
||||||
|
if (strncmp(file, "maria_log.", 10) == 0 &&
|
||||||
|
file[10] >= '0' && file[10] <= '9' &&
|
||||||
|
file[11] >= '0' && file[11] <= '9' &&
|
||||||
|
file[12] >= '0' && file[12] <= '9' &&
|
||||||
|
file[13] >= '0' && file[13] <= '9' &&
|
||||||
|
file[14] >= '0' && file[14] <= '9' &&
|
||||||
|
file[15] >= '0' && file[15] <= '9' &&
|
||||||
|
file[16] >= '0' && file[16] <= '9' &&
|
||||||
|
file[17] >= '0' && file[17] <= '9' &&
|
||||||
|
file[18] == '\0')
|
||||||
|
{
|
||||||
|
/* Remove the 'm' in 'maria' */
|
||||||
|
char old_logname[FN_REFLEN], new_logname[FN_REFLEN];
|
||||||
|
fn_format(old_logname, file, maria_data_root, "", MYF(0));
|
||||||
|
fn_format(new_logname, file+1, maria_data_root, "", MYF(0));
|
||||||
|
if (my_rename(old_logname, new_logname, MYF(MY_WME)))
|
||||||
|
{
|
||||||
|
my_dirend(dir);
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my_dirend(dir);
|
||||||
|
|
||||||
|
fn_format(new_name, CONTROL_FILE_BASE_NAME, maria_data_root, "", MYF(0));
|
||||||
|
if (my_rename(name, new_name, MYF(MY_WME)))
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
}
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
}
|
||||||
|
@@ -38,7 +38,8 @@ my_bool maria_log_remove()
|
|||||||
for (i= 0; i < dirp->number_off_files; i++)
|
for (i= 0; i < dirp->number_off_files; i++)
|
||||||
{
|
{
|
||||||
char *file= dirp->dir_entry[i].name;
|
char *file= dirp->dir_entry[i].name;
|
||||||
if (strncmp(file, "aria_log.", 10) == 0 &&
|
if (strncmp(file, "aria_log.", 9) == 0 &&
|
||||||
|
file[9] >= '0' && file[9] <= '9' &&
|
||||||
file[10] >= '0' && file[10] <= '9' &&
|
file[10] >= '0' && file[10] <= '9' &&
|
||||||
file[11] >= '0' && file[11] <= '9' &&
|
file[11] >= '0' && file[11] <= '9' &&
|
||||||
file[12] >= '0' && file[12] <= '9' &&
|
file[12] >= '0' && file[12] <= '9' &&
|
||||||
@@ -46,8 +47,7 @@ my_bool maria_log_remove()
|
|||||||
file[14] >= '0' && file[14] <= '9' &&
|
file[14] >= '0' && file[14] <= '9' &&
|
||||||
file[15] >= '0' && file[15] <= '9' &&
|
file[15] >= '0' && file[15] <= '9' &&
|
||||||
file[16] >= '0' && file[16] <= '9' &&
|
file[16] >= '0' && file[16] <= '9' &&
|
||||||
file[17] >= '0' && file[17] <= '9' &&
|
file[17] == '\0')
|
||||||
file[18] == '\0')
|
|
||||||
{
|
{
|
||||||
if (fn_format(file_name, file,
|
if (fn_format(file_name, file,
|
||||||
maria_data_root, "", MYF(MY_WME)) == NullS ||
|
maria_data_root, "", MYF(MY_WME)) == NullS ||
|
||||||
|
Reference in New Issue
Block a user