Commit 83d418a2 authored by unknown's avatar unknown

WL 2826: A third step, fixing generate_partition_syntax


sql/mysql_priv.h:
  Make it possible to set injector code and value
  Declare header part of a set of new functions
sql/sql_partition.cc:
  Fix generate_partition_syntax to handle shadow variant of frm file
parent 9b6c2bc2
......@@ -611,8 +611,15 @@ struct Query_cache_query_flags
#define ERROR_INJECTOR(x)
#define ERROR_INJECTOR_ACTION(x)
#define ERROR_INJECTOR_CRASH(x)
#define SET_ERROR_INJECT_CODE(x)
#define SET_ERROR_INJECT_VALUE(x)
#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
my_error_inject(int error)
{
......@@ -632,6 +639,7 @@ my_error_inject(int error)
#define ERROR_INJECT(code) \
(my_error_inject((code)) ? 1 : 0)
#endif
uint build_table_path(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext);
void write_bin_log(THD *thd, bool clear_error,
......@@ -1128,7 +1136,14 @@ typedef struct st_lock_param_type
} ALTER_PARTITION_PARAM_TYPE;
void mem_alloc_error(size_t size);
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_INSTALL_SHADOW 2
#define WFRM_PACK_FRM
......
......@@ -2388,15 +2388,10 @@ char *generate_partition_syntax(partition_info *part_info,
char path[FN_REFLEN];
int err= 0;
List_iterator<partition_element> part_it(part_info->partitions);
List_iterator<partition_element> temp_it(part_info->temp_partitions);
File fptr;
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");
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))
DBUG_RETURN(NULL);
#ifndef __WIN__
......@@ -2459,8 +2454,7 @@ char *generate_partition_syntax(partition_info *part_info,
err+= add_space(fptr);
}
}
no_parts= part_info->no_parts;
tot_no_parts= no_parts + no_temp_parts;
tot_no_parts= part_info->partitions.elements;
no_subparts= part_info->no_subparts;
if (write_all || (!part_info->use_default_partitions))
......@@ -2469,57 +2463,10 @@ char *generate_partition_syntax(partition_info *part_info,
i= 0;
do
{
/*
We need to do some clever list manipulation here since we have two
different needs for our list processing and here we take some of the
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= part_it++;
if (part_elem->part_state != PART_TO_BE_DROPPED &&
part_elem->part_state != PART_REORGED_DROPPED)
{
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_string(fptr, part_elem->partition_name);
err+= add_space(fptr);
......@@ -2558,7 +2505,6 @@ char *generate_partition_syntax(partition_info *part_info,
if (i == (tot_no_parts-1))
err+= add_end_parenthesis(fptr);
} while (++i < tot_no_parts);
DBUG_ASSERT(!no_parts && !no_temp_parts);
}
if (err)
goto close_file;
......@@ -4576,6 +4522,7 @@ that are reorganised.
my_error(ER_ROW_IS_REFERENCED, MYF(0));
DBUG_RETURN(TRUE);
}
tab_part_info->no_parts-= no_parts_dropped;
}
else if ((alter_info->flags & ALTER_OPTIMIZE_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
even in the presence of a crash.
......
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