diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 8490d59643b..77d141d5282 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -257,7 +257,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd, #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \ MYSQL_PLUGIN_VAR_HEADER; \ type *value; \ - type def_val; \ + const type def_val; \ } MYSQL_SYSVAR_NAME(name) #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 { \ MYSQL_PLUGIN_VAR_HEADER; \ int offset; \ - type def_val; \ + const type def_val; \ DECLARE_THDVAR_FUNC(type); \ } 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 { \ MYSQL_PLUGIN_VAR_HEADER; \ int offset; \ - type def_val; \ + const type def_val; \ DECLARE_THDVAR_FUNC(type); \ TYPELIB *typelib; \ } MYSQL_SYSVAR_NAME(name) diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index 838e9814c89..d0eea52e341 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -22,6 +22,9 @@ #include "ma_checkpoint.h" #include +static my_bool maria_upgrade(); + + void history_state_free(MARIA_STATE_HISTORY_CLOSED *closed_history) { MARIA_STATE_HISTORY *history, *next; @@ -65,6 +68,8 @@ int maria_init(void) maria_block_size % MARIA_MIN_KEY_BLOCK_LENGTH == 0); if (!maria_inited) { + if (maria_upgrade()) + return 1; maria_inited= TRUE; pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW); _ma_init_block_record_data(); @@ -113,3 +118,72 @@ void maria_end(void) 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); +} diff --git a/storage/maria/unittest/ma_maria_log_cleanup.c b/storage/maria/unittest/ma_maria_log_cleanup.c index 6eeb0c6856a..f85c75b1a88 100644 --- a/storage/maria/unittest/ma_maria_log_cleanup.c +++ b/storage/maria/unittest/ma_maria_log_cleanup.c @@ -38,7 +38,8 @@ my_bool maria_log_remove() for (i= 0; i < dirp->number_off_files; i++) { 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[11] >= '0' && file[11] <= '9' && file[12] >= '0' && file[12] <= '9' && @@ -46,8 +47,7 @@ my_bool maria_log_remove() 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') + file[17] == '\0') { if (fn_format(file_name, file, maria_data_root, "", MYF(MY_WME)) == NullS ||