mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
WL 2826: A third step, fixing generate_partition_syntax
This commit is contained in:
@ -611,8 +611,15 @@ struct Query_cache_query_flags
|
|||||||
#define ERROR_INJECTOR(x)
|
#define ERROR_INJECTOR(x)
|
||||||
#define ERROR_INJECTOR_ACTION(x)
|
#define ERROR_INJECTOR_ACTION(x)
|
||||||
#define ERROR_INJECTOR_CRASH(x)
|
#define ERROR_INJECTOR_CRASH(x)
|
||||||
|
#define SET_ERROR_INJECT_CODE(x)
|
||||||
|
#define SET_ERROR_INJECT_VALUE(x)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define SET_ERROR_INJECT_CODE(x) \
|
||||||
|
current_thd->variables.error_inject_code= (x)
|
||||||
|
#define SET_ERROR_INJECT_VALUE(x) \
|
||||||
|
current_thd->variables.error_inject_value= (x)
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
my_error_inject(int error)
|
my_error_inject(int error)
|
||||||
{
|
{
|
||||||
@ -632,6 +639,7 @@ my_error_inject(int error)
|
|||||||
#define ERROR_INJECT(code) \
|
#define ERROR_INJECT(code) \
|
||||||
(my_error_inject((code)) ? 1 : 0)
|
(my_error_inject((code)) ? 1 : 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint build_table_path(char *buff, size_t bufflen, const char *db,
|
uint build_table_path(char *buff, size_t bufflen, const char *db,
|
||||||
const char *table, const char *ext);
|
const char *table, const char *ext);
|
||||||
void write_bin_log(THD *thd, bool clear_error,
|
void write_bin_log(THD *thd, bool clear_error,
|
||||||
@ -1128,7 +1136,14 @@ typedef struct st_lock_param_type
|
|||||||
} ALTER_PARTITION_PARAM_TYPE;
|
} ALTER_PARTITION_PARAM_TYPE;
|
||||||
|
|
||||||
void mem_alloc_error(size_t size);
|
void mem_alloc_error(size_t size);
|
||||||
|
|
||||||
bool write_table_log(ALTER_PARTITION_PARAM_TYPE *lpt);
|
bool write_table_log(ALTER_PARTITION_PARAM_TYPE *lpt);
|
||||||
|
bool write_log_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt, bool install_flag);
|
||||||
|
bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt);
|
||||||
|
bool write_log_add_partition(ALTER_PARTITION_PARAM_TYPE *lpt);
|
||||||
|
bool write_log_ph1_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt);
|
||||||
|
bool write_log_ph2_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt);
|
||||||
|
|
||||||
#define WFRM_WRITE_SHADOW 1
|
#define WFRM_WRITE_SHADOW 1
|
||||||
#define WFRM_INSTALL_SHADOW 2
|
#define WFRM_INSTALL_SHADOW 2
|
||||||
#define WFRM_PACK_FRM
|
#define WFRM_PACK_FRM
|
||||||
|
@ -2388,15 +2388,10 @@ char *generate_partition_syntax(partition_info *part_info,
|
|||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
int err= 0;
|
int err= 0;
|
||||||
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);
|
|
||||||
File fptr;
|
File fptr;
|
||||||
char *buf= NULL; //Return buffer
|
char *buf= NULL; //Return buffer
|
||||||
uint use_temp= 0;
|
|
||||||
uint no_temp_parts= part_info->temp_partitions.elements;
|
|
||||||
bool write_part_state;
|
|
||||||
DBUG_ENTER("generate_partition_syntax");
|
DBUG_ENTER("generate_partition_syntax");
|
||||||
|
|
||||||
write_part_state= (part_info->part_state && !part_info->part_state_len);
|
|
||||||
if (unlikely(((fptr= create_temp_file(path,mysql_tmpdir,"psy", 0,0))) < 0))
|
if (unlikely(((fptr= create_temp_file(path,mysql_tmpdir,"psy", 0,0))) < 0))
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
#ifndef __WIN__
|
#ifndef __WIN__
|
||||||
@ -2459,8 +2454,7 @@ char *generate_partition_syntax(partition_info *part_info,
|
|||||||
err+= add_space(fptr);
|
err+= add_space(fptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
no_parts= part_info->no_parts;
|
tot_no_parts= part_info->partitions.elements;
|
||||||
tot_no_parts= no_parts + no_temp_parts;
|
|
||||||
no_subparts= part_info->no_subparts;
|
no_subparts= part_info->no_subparts;
|
||||||
|
|
||||||
if (write_all || (!part_info->use_default_partitions))
|
if (write_all || (!part_info->use_default_partitions))
|
||||||
@ -2469,57 +2463,10 @@ char *generate_partition_syntax(partition_info *part_info,
|
|||||||
i= 0;
|
i= 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/*
|
part_elem= part_it++;
|
||||||
We need to do some clever list manipulation here since we have two
|
if (part_elem->part_state != PART_TO_BE_DROPPED &&
|
||||||
different needs for our list processing and here we take some of the
|
part_elem->part_state != PART_REORGED_DROPPED)
|
||||||
cost of using a simpler list processing for the other parts of the
|
|
||||||
code.
|
|
||||||
|
|
||||||
ALTER TABLE REORGANIZE PARTITIONS has the list of partitions to be
|
|
||||||
the final list as the main list and the reorganised partitions is in
|
|
||||||
the temporary partition list. Thus when finding the first part added
|
|
||||||
we insert the temporary list if there is such a list. If there is no
|
|
||||||
temporary list we are performing an ADD PARTITION.
|
|
||||||
*/
|
|
||||||
if (use_temp && use_temp <= no_temp_parts)
|
|
||||||
{
|
{
|
||||||
part_elem= temp_it++;
|
|
||||||
DBUG_ASSERT(no_temp_parts);
|
|
||||||
no_temp_parts--;
|
|
||||||
}
|
|
||||||
else if (use_temp)
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(no_parts);
|
|
||||||
part_elem= save_part_elem;
|
|
||||||
use_temp= 0;
|
|
||||||
no_parts--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
part_elem= part_it++;
|
|
||||||
if ((part_elem->part_state == PART_TO_BE_ADDED ||
|
|
||||||
part_elem->part_state == PART_IS_ADDED) && no_temp_parts)
|
|
||||||
{
|
|
||||||
save_part_elem= part_elem;
|
|
||||||
part_elem= temp_it++;
|
|
||||||
no_temp_parts--;
|
|
||||||
use_temp= 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(no_parts);
|
|
||||||
no_parts--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (part_elem->part_state != PART_IS_DROPPED)
|
|
||||||
{
|
|
||||||
if (write_part_state)
|
|
||||||
{
|
|
||||||
uint32 part_state_id= part_info->part_state_len;
|
|
||||||
part_info->part_state[part_state_id]= (uchar)part_elem->part_state;
|
|
||||||
part_info->part_state_len= part_state_id+1;
|
|
||||||
}
|
|
||||||
err+= add_partition(fptr);
|
err+= add_partition(fptr);
|
||||||
err+= add_string(fptr, part_elem->partition_name);
|
err+= add_string(fptr, part_elem->partition_name);
|
||||||
err+= add_space(fptr);
|
err+= add_space(fptr);
|
||||||
@ -2558,7 +2505,6 @@ char *generate_partition_syntax(partition_info *part_info,
|
|||||||
if (i == (tot_no_parts-1))
|
if (i == (tot_no_parts-1))
|
||||||
err+= add_end_parenthesis(fptr);
|
err+= add_end_parenthesis(fptr);
|
||||||
} while (++i < tot_no_parts);
|
} while (++i < tot_no_parts);
|
||||||
DBUG_ASSERT(!no_parts && !no_temp_parts);
|
|
||||||
}
|
}
|
||||||
if (err)
|
if (err)
|
||||||
goto close_file;
|
goto close_file;
|
||||||
@ -4576,6 +4522,7 @@ that are reorganised.
|
|||||||
my_error(ER_ROW_IS_REFERENCED, MYF(0));
|
my_error(ER_ROW_IS_REFERENCED, MYF(0));
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
tab_part_info->no_parts-= no_parts_dropped;
|
||||||
}
|
}
|
||||||
else if ((alter_info->flags & ALTER_OPTIMIZE_PARTITION) ||
|
else if ((alter_info->flags & ALTER_OPTIMIZE_PARTITION) ||
|
||||||
(alter_info->flags & ALTER_ANALYZE_PARTITION) ||
|
(alter_info->flags & ALTER_ANALYZE_PARTITION) ||
|
||||||
@ -5138,29 +5085,6 @@ write_log_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt, bool install_frm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Write the log entries to ensure that the drop partition command is completed
|
|
||||||
even in the presence of a crash.
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
write_log_drop_partition()
|
|
||||||
lpt Struct containing parameters
|
|
||||||
RETURN VALUES
|
|
||||||
TRUE Error
|
|
||||||
FALSE Success
|
|
||||||
DESCRIPTION
|
|
||||||
Prepare entries to the table log indicating all partitions to drop and to
|
|
||||||
install the shadow frm file and remove the old frm file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool
|
|
||||||
write_log_add_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
|
||||||
{
|
|
||||||
DBUG_ENTER("write_log_drop_partition");
|
|
||||||
DBUG_RETURN(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Write the log entries to ensure that the drop partition command is completed
|
Write the log entries to ensure that the drop partition command is completed
|
||||||
even in the presence of a crash.
|
even in the presence of a crash.
|
||||||
|
Reference in New Issue
Block a user