diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-24 07:16:08 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2015-06-24 07:16:08 +0300 |
commit | 2e4984c185ddcd2da789017cd147338846ff409a (patch) | |
tree | 0293831900c860600efbaa747ea886d9d1cbf5bd /storage/mroonga/lib/mrn_path_mapper.cpp | |
parent | 792b53e80806df893ee62c9a1c1bd117114c8c6d (diff) | |
parent | a6087e7dc1ef3561d8189c8db15e9591d0f9b520 (diff) | |
download | mariadb-git-2e4984c185ddcd2da789017cd147338846ff409a.tar.gz |
Merge tag 'mariadb-10.0.20' into 10.0-FusionIO10.0-FusionIO
Conflicts:
storage/innobase/os/os0file.cc
storage/xtradb/os/os0file.cc
storage/xtradb/srv/srv0start.cc
Diffstat (limited to 'storage/mroonga/lib/mrn_path_mapper.cpp')
-rw-r--r-- | storage/mroonga/lib/mrn_path_mapper.cpp | 97 |
1 files changed, 65 insertions, 32 deletions
diff --git a/storage/mroonga/lib/mrn_path_mapper.cpp b/storage/mroonga/lib/mrn_path_mapper.cpp index ee5432f16bb..7a595986f01 100644 --- a/storage/mroonga/lib/mrn_path_mapper.cpp +++ b/storage/mroonga/lib/mrn_path_mapper.cpp @@ -2,7 +2,7 @@ /* Copyright(C) 2010 Tetsuro IKEDA Copyright(C) 2011-2013 Kentoku SHIBA - Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com> + Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -29,16 +29,17 @@ namespace mrn { char *PathMapper::default_path_prefix = NULL; char *PathMapper::default_mysql_data_home_path = NULL; - PathMapper::PathMapper(const char *mysql_path, + PathMapper::PathMapper(const char *original_mysql_path, const char *path_prefix, const char *mysql_data_home_path) - : mysql_path_(mysql_path), + : original_mysql_path_(original_mysql_path), path_prefix_(path_prefix), mysql_data_home_path_(mysql_data_home_path) { db_path_[0] = '\0'; db_name_[0] = '\0'; table_name_[0] = '\0'; mysql_table_name_[0] = '\0'; + mysql_path_[0] = '\0'; } /** @@ -52,22 +53,25 @@ namespace mrn { return db_path_; } - if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) { + if (original_mysql_path_[0] == FN_CURLIB && + original_mysql_path_[1] == FN_LIBCHAR) { if (path_prefix_) { strcpy(db_path_, path_prefix_); } int i = 2, j = strlen(db_path_), len; - len = strlen(mysql_path_); - while (mysql_path_[i] != FN_LIBCHAR && i < len) { - db_path_[j++] = mysql_path_[i++]; + len = strlen(original_mysql_path_); + while (original_mysql_path_[i] != FN_LIBCHAR && i < len) { + db_path_[j++] = original_mysql_path_[i++]; } db_path_[j] = '\0'; } else if (mysql_data_home_path_) { - int len = strlen(mysql_path_); + int len = strlen(original_mysql_path_); int mysql_data_home_len = strlen(mysql_data_home_path_); if (len > mysql_data_home_len && - !strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) { + !strncmp(original_mysql_path_, + mysql_data_home_path_, + mysql_data_home_len)) { int i = mysql_data_home_len, j; if (path_prefix_ && path_prefix_[0] == FN_LIBCHAR) { strcpy(db_path_, path_prefix_); @@ -87,19 +91,19 @@ namespace mrn { } } - while (mysql_path_[i] != FN_LIBCHAR && i < len) { - db_path_[j++] = mysql_path_[i++]; + while (original_mysql_path_[i] != FN_LIBCHAR && i < len) { + db_path_[j++] = original_mysql_path_[i++]; } if (i == len) { - memcpy(db_path_, mysql_path_, len); + memcpy(db_path_, original_mysql_path_, len); } else { db_path_[j] = '\0'; } } else { - strcpy(db_path_, mysql_path_); + strcpy(db_path_, original_mysql_path_); } } else { - strcpy(db_path_, mysql_path_); + strcpy(db_path_, original_mysql_path_); } strcat(db_path_, MRN_DB_FILE_SUFFIX); return db_path_; @@ -116,32 +120,35 @@ namespace mrn { return db_name_; } - if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) { + if (original_mysql_path_[0] == FN_CURLIB && + original_mysql_path_[1] == FN_LIBCHAR) { int i = 2, j = 0, len; - len = strlen(mysql_path_); - while (mysql_path_[i] != FN_LIBCHAR && i < len) { - db_name_[j++] = mysql_path_[i++]; + len = strlen(original_mysql_path_); + while (original_mysql_path_[i] != FN_LIBCHAR && i < len) { + db_name_[j++] = original_mysql_path_[i++]; } db_name_[j] = '\0'; } else if (mysql_data_home_path_) { - int len = strlen(mysql_path_); + int len = strlen(original_mysql_path_); int mysql_data_home_len = strlen(mysql_data_home_path_); if (len > mysql_data_home_len && - !strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) { + !strncmp(original_mysql_path_, + mysql_data_home_path_, + mysql_data_home_len)) { int i = mysql_data_home_len, j = 0; - while (mysql_path_[i] != FN_LIBCHAR && i < len) { - db_name_[j++] = mysql_path_[i++]; + while (original_mysql_path_[i] != FN_LIBCHAR && i < len) { + db_name_[j++] = original_mysql_path_[i++]; } if (i == len) { - memcpy(db_name_, mysql_path_, len); + memcpy(db_name_, original_mysql_path_, len); } else { db_name_[j] = '\0'; } } else { - strcpy(db_name_, mysql_path_); + strcpy(db_name_, original_mysql_path_); } } else { - strcpy(db_name_, mysql_path_); + strcpy(db_name_, original_mysql_path_); } return db_name_; } @@ -154,10 +161,10 @@ namespace mrn { return table_name_; } - int len = strlen(mysql_path_); + int len = strlen(original_mysql_path_); int i = len, j = 0; - for (; mysql_path_[--i] != FN_LIBCHAR ;) {} - if (mysql_path_[i + 1] == '_') { + for (; original_mysql_path_[--i] != FN_LIBCHAR ;) {} + if (original_mysql_path_[i + 1] == '_') { table_name_[j++] = '@'; table_name_[j++] = '0'; table_name_[j++] = '0'; @@ -166,7 +173,7 @@ namespace mrn { i++; } for (; i < len ;) { - table_name_[j++] = mysql_path_[++i]; + table_name_[j++] = original_mysql_path_[++i]; } table_name_[j] = '\0'; return table_name_; @@ -180,13 +187,39 @@ namespace mrn { return mysql_table_name_; } - int len = strlen(mysql_path_); + int len = strlen(original_mysql_path_); int i = len, j = 0; - for (; mysql_path_[--i] != FN_LIBCHAR ;) {} + for (; original_mysql_path_[--i] != FN_LIBCHAR ;) {} for (; i < len ;) { - mysql_table_name_[j++] = mysql_path_[++i]; + if (len - i - 1 >= 3 && + strncmp(original_mysql_path_ + i + 1, "#P#", 3) == 0) { + break; + } + mysql_table_name_[j++] = original_mysql_path_[++i]; } mysql_table_name_[j] = '\0'; return mysql_table_name_; } + + /** + * "./${db}/${table}" ==> "./${db}/${table}" + * "./${db}/${table}#P#xxx" ==> "./${db}/${table}" + */ + const char *PathMapper::mysql_path() { + if (mysql_path_[0] != '\0') { + return mysql_path_; + } + + int i; + int len = strlen(original_mysql_path_); + for (i = 0; i < len; i++) { + if (len - i >= 3 && + strncmp(original_mysql_path_ + i, "#P#", 3) == 0) { + break; + } + mysql_path_[i] = original_mysql_path_[i]; + } + mysql_path_[i] = '\0'; + return mysql_path_; + } } |