diff options
author | Mattias Jonsson <mattiasj@mysql.com> | 2008-08-12 12:26:23 +0200 |
---|---|---|
committer | Mattias Jonsson <mattiasj@mysql.com> | 2008-08-12 12:26:23 +0200 |
commit | f84bf0077d4eba3798820c72a9c1fdfa8d78c5a0 (patch) | |
tree | c37997f38ab924c9706f08ded9e966d08e391773 /sql | |
parent | 4cb12690c75eaa17e85236fcdc28b9e5faf0629f (diff) | |
parent | 295fc5834aef999a8f77d0b38037699d7a2b26bc (diff) | |
download | mariadb-git-f84bf0077d4eba3798820c72a9c1fdfa8d78c5a0.tar.gz |
manual merge of bug#37402
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 45 | ||||
-rw-r--r-- | sql/handler.cc | 10 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 |
3 files changed, 46 insertions, 11 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c7711ca37b8..dfaa58c9249 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -593,6 +593,12 @@ int ha_partition::drop_partitions(const char *path) int error= 0; DBUG_ENTER("ha_partition::drop_partitions"); + /* + Assert that it works without HA_FILE_BASED and lower_case_table_name = 2. + We use m_file[0] as long as all partitions have the same storage engine. + */ + DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path, + part_name_buff))); do { partition_element *part_elem= part_it++; @@ -682,6 +688,13 @@ int ha_partition::rename_partitions(const char *path) partition_element *part_elem, *sub_elem; DBUG_ENTER("ha_partition::rename_partitions"); + /* + Assert that it works without HA_FILE_BASED and lower_case_table_name = 2. + We use m_file[0] as long as all partitions have the same storage engine. + */ + DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path, + norm_name_buff))); + if (temp_partitions) { /* @@ -1344,6 +1357,12 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, THD *thd= current_thd; DBUG_ENTER("ha_partition::change_partitions"); + /* + Assert that it works without HA_FILE_BASED and lower_case_table_name = 2. + We use m_file[0] as long as all partitions have the same storage engine. + */ + DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path, + part_name_buff))); m_reorged_parts= 0; if (!m_part_info->is_sub_partitioned()) no_subparts= 1; @@ -1776,8 +1795,10 @@ uint ha_partition::del_ren_cre_table(const char *from, { int save_error= 0; int error; - char from_buff[FN_REFLEN], to_buff[FN_REFLEN]; + char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN], + to_lc_buff[FN_REFLEN]; char *name_buffer_ptr; + const char *from_path, *to_path; uint i; handler **file, **abort_file; DBUG_ENTER("del_ren_cre_table()"); @@ -1785,17 +1806,29 @@ uint ha_partition::del_ren_cre_table(const char *from, if (get_from_handler_file(from, current_thd->mem_root)) DBUG_RETURN(TRUE); DBUG_ASSERT(m_file_buffer); + DBUG_PRINT("enter", ("from: (%s) to: (%s)", from, to)); name_buffer_ptr= m_name_buffer_ptr; file= m_file; + /* + Since ha_partition has HA_FILE_BASED, it must alter underlying table names + if they do not have HA_FILE_BASED and lower_case_table_names == 2. + See Bug#37402, for Mac OS X. + The appended #P#<partname>[#SP#<subpartname>] will remain in current case. + Using the first partitions handler, since mixing handlers is not allowed. + */ + from_path= get_canonical_filename(*file, from, from_lc_buff); + if (to != NULL) + to_path= get_canonical_filename(*file, to, to_lc_buff); i= 0; do { - create_partition_name(from_buff, from, name_buffer_ptr, NORMAL_PART_NAME, - FALSE); + create_partition_name(from_buff, from_path, name_buffer_ptr, + NORMAL_PART_NAME, FALSE); + if (to != NULL) { // Rename branch - create_partition_name(to_buff, to, name_buffer_ptr, NORMAL_PART_NAME, - FALSE); + create_partition_name(to_buff, to_path, name_buffer_ptr, + NORMAL_PART_NAME, FALSE); error= (*file)->ha_rename_table(from_buff, to_buff); } else if (table_arg == NULL) // delete branch @@ -1817,7 +1850,7 @@ create_error: name_buffer_ptr= m_name_buffer_ptr; for (abort_file= file, file= m_file; file < abort_file; file++) { - create_partition_name(from_buff, from, name_buffer_ptr, NORMAL_PART_NAME, + create_partition_name(from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME, FALSE); VOID((*file)->ha_delete_table((const char*) from_buff)); name_buffer_ptr= strend(name_buffer_ptr) + 1; diff --git a/sql/handler.cc b/sql/handler.cc index e550295ebba..cc2db397ad4 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1814,8 +1814,8 @@ bool ha_flush_logs(handlerton *db_type) return FALSE; } -static const char *check_lowercase_names(handler *file, const char *path, - char *tmp_path) +const char *get_canonical_filename(handler *file, const char *path, + char *tmp_path) { if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED)) return path; @@ -1886,7 +1886,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type))) DBUG_RETURN(ENOENT); - path= check_lowercase_names(file, path, tmp_path); + path= get_canonical_filename(file, path, tmp_path); if ((error= file->ha_delete_table(path)) && generate_warning) { /* @@ -3422,7 +3422,7 @@ int ha_create_table(THD *thd, const char *path, if (update_create_info) update_create_info_from_table(create_info, &table); - name= check_lowercase_names(table.file, share.path.str, name_buff); + name= get_canonical_filename(table.file, share.path.str, name_buff); error= table.file->ha_create(name, &table, create_info); VOID(closefrm(&table, 0)); @@ -3494,7 +3494,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) update_create_info_from_table(&create_info, &table); create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE; - check_lowercase_names(table.file, path, path); + get_canonical_filename(table.file, path, path); error=table.file->ha_create(path, &table, &create_info); VOID(closefrm(&table, 1)); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e9deb479c5e..6f2080eaa4f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2227,6 +2227,8 @@ uint tablename_to_filename(const char *from, char *to, uint to_length); #ifdef MYSQL_SERVER uint build_table_filename(char *buff, size_t bufflen, const char *db, const char *table, const char *ext, uint flags); +const char *get_canonical_filename(handler *file, const char *path, + char *tmp_path); #define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" #define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 |