Commit f305a7ce authored by Sergei Golubchik's avatar Sergei Golubchik

bugfix: long partition names

parent a7ed4644
set names utf8;
create database mysqltest1;
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
Warnings:
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
ERROR HY000: The path specified for @0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@ is too long.
drop database mysqltest1;
source include/have_innodb.inc;
source include/have_partition.inc;
set names utf8;
create database mysqltest1;
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
--error ER_PATH_LENGTH
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
id int(10) unsigned NOT NULL,
id2 int(10) unsigned NOT NULL,
PRIMARY KEY ( id, id2 )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
PARTITION BY RANGE ( id )
SUBPARTITION BY HASH ( id2 )
SUBPARTITIONS 2 (
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
drop database mysqltest1;
...@@ -634,7 +634,7 @@ int ha_partition::create(const char *name, TABLE *table_arg, ...@@ -634,7 +634,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
int ha_partition::drop_partitions(const char *path) int ha_partition::drop_partitions(const char *path)
{ {
List_iterator<partition_element> part_it(m_part_info->partitions); List_iterator<partition_element> part_it(m_part_info->partitions);
char part_name_buff[FN_REFLEN]; char part_name_buff[FN_REFLEN + 1];
uint num_parts= m_part_info->partitions.elements; uint num_parts= m_part_info->partitions.elements;
uint num_subparts= m_part_info->num_subparts; uint num_subparts= m_part_info->num_subparts;
uint i= 0; uint i= 0;
...@@ -667,9 +667,11 @@ int ha_partition::drop_partitions(const char *path) ...@@ -667,9 +667,11 @@ int ha_partition::drop_partitions(const char *path)
{ {
partition_element *sub_elem= sub_it++; partition_element *sub_elem= sub_it++;
part= i * num_subparts + j; part= i * num_subparts + j;
create_subpartition_name(part_name_buff, path, if ((ret_error= create_subpartition_name(part_name_buff,
part_elem->partition_name, sizeof(part_name_buff), path,
sub_elem->partition_name, name_variant); part_elem->partition_name,
sub_elem->partition_name, name_variant)))
error= ret_error;
file= m_file[part]; file= m_file[part];
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff)); DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
if ((ret_error= file->ha_delete_table(part_name_buff))) if ((ret_error= file->ha_delete_table(part_name_buff)))
...@@ -680,15 +682,19 @@ int ha_partition::drop_partitions(const char *path) ...@@ -680,15 +682,19 @@ int ha_partition::drop_partitions(const char *path)
} }
else else
{ {
create_partition_name(part_name_buff, path, if ((ret_error= create_partition_name(part_name_buff,
part_elem->partition_name, name_variant, sizeof(part_name_buff), path,
TRUE); part_elem->partition_name, name_variant, TRUE)))
file= m_file[i];
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
if ((ret_error= file->ha_delete_table(part_name_buff)))
error= ret_error; error= ret_error;
if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos)) else
error= 1; {
file= m_file[i];
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
if ((ret_error= file->ha_delete_table(part_name_buff)))
error= ret_error;
if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
}
} }
if (part_elem->part_state == PART_IS_CHANGED) if (part_elem->part_state == PART_IS_CHANGED)
part_elem->part_state= PART_NORMAL; part_elem->part_state= PART_NORMAL;
...@@ -724,8 +730,8 @@ int ha_partition::rename_partitions(const char *path) ...@@ -724,8 +730,8 @@ int ha_partition::rename_partitions(const char *path)
{ {
List_iterator<partition_element> part_it(m_part_info->partitions); List_iterator<partition_element> part_it(m_part_info->partitions);
List_iterator<partition_element> temp_it(m_part_info->temp_partitions); List_iterator<partition_element> temp_it(m_part_info->temp_partitions);
char part_name_buff[FN_REFLEN]; char part_name_buff[FN_REFLEN + 1];
char norm_name_buff[FN_REFLEN]; char norm_name_buff[FN_REFLEN + 1];
uint num_parts= m_part_info->partitions.elements; uint num_parts= m_part_info->partitions.elements;
uint part_count= 0; uint part_count= 0;
uint num_subparts= m_part_info->num_subparts; uint num_subparts= m_part_info->num_subparts;
...@@ -767,10 +773,11 @@ int ha_partition::rename_partitions(const char *path) ...@@ -767,10 +773,11 @@ int ha_partition::rename_partitions(const char *path)
{ {
sub_elem= sub_it++; sub_elem= sub_it++;
file= m_reorged_file[part_count++]; file= m_reorged_file[part_count++];
create_subpartition_name(norm_name_buff, path, if ((ret_error= create_subpartition_name(norm_name_buff,
part_elem->partition_name, sizeof(norm_name_buff), path,
sub_elem->partition_name, part_elem->partition_name,
NORMAL_PART_NAME); sub_elem->partition_name, NORMAL_PART_NAME)))
error= ret_error;
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff)); DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
if ((ret_error= file->ha_delete_table(norm_name_buff))) if ((ret_error= file->ha_delete_table(norm_name_buff)))
error= ret_error; error= ret_error;
...@@ -783,16 +790,20 @@ int ha_partition::rename_partitions(const char *path) ...@@ -783,16 +790,20 @@ int ha_partition::rename_partitions(const char *path)
else else
{ {
file= m_reorged_file[part_count++]; file= m_reorged_file[part_count++];
create_partition_name(norm_name_buff, path, if ((ret_error= create_partition_name(norm_name_buff,
part_elem->partition_name, NORMAL_PART_NAME, sizeof(norm_name_buff), path,
TRUE); part_elem->partition_name, NORMAL_PART_NAME, TRUE)))
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
if ((ret_error= file->ha_delete_table(norm_name_buff)))
error= ret_error; error= ret_error;
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
else else
part_elem->log_entry= NULL; /* Indicate success */ {
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
if ((ret_error= file->ha_delete_table(norm_name_buff)))
error= ret_error;
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
else
part_elem->log_entry= NULL; /* Indicate success */
}
} }
} while (++i < temp_partitions); } while (++i < temp_partitions);
(void) sync_ddl_log(); (void) sync_ddl_log();
...@@ -835,10 +846,11 @@ int ha_partition::rename_partitions(const char *path) ...@@ -835,10 +846,11 @@ int ha_partition::rename_partitions(const char *path)
{ {
sub_elem= sub_it++; sub_elem= sub_it++;
part= i * num_subparts + j; part= i * num_subparts + j;
create_subpartition_name(norm_name_buff, path, if ((ret_error= create_subpartition_name(norm_name_buff,
part_elem->partition_name, sizeof(norm_name_buff), path,
sub_elem->partition_name, part_elem->partition_name,
NORMAL_PART_NAME); sub_elem->partition_name, NORMAL_PART_NAME)))
error= ret_error;
if (part_elem->part_state == PART_IS_CHANGED) if (part_elem->part_state == PART_IS_CHANGED)
{ {
file= m_reorged_file[part_count++]; file= m_reorged_file[part_count++];
...@@ -850,10 +862,11 @@ int ha_partition::rename_partitions(const char *path) ...@@ -850,10 +862,11 @@ int ha_partition::rename_partitions(const char *path)
(void) sync_ddl_log(); (void) sync_ddl_log();
} }
file= m_new_file[part]; file= m_new_file[part];
create_subpartition_name(part_name_buff, path, if ((ret_error= create_subpartition_name(part_name_buff,
part_elem->partition_name, sizeof(part_name_buff), path,
sub_elem->partition_name, part_elem->partition_name,
TEMP_PART_NAME); sub_elem->partition_name, TEMP_PART_NAME)))
error= ret_error;
DBUG_PRINT("info", ("Rename subpartition from %s to %s", DBUG_PRINT("info", ("Rename subpartition from %s to %s",
part_name_buff, norm_name_buff)); part_name_buff, norm_name_buff));
if ((ret_error= file->ha_rename_table(part_name_buff, if ((ret_error= file->ha_rename_table(part_name_buff,
...@@ -867,32 +880,36 @@ int ha_partition::rename_partitions(const char *path) ...@@ -867,32 +880,36 @@ int ha_partition::rename_partitions(const char *path)
} }
else else
{ {
create_partition_name(norm_name_buff, path, if ((ret_error= create_partition_name(norm_name_buff,
part_elem->partition_name, NORMAL_PART_NAME, sizeof(norm_name_buff), path,
TRUE); part_elem->partition_name, NORMAL_PART_NAME, TRUE)) ||
if (part_elem->part_state == PART_IS_CHANGED) (ret_error= create_partition_name(part_name_buff,
sizeof(part_name_buff), path,
part_elem->partition_name, TEMP_PART_NAME, TRUE)))
error= ret_error;
else
{ {
file= m_reorged_file[part_count++]; if (part_elem->part_state == PART_IS_CHANGED)
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff)); {
if ((ret_error= file->ha_delete_table(norm_name_buff))) file= m_reorged_file[part_count++];
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
if ((ret_error= file->ha_delete_table(norm_name_buff)))
error= ret_error;
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
(void) sync_ddl_log();
}
file= m_new_file[i];
DBUG_PRINT("info", ("Rename partition from %s to %s",
part_name_buff, norm_name_buff));
if ((ret_error= file->ha_rename_table(part_name_buff,
norm_name_buff)))
error= ret_error; error= ret_error;
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos)) else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1; error= 1;
(void) sync_ddl_log(); else
part_elem->log_entry= NULL;
} }
file= m_new_file[i];
create_partition_name(part_name_buff, path,
part_elem->partition_name, TEMP_PART_NAME,
TRUE);
DBUG_PRINT("info", ("Rename partition from %s to %s",
part_name_buff, norm_name_buff));
if ((ret_error= file->ha_rename_table(part_name_buff,
norm_name_buff)))
error= ret_error;
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
else
part_elem->log_entry= NULL;
} }
} }
} while (++i < num_parts); } while (++i < num_parts);
...@@ -1488,7 +1505,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1488,7 +1505,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
{ {
List_iterator<partition_element> part_it(m_part_info->partitions); List_iterator<partition_element> part_it(m_part_info->partitions);
List_iterator <partition_element> t_it(m_part_info->temp_partitions); List_iterator <partition_element> t_it(m_part_info->temp_partitions);
char part_name_buff[FN_REFLEN]; char part_name_buff[FN_REFLEN + 1];
uint num_parts= m_part_info->partitions.elements; uint num_parts= m_part_info->partitions.elements;
uint num_subparts= m_part_info->num_subparts; uint num_subparts= m_part_info->num_subparts;
uint i= 0; uint i= 0;
...@@ -1698,10 +1715,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1698,10 +1715,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
do do
{ {
partition_element *sub_elem= sub_it++; partition_element *sub_elem= sub_it++;
create_subpartition_name(part_name_buff, path, if ((error= create_subpartition_name(part_name_buff,
part_elem->partition_name, sizeof(part_name_buff), path,
sub_elem->partition_name, part_elem->partition_name, sub_elem->partition_name,
name_variant); name_variant)))
{
cleanup_new_partition(part_count);
DBUG_RETURN(error);
}
part= i * num_subparts + j; part= i * num_subparts + j;
DBUG_PRINT("info", ("Add subpartition %s", part_name_buff)); DBUG_PRINT("info", ("Add subpartition %s", part_name_buff));
if ((error= prepare_new_partition(table, create_info, if ((error= prepare_new_partition(table, create_info,
...@@ -1719,9 +1740,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1719,9 +1740,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
} }
else else
{ {
create_partition_name(part_name_buff, path, if ((error= create_partition_name(part_name_buff,
part_elem->partition_name, name_variant, sizeof(part_name_buff), path, part_elem->partition_name,
TRUE); name_variant, TRUE)))
{
cleanup_new_partition(part_count);
DBUG_RETURN(error);
}
DBUG_PRINT("info", ("Add partition %s", part_name_buff)); DBUG_PRINT("info", ("Add partition %s", part_name_buff));
if ((error= prepare_new_partition(table, create_info, if ((error= prepare_new_partition(table, create_info,
new_file_array[i], new_file_array[i],
...@@ -1980,8 +2006,8 @@ int ha_partition::del_ren_cre_table(const char *from, ...@@ -1980,8 +2006,8 @@ int ha_partition::del_ren_cre_table(const char *from,
{ {
int save_error= 0; int save_error= 0;
int error= HA_ERR_INTERNAL_ERROR; int error= HA_ERR_INTERNAL_ERROR;
char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN], char from_buff[FN_REFLEN + 1], to_buff[FN_REFLEN + 1],
to_lc_buff[FN_REFLEN], buff[FN_REFLEN]; from_lc_buff[FN_REFLEN], to_lc_buff[FN_REFLEN], buff[FN_REFLEN];
char *name_buffer_ptr; char *name_buffer_ptr;
const char *from_path; const char *from_path;
const char *to_path= NULL; const char *to_path= NULL;
...@@ -2028,13 +2054,15 @@ int ha_partition::del_ren_cre_table(const char *from, ...@@ -2028,13 +2054,15 @@ int ha_partition::del_ren_cre_table(const char *from,
i= 0; i= 0;
do do
{ {
create_partition_name(from_buff, from_path, name_buffer_ptr, if ((error= create_partition_name(from_buff, sizeof(from_buff), from_path,
NORMAL_PART_NAME, FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
goto rename_error;
if (to != NULL) if (to != NULL)
{ // Rename branch { // Rename branch
create_partition_name(to_buff, to_path, name_buffer_ptr, if ((error= create_partition_name(to_buff, sizeof(to_buff), to_path,
NORMAL_PART_NAME, FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
goto rename_error;
error= (*file)->ha_rename_table(from_buff, to_buff); error= (*file)->ha_rename_table(from_buff, to_buff);
if (error) if (error)
goto rename_error; goto rename_error;
...@@ -2081,9 +2109,9 @@ int ha_partition::del_ren_cre_table(const char *from, ...@@ -2081,9 +2109,9 @@ int ha_partition::del_ren_cre_table(const char *from,
name_buffer_ptr= m_name_buffer_ptr; name_buffer_ptr= m_name_buffer_ptr;
for (abort_file= file, file= m_file; file < abort_file; file++) for (abort_file= file, file= m_file; file < abort_file; file++)
{ {
create_partition_name(from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME, if (!create_partition_name(from_buff, sizeof(from_buff), from_path,
FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE))
(void) (*file)->ha_delete_table((const char*) from_buff); (void) (*file)->ha_delete_table(from_buff);
name_buffer_ptr= strend(name_buffer_ptr) + 1; name_buffer_ptr= strend(name_buffer_ptr) + 1;
} }
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -2092,12 +2120,11 @@ int ha_partition::del_ren_cre_table(const char *from, ...@@ -2092,12 +2120,11 @@ int ha_partition::del_ren_cre_table(const char *from,
for (abort_file= file, file= m_file; file < abort_file; file++) for (abort_file= file, file= m_file; file < abort_file; file++)
{ {
/* Revert the rename, back from 'to' to the original 'from' */ /* Revert the rename, back from 'to' to the original 'from' */
create_partition_name(from_buff, from_path, name_buffer_ptr, if (!create_partition_name(from_buff, sizeof(from_buff), from_path,
NORMAL_PART_NAME, FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE) &&
create_partition_name(to_buff, to_path, name_buffer_ptr, !create_partition_name(to_buff, sizeof(to_buff), to_path, name_buffer_ptr,
NORMAL_PART_NAME, FALSE); NORMAL_PART_NAME, FALSE))
/* Ignore error here */ (void) (*file)->ha_rename_table(to_buff, from_buff);
(void) (*file)->ha_rename_table(to_buff, from_buff);
name_buffer_ptr= strend(name_buffer_ptr) + 1; name_buffer_ptr= strend(name_buffer_ptr) + 1;
} }
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -2895,7 +2922,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) ...@@ -2895,7 +2922,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
char *name_buffer_ptr; char *name_buffer_ptr;
int error= HA_ERR_INITIALIZATION; int error= HA_ERR_INITIALIZATION;
handler **file; handler **file;
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN + 1];
bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE); bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
ulonglong check_table_flags; ulonglong check_table_flags;
DBUG_ENTER("ha_partition::open"); DBUG_ENTER("ha_partition::open");
...@@ -2965,8 +2992,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) ...@@ -2965,8 +2992,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
file= m_is_clone_of->m_file; file= m_is_clone_of->m_file;
for (i= 0; i < m_tot_parts; i++) for (i= 0; i < m_tot_parts; i++)
{ {
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME, if ((error= create_partition_name(name_buff, sizeof(name_buff), name,
FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
goto err_handler;
if (!(m_file[i]= file[i]->clone(name_buff, m_clone_mem_root))) if (!(m_file[i]= file[i]->clone(name_buff, m_clone_mem_root)))
{ {
error= HA_ERR_INITIALIZATION; error= HA_ERR_INITIALIZATION;
...@@ -2981,8 +3009,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) ...@@ -2981,8 +3009,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
file= m_file; file= m_file;
do do
{ {
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME, if ((error= create_partition_name(name_buff, sizeof(name_buff), name,
FALSE); name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
goto err_handler;
table->s->connect_string = m_connect_string[(uint)(file-m_file)]; table->s->connect_string = m_connect_string[(uint)(file-m_file)];
if ((error= (*file)->ha_open(table, name_buff, mode, test_if_locked))) if ((error= (*file)->ha_open(table, name_buff, mode, test_if_locked)))
goto err_handler; goto err_handler;
......
...@@ -5882,8 +5882,8 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -5882,8 +5882,8 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DDL_LOG_ENTRY ddl_log_entry; DDL_LOG_ENTRY ddl_log_entry;
partition_info *part_info= lpt->part_info; partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *log_entry;
char tmp_path[FN_REFLEN]; char tmp_path[FN_REFLEN + 1];
char normal_path[FN_REFLEN]; char normal_path[FN_REFLEN + 1];
List_iterator<partition_element> part_it(part_info->partitions); List_iterator<partition_element> part_it(part_info->partitions);
uint temp_partitions= part_info->temp_partitions.elements; uint temp_partitions= part_info->temp_partitions.elements;
uint num_elements= part_info->partitions.elements; uint num_elements= part_info->partitions.elements;
...@@ -5907,14 +5907,15 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -5907,14 +5907,15 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
ddl_log_entry.next_entry= *next_entry; ddl_log_entry.next_entry= *next_entry;
ddl_log_entry.handler_name= ddl_log_entry.handler_name=
ha_resolve_storage_engine_name(sub_elem->engine_type); ha_resolve_storage_engine_name(sub_elem->engine_type);
create_subpartition_name(tmp_path, path, if (create_subpartition_name(tmp_path, sizeof(tmp_path), path,
part_elem->partition_name, part_elem->partition_name,
sub_elem->partition_name, sub_elem->partition_name,
TEMP_PART_NAME); TEMP_PART_NAME) ||
create_subpartition_name(normal_path, path, create_subpartition_name(normal_path, sizeof(normal_path), path,
part_elem->partition_name, part_elem->partition_name,
sub_elem->partition_name, sub_elem->partition_name,
NORMAL_PART_NAME); NORMAL_PART_NAME))
DBUG_RETURN(TRUE);
ddl_log_entry.name= normal_path; ddl_log_entry.name= normal_path;
ddl_log_entry.from_name= tmp_path; ddl_log_entry.from_name= tmp_path;
if (part_elem->part_state == PART_IS_CHANGED) if (part_elem->part_state == PART_IS_CHANGED)
...@@ -5935,12 +5936,13 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -5935,12 +5936,13 @@ static bool write_log_changed_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
ddl_log_entry.next_entry= *next_entry; ddl_log_entry.next_entry= *next_entry;
ddl_log_entry.handler_name= ddl_log_entry.handler_name=
ha_resolve_storage_engine_name(part_elem->engine_type); ha_resolve_storage_engine_name(part_elem->engine_type);
create_partition_name(tmp_path, path, if (create_partition_name(tmp_path, sizeof(tmp_path), path,
part_elem->partition_name, part_elem->partition_name, TEMP_PART_NAME,
TEMP_PART_NAME, TRUE); TRUE) ||
create_partition_name(normal_path, path, create_partition_name(normal_path, sizeof(normal_path), path,
part_elem->partition_name, part_elem->partition_name, NORMAL_PART_NAME,
NORMAL_PART_NAME, TRUE); TRUE))
DBUG_RETURN(TRUE);
ddl_log_entry.name= normal_path; ddl_log_entry.name= normal_path;
ddl_log_entry.from_name= tmp_path; ddl_log_entry.from_name= tmp_path;
if (part_elem->part_state == PART_IS_CHANGED) if (part_elem->part_state == PART_IS_CHANGED)
...@@ -5979,7 +5981,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -5979,7 +5981,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DDL_LOG_ENTRY ddl_log_entry; DDL_LOG_ENTRY ddl_log_entry;
partition_info *part_info= lpt->part_info; partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *log_entry;
char tmp_path[FN_LEN]; char tmp_path[FN_REFLEN + 1];
List_iterator<partition_element> part_it(part_info->partitions); List_iterator<partition_element> part_it(part_info->partitions);
List_iterator<partition_element> temp_it(part_info->temp_partitions); List_iterator<partition_element> temp_it(part_info->temp_partitions);
uint num_temp_partitions= part_info->temp_partitions.elements; uint num_temp_partitions= part_info->temp_partitions.elements;
...@@ -6018,10 +6020,10 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -6018,10 +6020,10 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
ddl_log_entry.next_entry= *next_entry; ddl_log_entry.next_entry= *next_entry;
ddl_log_entry.handler_name= ddl_log_entry.handler_name=
ha_resolve_storage_engine_name(sub_elem->engine_type); ha_resolve_storage_engine_name(sub_elem->engine_type);
create_subpartition_name(tmp_path, path, if (create_subpartition_name(tmp_path, sizeof(tmp_path), path,
part_elem->partition_name, part_elem->partition_name,
sub_elem->partition_name, sub_elem->partition_name, name_variant))
name_variant); DBUG_RETURN(TRUE);
ddl_log_entry.name= tmp_path; ddl_log_entry.name= tmp_path;
if (write_ddl_log_entry(&ddl_log_entry, &log_entry)) if (write_ddl_log_entry(&ddl_log_entry, &log_entry))
{ {
...@@ -6037,9 +6039,10 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -6037,9 +6039,10 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
ddl_log_entry.next_entry= *next_entry; ddl_log_entry.next_entry= *next_entry;
ddl_log_entry.handler_name= ddl_log_entry.handler_name=
ha_resolve_storage_engine_name(part_elem->engine_type); ha_resolve_storage_engine_name(part_elem->engine_type);
create_partition_name(tmp_path, path, if (create_partition_name(tmp_path, sizeof(tmp_path), path,
part_elem->partition_name, part_elem->partition_name, name_variant,
name_variant, TRUE); TRUE))
DBUG_RETURN(TRUE);
ddl_log_entry.name= tmp_path; ddl_log_entry.name= tmp_path;
if (write_ddl_log_entry(&ddl_log_entry, &log_entry)) if (write_ddl_log_entry(&ddl_log_entry, &log_entry))
{ {
...@@ -8117,31 +8120,41 @@ static uint32 get_next_subpartition_via_walking(PARTITION_ITERATOR *part_iter) ...@@ -8117,31 +8120,41 @@ static uint32 get_next_subpartition_via_walking(PARTITION_ITERATOR *part_iter)
} }
/* used in error messages below */
static const char *longest_str(const char *s1, const char *s2,
const char *s3=0)
{
if (strlen(s2) > strlen(s1)) s1= s2;
if (s3 && strlen(s3) > strlen(s1)) s1= s3;
return s1;
}
/* /*
Create partition names Create partition names
SYNOPSIS SYNOPSIS
create_partition_name() create_partition_name()
out:out Created partition name string out:out The buffer for the created partition name string
must be *at least* of FN_REFLEN+1 bytes
in1 First part in1 First part
in2 Second part in2 Second part
name_variant Normal, temporary or renamed partition name name_variant Normal, temporary or renamed partition name
RETURN VALUE RETURN VALUE
NONE 0 if ok, error if name too long
DESCRIPTION DESCRIPTION
This method is used to calculate the partition name, service routine to This method is used to calculate the partition name, service routine to
the del_ren_cre_table method. the del_ren_cre_table method.
*/ */
void create_partition_name(char *out, const char *in1, int create_partition_name(char *out, size_t outlen, const char *in1,
const char *in2, uint name_variant, const char *in2, uint name_variant, bool translate)
bool translate)
{ {
char transl_part_name[FN_REFLEN]; char transl_part_name[FN_REFLEN];
const char *transl_part; const char *transl_part, *end;
DBUG_ASSERT(outlen >= FN_REFLEN + 1); // consistency! same limit everywhere
if (translate) if (translate)
{ {
...@@ -8151,11 +8164,17 @@ void create_partition_name(char *out, const char *in1, ...@@ -8151,11 +8164,17 @@ void create_partition_name(char *out, const char *in1,
else else
transl_part= in2; transl_part= in2;
if (name_variant == NORMAL_PART_NAME) if (name_variant == NORMAL_PART_NAME)
strxmov(out, in1, "#P#", transl_part, NullS); end= strxnmov(out, outlen-1, in1, "#P#", transl_part, NullS);
else if (name_variant == TEMP_PART_NAME) else if (name_variant == TEMP_PART_NAME)
strxmov(out, in1, "#P#", transl_part, "#TMP#", NullS); end= strxnmov(out, outlen-1, in1, "#P#", transl_part, "#TMP#", NullS);
else if (name_variant == RENAMED_PART_NAME) else if (name_variant == RENAMED_PART_NAME)
strxmov(out, in1, "#P#", transl_part, "#REN#", NullS); end= strxnmov(out, outlen-1, in1, "#P#", transl_part, "#REN#", NullS);
if (end - out == static_cast<ptrdiff_t>(outlen-1))
{
my_error(ER_PATH_LENGTH, MYF(0), longest_str(in1, transl_part));
return HA_WRONG_CREATE_OPTION;
}
return 0;
} }
...@@ -8164,37 +8183,46 @@ void create_partition_name(char *out, const char *in1, ...@@ -8164,37 +8183,46 @@ void create_partition_name(char *out, const char *in1,
SYNOPSIS SYNOPSIS
create_subpartition_name() create_subpartition_name()
out:out Created partition name string out:out The buffer for the created partition name string
must be *at least* of FN_REFLEN+1 bytes
in1 First part in1 First part
in2 Second part in2 Second part
in3 Third part in3 Third part
name_variant Normal, temporary or renamed partition name name_variant Normal, temporary or renamed partition name
RETURN VALUE RETURN VALUE
NONE 0 if ok, error if name too long
DESCRIPTION DESCRIPTION
This method is used to calculate the subpartition name, service routine to This method is used to calculate the subpartition name, service routine to
the del_ren_cre_table method. the del_ren_cre_table method.
*/ */
void create_subpartition_name(char *out, const char *in1, int create_subpartition_name(char *out, size_t outlen,
const char *in2, const char *in3, const char *in1, const char *in2,
uint name_variant) const char *in3, uint name_variant)
{ {
char transl_part_name[FN_REFLEN], transl_subpart_name[FN_REFLEN]; char transl_part_name[FN_REFLEN], transl_subpart_name[FN_REFLEN], *end;
DBUG_ASSERT(outlen >= FN_REFLEN + 1); // consistency! same limit everywhere
tablename_to_filename(in2, transl_part_name, FN_REFLEN); tablename_to_filename(in2, transl_part_name, FN_REFLEN);
tablename_to_filename(in3, transl_subpart_name, FN_REFLEN); tablename_to_filename(in3, transl_subpart_name, FN_REFLEN);
if (name_variant == NORMAL_PART_NAME) if (name_variant == NORMAL_PART_NAME)
strxmov(out, in1, "#P#", transl_part_name, end= strxnmov(out, outlen-1, in1, "#P#", transl_part_name,
"#SP#", transl_subpart_name, NullS); "#SP#", transl_subpart_name, NullS);
else if (name_variant == TEMP_PART_NAME) else if (name_variant == TEMP_PART_NAME)
strxmov(out, in1, "#P#", transl_part_name, end= strxnmov(out, outlen-1, in1, "#P#", transl_part_name,
"#SP#", transl_subpart_name, "#TMP#", NullS); "#SP#", transl_subpart_name, "#TMP#", NullS);
else if (name_variant == RENAMED_PART_NAME) else if (name_variant == RENAMED_PART_NAME)
strxmov(out, in1, "#P#", transl_part_name, end= strxnmov(out, outlen-1, in1, "#P#", transl_part_name,
"#SP#", transl_subpart_name, "#REN#", NullS); "#SP#", transl_subpart_name, "#REN#", NullS);
if (end - out == static_cast<ptrdiff_t>(outlen-1))
{
my_error(ER_PATH_LENGTH, MYF(0),
longest_str(in1, transl_part_name, transl_subpart_name));
return HA_WRONG_CREATE_OPTION;
}
return 0;
} }
uint get_partition_field_store_length(Field *field) uint get_partition_field_store_length(Field *field)
......
...@@ -274,12 +274,12 @@ bool partition_key_modified(TABLE *table, const MY_BITMAP *fields); ...@@ -274,12 +274,12 @@ bool partition_key_modified(TABLE *table, const MY_BITMAP *fields);
#define partition_key_modified(X,Y) 0 #define partition_key_modified(X,Y) 0
#endif #endif
void create_partition_name(char *out, const char *in1, int __attribute__((warn_unused_result))
const char *in2, uint name_variant, create_partition_name(char *out, size_t outlen, const char *in1, const char
bool translate); *in2, uint name_variant, bool translate);
void create_subpartition_name(char *out, const char *in1, int __attribute__((warn_unused_result))
const char *in2, const char *in3, create_subpartition_name(char *out, size_t outlen, const char *in1, const
uint name_variant); char *in2, const char *in3, uint name_variant);
void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf); void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
void set_key_field_ptr(KEY *key_info, const uchar *new_buf, void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment