mirror of
https://github.com/MariaDB/server.git
synced 2026-05-14 19:07:15 +02:00
Merge c-9a08e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1-bugs
into c-9a08e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/wl2826 configure.in: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/handler.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_partition.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged dbug/dbug.c: Manual merge include/my_dbug.h: Manual merge sql/ha_heap.cc: Manual merge sql/ha_myisammrg.cc: Manual merge sql/ha_partition.cc: Manual merge sql/log.cc: Manual merge sql/share/errmsg.txt: Manual merge
This commit is contained in:
commit
1154609c39
24 changed files with 2338 additions and 507 deletions
|
|
@ -102,7 +102,9 @@ handlerton partition_hton = {
|
|||
alter_table_flags, /* Partition flags */
|
||||
NULL, /* Alter Tablespace */
|
||||
NULL, /* Fill FILES table */
|
||||
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
|
||||
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
|
||||
NULL, /* binlog function */
|
||||
NULL /* binlog query */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -392,88 +394,6 @@ int ha_partition::ha_initialise()
|
|||
/****************************************************************************
|
||||
MODULE meta data changes
|
||||
****************************************************************************/
|
||||
/*
|
||||
Create partition names
|
||||
|
||||
SYNOPSIS
|
||||
create_partition_name()
|
||||
out:out Created partition name string
|
||||
in1 First part
|
||||
in2 Second part
|
||||
name_variant Normal, temporary or renamed partition name
|
||||
|
||||
RETURN VALUE
|
||||
NONE
|
||||
|
||||
DESCRIPTION
|
||||
This method is used to calculate the partition name, service routine to
|
||||
the del_ren_cre_table method.
|
||||
*/
|
||||
|
||||
#define NORMAL_PART_NAME 0
|
||||
#define TEMP_PART_NAME 1
|
||||
#define RENAMED_PART_NAME 2
|
||||
static void create_partition_name(char *out, const char *in1,
|
||||
const char *in2, uint name_variant,
|
||||
bool translate)
|
||||
{
|
||||
char transl_part_name[FN_REFLEN];
|
||||
const char *transl_part;
|
||||
|
||||
if (translate)
|
||||
{
|
||||
tablename_to_filename(in2, transl_part_name, FN_REFLEN);
|
||||
transl_part= transl_part_name;
|
||||
}
|
||||
else
|
||||
transl_part= in2;
|
||||
if (name_variant == NORMAL_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part, NullS);
|
||||
else if (name_variant == TEMP_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part, "#TMP#", NullS);
|
||||
else if (name_variant == RENAMED_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part, "#REN#", NullS);
|
||||
}
|
||||
|
||||
/*
|
||||
Create subpartition name
|
||||
|
||||
SYNOPSIS
|
||||
create_subpartition_name()
|
||||
out:out Created partition name string
|
||||
in1 First part
|
||||
in2 Second part
|
||||
in3 Third part
|
||||
name_variant Normal, temporary or renamed partition name
|
||||
|
||||
RETURN VALUE
|
||||
NONE
|
||||
|
||||
DESCRIPTION
|
||||
This method is used to calculate the subpartition name, service routine to
|
||||
the del_ren_cre_table method.
|
||||
*/
|
||||
|
||||
static void create_subpartition_name(char *out, const char *in1,
|
||||
const char *in2, const char *in3,
|
||||
uint name_variant)
|
||||
{
|
||||
char transl_part_name[FN_REFLEN], transl_subpart_name[FN_REFLEN];
|
||||
|
||||
tablename_to_filename(in2, transl_part_name, FN_REFLEN);
|
||||
tablename_to_filename(in3, transl_subpart_name, FN_REFLEN);
|
||||
if (name_variant == NORMAL_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part_name,
|
||||
"#SP#", transl_subpart_name, NullS);
|
||||
else if (name_variant == TEMP_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part_name,
|
||||
"#SP#", transl_subpart_name, "#TMP#", NullS);
|
||||
else if (name_variant == RENAMED_PART_NAME)
|
||||
strxmov(out, in1, "#P#", transl_part_name,
|
||||
"#SP#", transl_subpart_name, "#REN#", NullS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Delete a table
|
||||
|
||||
|
|
@ -564,7 +484,9 @@ int ha_partition::rename_table(const char *from, const char *to)
|
|||
and types of engines in the partitions.
|
||||
*/
|
||||
|
||||
int ha_partition::create_handler_files(const char *name)
|
||||
int ha_partition::create_handler_files(const char *path,
|
||||
const char *old_path,
|
||||
bool rename_flag)
|
||||
{
|
||||
DBUG_ENTER("ha_partition::create_handler_files()");
|
||||
|
||||
|
|
@ -572,10 +494,26 @@ int ha_partition::create_handler_files(const char *name)
|
|||
We need to update total number of parts since we might write the handler
|
||||
file as part of a partition management command
|
||||
*/
|
||||
if (create_handler_file(name))
|
||||
if (rename_flag)
|
||||
{
|
||||
my_error(ER_CANT_CREATE_HANDLER_FILE, MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
char name[FN_REFLEN];
|
||||
char old_name[FN_REFLEN];
|
||||
|
||||
strxmov(name, path, ha_par_ext, NullS);
|
||||
strxmov(old_name, old_path, ha_par_ext, NullS);
|
||||
if (my_delete(name, MYF(MY_WME)) ||
|
||||
my_rename(old_name, name, MYF(MY_WME)))
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (create_handler_file(path))
|
||||
{
|
||||
my_error(ER_CANT_CREATE_HANDLER_FILE, MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
@ -641,45 +579,26 @@ int ha_partition::create(const char *name, TABLE *table_arg,
|
|||
int ha_partition::drop_partitions(const char *path)
|
||||
{
|
||||
List_iterator<partition_element> part_it(m_part_info->partitions);
|
||||
List_iterator<partition_element> temp_it(m_part_info->temp_partitions);
|
||||
char part_name_buff[FN_REFLEN];
|
||||
uint no_parts= m_part_info->partitions.elements;
|
||||
uint part_count= 0;
|
||||
uint no_subparts= m_part_info->no_subparts;
|
||||
uint i= 0;
|
||||
uint name_variant;
|
||||
int error= 1;
|
||||
bool reorged_parts= (m_reorged_parts > 0);
|
||||
bool temp_partitions= (m_part_info->temp_partitions.elements > 0);
|
||||
int ret_error;
|
||||
int error= 0;
|
||||
DBUG_ENTER("ha_partition::drop_partitions");
|
||||
|
||||
if (temp_partitions)
|
||||
no_parts= m_part_info->temp_partitions.elements;
|
||||
do
|
||||
{
|
||||
partition_element *part_elem;
|
||||
if (temp_partitions)
|
||||
{
|
||||
/*
|
||||
We need to remove the reorganised partitions that were put in the
|
||||
temp_partitions-list.
|
||||
*/
|
||||
part_elem= temp_it++;
|
||||
DBUG_ASSERT(part_elem->part_state == PART_TO_BE_DROPPED);
|
||||
}
|
||||
else
|
||||
part_elem= part_it++;
|
||||
if (part_elem->part_state == PART_TO_BE_DROPPED ||
|
||||
part_elem->part_state == PART_IS_CHANGED)
|
||||
partition_element *part_elem= part_it++;
|
||||
if (part_elem->part_state == PART_TO_BE_DROPPED)
|
||||
{
|
||||
handler *file;
|
||||
/*
|
||||
This part is to be dropped, meaning the part or all its subparts.
|
||||
*/
|
||||
name_variant= NORMAL_PART_NAME;
|
||||
if (part_elem->part_state == PART_IS_CHANGED ||
|
||||
(part_elem->part_state == PART_TO_BE_DROPPED && temp_partitions))
|
||||
name_variant= RENAMED_PART_NAME;
|
||||
if (m_is_sub_partitioned)
|
||||
{
|
||||
List_iterator<partition_element> sub_it(part_elem->subpartitions);
|
||||
|
|
@ -691,12 +610,10 @@ int ha_partition::drop_partitions(const char *path)
|
|||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, name_variant);
|
||||
if (reorged_parts)
|
||||
file= m_reorged_file[part_count++];
|
||||
else
|
||||
file= m_file[part];
|
||||
file= m_file[part];
|
||||
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
|
||||
error= file->delete_table((const char *) part_name_buff);
|
||||
if ((ret_error= file->delete_table((const char *) part_name_buff)))
|
||||
error= ret_error;
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
else
|
||||
|
|
@ -704,12 +621,10 @@ int ha_partition::drop_partitions(const char *path)
|
|||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, name_variant,
|
||||
TRUE);
|
||||
if (reorged_parts)
|
||||
file= m_reorged_file[part_count++];
|
||||
else
|
||||
file= m_file[i];
|
||||
file= m_file[i];
|
||||
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
|
||||
error= file->delete_table((const char *) part_name_buff);
|
||||
if ((ret_error= file->delete_table((const char *) part_name_buff)))
|
||||
error= ret_error;
|
||||
}
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
part_elem->part_state= PART_NORMAL;
|
||||
|
|
@ -751,7 +666,8 @@ int ha_partition::rename_partitions(const char *path)
|
|||
uint no_subparts= m_part_info->no_subparts;
|
||||
uint i= 0;
|
||||
uint j= 0;
|
||||
int error= 1;
|
||||
int error= 0;
|
||||
int ret_error;
|
||||
uint temp_partitions= m_part_info->temp_partitions.elements;
|
||||
handler *file;
|
||||
partition_element *part_elem, *sub_elem;
|
||||
|
|
@ -759,6 +675,14 @@ int ha_partition::rename_partitions(const char *path)
|
|||
|
||||
if (temp_partitions)
|
||||
{
|
||||
/*
|
||||
These are the reorganised partitions that have already been copied.
|
||||
We delete the partitions and log the delete by inactivating the
|
||||
delete log entry in the table log. We only need to synchronise
|
||||
these writes before moving to the next loop since there is no
|
||||
interaction among reorganised partitions, they cannot have the
|
||||
same name.
|
||||
*/
|
||||
do
|
||||
{
|
||||
part_elem= temp_it++;
|
||||
|
|
@ -769,39 +693,59 @@ int ha_partition::rename_partitions(const char *path)
|
|||
{
|
||||
sub_elem= sub_it++;
|
||||
file= m_reorged_file[part_count++];
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
RENAMED_PART_NAME);
|
||||
create_subpartition_name(norm_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
NORMAL_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
|
||||
if ((ret_error= file->delete_table((const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
sub_elem->log_entry= NULL; /* Indicate success */
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
else
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, RENAMED_PART_NAME,
|
||||
TRUE);
|
||||
create_partition_name(norm_name_buff, path,
|
||||
part_elem->partition_name, NORMAL_PART_NAME,
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->delete_table((const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
part_elem->log_entry= NULL; /* Indicate success */
|
||||
}
|
||||
} while (++i < temp_partitions);
|
||||
VOID(sync_table_log());
|
||||
}
|
||||
i= 0;
|
||||
do
|
||||
{
|
||||
/*
|
||||
When state is PART_IS_CHANGED it means that we have created a new
|
||||
TEMP partition that is to be renamed to normal partition name and
|
||||
we are to delete the old partition with currently the normal name.
|
||||
|
||||
We perform this operation by
|
||||
1) Delete old partition with normal partition name
|
||||
2) Signal this in table log entry
|
||||
3) Synch table log to ensure we have consistency in crashes
|
||||
4) Rename temporary partition name to normal partition name
|
||||
5) Signal this to table log entry
|
||||
It is not necessary to synch the last state since a new rename
|
||||
should not corrupt things if there was no temporary partition.
|
||||
|
||||
The only other parts we need to cater for are new parts that
|
||||
replace reorganised parts. The reorganised parts were deleted
|
||||
by the code above that goes through the temp_partitions list.
|
||||
Thus the synch above makes it safe to simply perform step 4 and 5
|
||||
for those entries.
|
||||
*/
|
||||
part_elem= part_it++;
|
||||
if (part_elem->part_state == PART_IS_CHANGED ||
|
||||
(part_elem->part_state == PART_IS_ADDED && temp_partitions))
|
||||
|
|
@ -823,14 +767,12 @@ int ha_partition::rename_partitions(const char *path)
|
|||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
RENAMED_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
|
||||
if ((ret_error= file->delete_table((const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
VOID(sync_table_log());
|
||||
}
|
||||
file= m_new_file[part];
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
|
|
@ -839,8 +781,13 @@ int ha_partition::rename_partitions(const char *path)
|
|||
TEMP_PART_NAME);
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
error= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff);
|
||||
if ((ret_error= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
sub_elem->log_entry= NULL;
|
||||
} while (++j < no_subparts);
|
||||
}
|
||||
else
|
||||
|
|
@ -851,13 +798,12 @@ int ha_partition::rename_partitions(const char *path)
|
|||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, RENAMED_PART_NAME,
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
norm_name_buff, part_name_buff));
|
||||
error= file->rename_table((const char *) norm_name_buff,
|
||||
(const char *) part_name_buff);
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->delete_table((const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
VOID(sync_table_log());
|
||||
}
|
||||
file= m_new_file[i];
|
||||
create_partition_name(part_name_buff, path,
|
||||
|
|
@ -865,11 +811,17 @@ int ha_partition::rename_partitions(const char *path)
|
|||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
error= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff);
|
||||
if ((ret_error= file->rename_table((const char *) part_name_buff,
|
||||
(const char *) norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (inactivate_table_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
part_elem->log_entry= NULL;
|
||||
}
|
||||
}
|
||||
} while (++i < no_parts);
|
||||
VOID(sync_table_log());
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
|
@ -1861,8 +1813,8 @@ bool ha_partition::create_handler_file(const char *name)
|
|||
{
|
||||
part_elem= part_it++;
|
||||
if (part_elem->part_state != PART_NORMAL &&
|
||||
part_elem->part_state != PART_IS_ADDED &&
|
||||
part_elem->part_state != PART_IS_CHANGED)
|
||||
part_elem->part_state != PART_TO_BE_ADDED &&
|
||||
part_elem->part_state != PART_CHANGED)
|
||||
continue;
|
||||
tablename_to_filename(part_elem->partition_name, part_name,
|
||||
FN_REFLEN);
|
||||
|
|
@ -1913,8 +1865,8 @@ bool ha_partition::create_handler_file(const char *name)
|
|||
{
|
||||
part_elem= part_it++;
|
||||
if (part_elem->part_state != PART_NORMAL &&
|
||||
part_elem->part_state != PART_IS_ADDED &&
|
||||
part_elem->part_state != PART_IS_CHANGED)
|
||||
part_elem->part_state != PART_TO_BE_ADDED &&
|
||||
part_elem->part_state != PART_CHANGED)
|
||||
continue;
|
||||
if (!m_is_sub_partitioned)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue