diff options
author | Michael Widenius <monty@askmonty.org> | 2010-09-27 21:48:10 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-09-27 21:48:10 +0300 |
commit | 0df1789285e2a824e6d77d58f8cd8d974bbe3773 (patch) | |
tree | fd23094ff9a897cfb0d26170fa9177f24a82b17b /storage | |
parent | 87d4af831aa037cc862ad285e3a051a97af1ec6f (diff) | |
download | mariadb-git-0df1789285e2a824e6d77d58f8cd8d974bbe3773.tar.gz |
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.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/maria/ma_init.c | 74 | ||||
-rw-r--r-- | storage/maria/unittest/ma_maria_log_cleanup.c | 6 |
2 files changed, 77 insertions, 3 deletions
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 <hash.h> +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 || |