Commit 062a3176 authored by Michael Widenius's avatar Michael Widenius Committed by Monty

Remove mem_alloc_error()

As thd->alloc() and new automatically calls my_error(ER_OUTOFMEORY)
there is no reason to call mem_alloc_error()

Other things:
- Fixed bug in mysql_unpack_partition() where lex.part_info was
  changed even if it would be a null pointer
parent 70c1110a
...@@ -1769,7 +1769,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1769,7 +1769,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
!(m_reorged_file= (handler**) thd->calloc(sizeof(handler*)* !(m_reorged_file= (handler**) thd->calloc(sizeof(handler*)*
(m_reorged_parts + 1)))) (m_reorged_parts + 1))))
{ {
mem_alloc_error(sizeof(handler*)*(m_reorged_parts+1));
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
} }
...@@ -1802,7 +1801,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1802,7 +1801,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
thd->calloc(sizeof(handler*)* thd->calloc(sizeof(handler*)*
(2*(num_remain_partitions + 1)))))) (2*(num_remain_partitions + 1))))))
{ {
mem_alloc_error(sizeof(handler*)*2*(num_remain_partitions+1));
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
} }
m_added_file= &new_file_array[num_remain_partitions + 1]; m_added_file= &new_file_array[num_remain_partitions + 1];
...@@ -1894,7 +1892,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1894,7 +1892,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
thd->mem_root, thd->mem_root,
part_elem->engine_type))) part_elem->engine_type)))
{ {
mem_alloc_error(sizeof(handler));
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
} }
if ((*new_file)->set_ha_share_ref(&p_share_refs->ha_shares[j])) if ((*new_file)->set_ha_share_ref(&p_share_refs->ha_shares[j]))
...@@ -2922,10 +2919,8 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root) ...@@ -2922,10 +2919,8 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root)
DBUG_ENTER("ha_partition::new_handlers_from_part_info"); DBUG_ENTER("ha_partition::new_handlers_from_part_info");
if (!(m_file= (handler **) alloc_root(mem_root, alloc_len))) if (!(m_file= (handler **) alloc_root(mem_root, alloc_len)))
{ goto error;
mem_alloc_error(alloc_len);
goto error_end;
}
m_file_tot_parts= m_tot_parts; m_file_tot_parts= m_tot_parts;
bzero((char*) m_file, alloc_len); bzero((char*) m_file, alloc_len);
DBUG_ASSERT(m_part_info->num_parts > 0); DBUG_ASSERT(m_part_info->num_parts > 0);
...@@ -2966,8 +2961,6 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root) ...@@ -2966,8 +2961,6 @@ bool ha_partition::new_handlers_from_part_info(MEM_ROOT *mem_root)
} }
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
error: error:
mem_alloc_error(sizeof(handler));
error_end:
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
......
...@@ -48,11 +48,9 @@ partition_info *partition_info::get_clone(THD *thd) ...@@ -48,11 +48,9 @@ partition_info *partition_info::get_clone(THD *thd)
List_iterator<partition_element> part_it(partitions); List_iterator<partition_element> part_it(partitions);
partition_element *part; partition_element *part;
partition_info *clone= new (mem_root) partition_info(*this); partition_info *clone= new (mem_root) partition_info(*this);
if (!clone) if (unlikely(!clone))
{
mem_alloc_error(sizeof(partition_info));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions)); memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions));
memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions)); memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions));
clone->bitmaps_are_initialized= FALSE; clone->bitmaps_are_initialized= FALSE;
...@@ -64,20 +62,16 @@ partition_info *partition_info::get_clone(THD *thd) ...@@ -64,20 +62,16 @@ partition_info *partition_info::get_clone(THD *thd)
partition_element *subpart; partition_element *subpart;
partition_element *part_clone= new (mem_root) partition_element(); partition_element *part_clone= new (mem_root) partition_element();
if (!part_clone) if (!part_clone)
{
mem_alloc_error(sizeof(partition_element));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
memcpy(part_clone, part, sizeof(partition_element)); memcpy(part_clone, part, sizeof(partition_element));
part_clone->subpartitions.empty(); part_clone->subpartitions.empty();
while ((subpart= (subpart_it++))) while ((subpart= (subpart_it++)))
{ {
partition_element *subpart_clone= new (mem_root) partition_element(); partition_element *subpart_clone= new (mem_root) partition_element();
if (!subpart_clone) if (!subpart_clone)
{
mem_alloc_error(sizeof(partition_element));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
memcpy(subpart_clone, subpart, sizeof(partition_element)); memcpy(subpart_clone, subpart, sizeof(partition_element));
part_clone->subpartitions.push_back(subpart_clone, mem_root); part_clone->subpartitions.push_back(subpart_clone, mem_root);
} }
...@@ -88,20 +82,15 @@ partition_info *partition_info::get_clone(THD *thd) ...@@ -88,20 +82,15 @@ partition_info *partition_info::get_clone(THD *thd)
(part_elem_value *)alloc_root(mem_root, sizeof(part_elem_value) * (part_elem_value *)alloc_root(mem_root, sizeof(part_elem_value) *
part->list_val_list.elements); part->list_val_list.elements);
if (!new_val_arr) if (!new_val_arr)
{
mem_alloc_error(sizeof(part_elem_value) * part->list_val_list.elements);
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
p_column_list_val *new_colval_arr= p_column_list_val *new_colval_arr=
(p_column_list_val*)alloc_root(mem_root, sizeof(p_column_list_val) * (p_column_list_val*)alloc_root(mem_root, sizeof(p_column_list_val) *
num_columns * num_columns *
part->list_val_list.elements); part->list_val_list.elements);
if (!new_colval_arr) if (!new_colval_arr)
{
mem_alloc_error(sizeof(p_column_list_val) * num_columns *
part->list_val_list.elements);
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
part_elem_value *val; part_elem_value *val;
while ((val= list_val_it++)) while ((val= list_val_it++))
{ {
...@@ -394,10 +383,6 @@ char *partition_info::create_default_partition_names(THD *thd, uint part_no, ...@@ -394,10 +383,6 @@ char *partition_info::create_default_partition_names(THD *thd, uint part_no,
move_ptr+= MAX_PART_NAME_SIZE; move_ptr+= MAX_PART_NAME_SIZE;
} while (++i < num_parts_arg); } while (++i < num_parts_arg);
} }
else
{
mem_alloc_error(num_parts_arg*MAX_PART_NAME_SIZE);
}
DBUG_RETURN(ptr); DBUG_RETURN(ptr);
} }
...@@ -422,13 +407,8 @@ char *partition_info::create_default_subpartition_name(THD *thd, uint subpart_no ...@@ -422,13 +407,8 @@ char *partition_info::create_default_subpartition_name(THD *thd, uint subpart_no
DBUG_ENTER("create_default_subpartition_name"); DBUG_ENTER("create_default_subpartition_name");
if (likely(ptr != NULL)) if (likely(ptr != NULL))
{
my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no); my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no);
}
else
{
mem_alloc_error(size_alloc);
}
DBUG_RETURN(ptr); DBUG_RETURN(ptr);
} }
...@@ -505,10 +485,7 @@ bool partition_info::set_up_default_partitions(THD *thd, handler *file, ...@@ -505,10 +485,7 @@ bool partition_info::set_up_default_partitions(THD *thd, handler *file,
default_name+=MAX_PART_NAME_SIZE; default_name+=MAX_PART_NAME_SIZE;
} }
else else
{
mem_alloc_error(sizeof(partition_element));
goto end; goto end;
}
} while (++i < num_parts); } while (++i < num_parts);
result= FALSE; result= FALSE;
end: end:
...@@ -574,10 +551,7 @@ bool partition_info::set_up_default_subpartitions(THD *thd, handler *file, ...@@ -574,10 +551,7 @@ bool partition_info::set_up_default_subpartitions(THD *thd, handler *file,
subpart_elem->partition_name= ptr; subpart_elem->partition_name= ptr;
} }
else else
{
mem_alloc_error(sizeof(partition_element));
goto end; goto end;
}
} while (++j < num_subparts); } while (++j < num_subparts);
} while (++i < num_parts); } while (++i < num_parts);
result= FALSE; result= FALSE;
...@@ -1506,11 +1480,9 @@ bool partition_info::set_part_expr(THD *thd, char *start_token, Item *item_ptr, ...@@ -1506,11 +1480,9 @@ bool partition_info::set_part_expr(THD *thd, char *start_token, Item *item_ptr,
size_t expr_len= end_token - start_token; size_t expr_len= end_token - start_token;
char *func_string= (char*) thd->memdup(start_token, expr_len); char *func_string= (char*) thd->memdup(start_token, expr_len);
if (!func_string) if (unlikely(!func_string))
{
mem_alloc_error(expr_len);
return TRUE; return TRUE;
}
if (is_subpart) if (is_subpart)
{ {
list_of_subpart_fields= FALSE; list_of_subpart_fields= FALSE;
...@@ -1665,7 +1637,6 @@ bool partition_info::set_up_charset_field_preps(THD *thd) ...@@ -1665,7 +1637,6 @@ bool partition_info::set_up_charset_field_preps(THD *thd)
} }
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
error: error:
mem_alloc_error(size);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -1972,10 +1943,8 @@ bool partition_info::init_column_part(THD *thd) ...@@ -1972,10 +1943,8 @@ bool partition_info::init_column_part(THD *thd)
if (!(list_val= if (!(list_val=
(part_elem_value*) thd->calloc(sizeof(part_elem_value))) || (part_elem_value*) thd->calloc(sizeof(part_elem_value))) ||
p_elem->list_val_list.push_back(list_val, thd->mem_root)) p_elem->list_val_list.push_back(list_val, thd->mem_root))
{
mem_alloc_error(sizeof(part_elem_value));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
}
if (num_columns) if (num_columns)
loc_num_columns= num_columns; loc_num_columns= num_columns;
else else
...@@ -1983,10 +1952,8 @@ bool partition_info::init_column_part(THD *thd) ...@@ -1983,10 +1952,8 @@ bool partition_info::init_column_part(THD *thd)
if (!(col_val_array= if (!(col_val_array=
(part_column_list_val*) thd->calloc(loc_num_columns * (part_column_list_val*) thd->calloc(loc_num_columns *
sizeof(part_column_list_val)))) sizeof(part_column_list_val))))
{
mem_alloc_error(loc_num_columns * sizeof(part_elem_value));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
}
list_val->col_val_array= col_val_array; list_val->col_val_array= col_val_array;
list_val->added_items= 0; list_val->added_items= 0;
curr_list_val= list_val; curr_list_val= list_val;
...@@ -2202,7 +2169,6 @@ bool partition_info::fix_column_value_functions(THD *thd, ...@@ -2202,7 +2169,6 @@ bool partition_info::fix_column_value_functions(THD *thd,
thd->variables.sql_mode= save_sql_mode; thd->variables.sql_mode= save_sql_mode;
if (!(val_ptr= (uchar*) thd->memdup(field->ptr, len))) if (!(val_ptr= (uchar*) thd->memdup(field->ptr, len)))
{ {
mem_alloc_error(len);
result= TRUE; result= TRUE;
goto end; goto end;
} }
...@@ -2717,11 +2683,9 @@ bool partition_info::vers_init_info(THD * thd) ...@@ -2717,11 +2683,9 @@ bool partition_info::vers_init_info(THD * thd)
column_list= TRUE; column_list= TRUE;
num_columns= 1; num_columns= 1;
vers_info= new (thd->mem_root) Vers_part_info; vers_info= new (thd->mem_root) Vers_part_info;
if (!vers_info) if (unlikely(!vers_info))
{
mem_alloc_error(sizeof(Vers_part_info));
return true; return true;
}
return false; return false;
} }
......
...@@ -343,7 +343,7 @@ static bool set_up_field_array(THD *thd, TABLE *table, ...@@ -343,7 +343,7 @@ static bool set_up_field_array(THD *thd, TABLE *table,
if (field->flags & GET_FIXED_FIELDS_FLAG) if (field->flags & GET_FIXED_FIELDS_FLAG)
num_fields++; num_fields++;
} }
if (num_fields > MAX_REF_PARTS) if (unlikely(num_fields > MAX_REF_PARTS))
{ {
char *err_str; char *err_str;
if (is_sub_part) if (is_sub_part)
...@@ -359,15 +359,13 @@ static bool set_up_field_array(THD *thd, TABLE *table, ...@@ -359,15 +359,13 @@ static bool set_up_field_array(THD *thd, TABLE *table,
We are using hidden key as partitioning field We are using hidden key as partitioning field
*/ */
DBUG_ASSERT(!is_sub_part); DBUG_ASSERT(!is_sub_part);
DBUG_RETURN(result); DBUG_RETURN(FALSE);
} }
size_field_array= (num_fields+1)*sizeof(Field*); size_field_array= (num_fields+1)*sizeof(Field*);
field_array= (Field**) thd->calloc(size_field_array); field_array= (Field**) thd->calloc(size_field_array);
if (unlikely(!field_array)) if (unlikely(!field_array))
{ DBUG_RETURN(TRUE);
mem_alloc_error(size_field_array);
result= TRUE;
}
ptr= table->field; ptr= table->field;
while ((field= *(ptr++))) while ((field= *(ptr++)))
{ {
...@@ -490,7 +488,6 @@ static bool create_full_part_field_array(THD *thd, TABLE *table, ...@@ -490,7 +488,6 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
field_array= (Field**) thd->calloc(size_field_array); field_array= (Field**) thd->calloc(size_field_array);
if (unlikely(!field_array)) if (unlikely(!field_array))
{ {
mem_alloc_error(size_field_array);
result= TRUE; result= TRUE;
goto end; goto end;
} }
...@@ -515,14 +512,12 @@ static bool create_full_part_field_array(THD *thd, TABLE *table, ...@@ -515,14 +512,12 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
if (!(bitmap_buf= (my_bitmap_map*) if (!(bitmap_buf= (my_bitmap_map*)
thd->alloc(bitmap_buffer_size(table->s->fields)))) thd->alloc(bitmap_buffer_size(table->s->fields))))
{ {
mem_alloc_error(bitmap_buffer_size(table->s->fields));
result= TRUE; result= TRUE;
goto end; goto end;
} }
if (my_bitmap_init(&part_info->full_part_field_set, bitmap_buf, if (unlikely(my_bitmap_init(&part_info->full_part_field_set, bitmap_buf,
table->s->fields, FALSE)) table->s->fields, FALSE)))
{ {
mem_alloc_error(table->s->fields);
result= TRUE; result= TRUE;
goto end; goto end;
} }
...@@ -1088,12 +1083,11 @@ static bool set_up_partition_bitmaps(THD *thd, partition_info *part_info) ...@@ -1088,12 +1083,11 @@ static bool set_up_partition_bitmaps(THD *thd, partition_info *part_info)
DBUG_ASSERT(!part_info->bitmaps_are_initialized); DBUG_ASSERT(!part_info->bitmaps_are_initialized);
/* Allocate for both read and lock_partitions */ /* Allocate for both read and lock_partitions */
if (!(bitmap_buf= (uint32*) alloc_root(&part_info->table->mem_root, if (unlikely(!(bitmap_buf=
bitmap_bytes * 2))) (uint32*) alloc_root(&part_info->table->mem_root,
{ bitmap_bytes * 2))))
mem_alloc_error(bitmap_bytes * 2);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
}
my_bitmap_init(&part_info->read_partitions, bitmap_buf, bitmap_bits, FALSE); my_bitmap_init(&part_info->read_partitions, bitmap_buf, bitmap_bits, FALSE);
/* Use the second half of the allocated buffer for lock_partitions */ /* Use the second half of the allocated buffer for lock_partitions */
my_bitmap_init(&part_info->lock_partitions, bitmap_buf + (bitmap_bytes / 4), my_bitmap_init(&part_info->lock_partitions, bitmap_buf + (bitmap_bytes / 4),
...@@ -1291,11 +1285,9 @@ static bool check_range_constants(THD *thd, partition_info *part_info) ...@@ -1291,11 +1285,9 @@ static bool check_range_constants(THD *thd, partition_info *part_info)
uint size_entries= sizeof(part_column_list_val) * num_column_values; uint size_entries= sizeof(part_column_list_val) * num_column_values;
part_info->range_col_array= (part_column_list_val*) part_info->range_col_array= (part_column_list_val*)
thd->calloc(part_info->num_parts * size_entries); thd->calloc(part_info->num_parts * size_entries);
if (part_info->range_col_array == NULL) if (unlikely(part_info->range_col_array == NULL))
{
mem_alloc_error(part_info->num_parts * size_entries);
goto end; goto end;
}
loc_range_col_array= part_info->range_col_array; loc_range_col_array= part_info->range_col_array;
i= 0; i= 0;
do do
...@@ -1329,11 +1321,9 @@ static bool check_range_constants(THD *thd, partition_info *part_info) ...@@ -1329,11 +1321,9 @@ static bool check_range_constants(THD *thd, partition_info *part_info)
part_info->range_int_array= (longlong*) part_info->range_int_array= (longlong*)
thd->alloc(part_info->num_parts * sizeof(longlong)); thd->alloc(part_info->num_parts * sizeof(longlong));
if (part_info->range_int_array == NULL) if (unlikely(part_info->range_int_array == NULL))
{
mem_alloc_error(part_info->num_parts * sizeof(longlong));
goto end; goto end;
}
i= 0; i= 0;
do do
{ {
...@@ -4455,26 +4445,24 @@ bool mysql_unpack_partition(THD *thd, ...@@ -4455,26 +4445,24 @@ bool mysql_unpack_partition(THD *thd,
thd->variables.character_set_client= system_charset_info; thd->variables.character_set_client= system_charset_info;
Parser_state parser_state; Parser_state parser_state;
if (parser_state.init(thd, part_buf, part_info_len)) if (unlikely(parser_state.init(thd, part_buf, part_info_len)))
goto end; goto end;
if (init_lex_with_single_table(thd, table, &lex)) if (unlikely(init_lex_with_single_table(thd, table, &lex)))
goto end; goto end;
*work_part_info_used= FALSE; *work_part_info_used= FALSE;
lex.part_info= new partition_info();
lex.part_info->table= table; /* Indicates MYSQLparse from this place */ if (unlikely(!(lex.part_info= new partition_info())))
if (!lex.part_info)
{
mem_alloc_error(sizeof(partition_info));
goto end; goto end;
}
lex.part_info->table= table; /* Indicates MYSQLparse from this place */
part_info= lex.part_info; part_info= lex.part_info;
DBUG_PRINT("info", ("Parse: %s", part_buf)); DBUG_PRINT("info", ("Parse: %s", part_buf));
thd->m_statement_psi= NULL; thd->m_statement_psi= NULL;
if (parse_sql(thd, & parser_state, NULL) || if (unlikely(parse_sql(thd, & parser_state, NULL)) ||
part_info->fix_parser_data(thd)) unlikely(part_info->fix_parser_data(thd)))
{ {
thd->free_items(); thd->free_items();
thd->m_statement_psi= parent_locker; thd->m_statement_psi= parent_locker;
...@@ -5328,23 +5316,19 @@ that are reorganised. ...@@ -5328,23 +5316,19 @@ that are reorganised.
partition_element *part_elem= alt_it++; partition_element *part_elem= alt_it++;
if (*fast_alter_table) if (*fast_alter_table)
part_elem->part_state= PART_TO_BE_ADDED; part_elem->part_state= PART_TO_BE_ADDED;
if (tab_part_info->partitions.push_back(part_elem, thd->mem_root)) if (unlikely(tab_part_info->partitions.push_back(part_elem,
{ thd->mem_root)))
mem_alloc_error(1);
goto err; goto err;
}
} while (++part_count < num_new_partitions); } while (++part_count < num_new_partitions);
tab_part_info->num_parts+= num_new_partitions; tab_part_info->num_parts+= num_new_partitions;
if (tab_part_info->part_type == VERSIONING_PARTITION) if (tab_part_info->part_type == VERSIONING_PARTITION)
{ {
DBUG_ASSERT(now_part); DBUG_ASSERT(now_part);
if (tab_part_info->partitions.push_back(now_part, thd->mem_root)) if (unlikely(tab_part_info->partitions.push_back(now_part,
{ thd->mem_root)))
mem_alloc_error(1);
goto err; goto err;
} }
} }
}
/* /*
If we specify partitions explicitly we don't use defaults anymore. If we specify partitions explicitly we don't use defaults anymore.
Using ADD PARTITION also means that we don't have the default number Using ADD PARTITION also means that we don't have the default number
...@@ -5675,12 +5659,10 @@ the generated partition syntax in a correct manner. ...@@ -5675,12 +5659,10 @@ the generated partition syntax in a correct manner.
else else
tab_max_range= part_elem->range_value; tab_max_range= part_elem->range_value;
if (*fast_alter_table && if (*fast_alter_table &&
tab_part_info->temp_partitions.push_back(part_elem, unlikely(tab_part_info->temp_partitions.
thd->mem_root)) push_back(part_elem, thd->mem_root)))
{
mem_alloc_error(1);
goto err; goto err;
}
if (*fast_alter_table) if (*fast_alter_table)
part_elem->part_state= PART_TO_BE_REORGED; part_elem->part_state= PART_TO_BE_REORGED;
if (!found_first) if (!found_first)
...@@ -7541,27 +7523,6 @@ void append_row_to_str(String &str, const uchar *row, TABLE *table) ...@@ -7541,27 +7523,6 @@ void append_row_to_str(String &str, const uchar *row, TABLE *table)
} }
/*
SYNOPSIS
mem_alloc_error()
size Size of memory attempted to allocate
None
RETURN VALUES
None
DESCRIPTION
A routine to use for all the many places in the code where memory
allocation error can happen, a tremendous amount of them, needs
simple routine that signals this error.
*/
void mem_alloc_error(size_t size)
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR),
static_cast<int>(size));
}
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
/** /**
Return comma-separated list of used partitions in the provided given string. Return comma-separated list of used partitions in the provided given string.
......
...@@ -133,7 +133,6 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs); ...@@ -133,7 +133,6 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs);
@param[in] table Table containing read_set and fields for the row. @param[in] table Table containing read_set and fields for the row.
*/ */
void append_row_to_str(String &str, const uchar *row, TABLE *table); void append_row_to_str(String &str, const uchar *row, TABLE *table);
void mem_alloc_error(size_t size);
void truncate_partition_filename(char *path); void truncate_partition_filename(char *path);
/* /*
......
...@@ -342,10 +342,7 @@ static bool exchange_name_with_ddl_log(THD *thd, ...@@ -342,10 +342,7 @@ static bool exchange_name_with_ddl_log(THD *thd,
DBUG_ENTER("exchange_name_with_ddl_log"); DBUG_ENTER("exchange_name_with_ddl_log");
if (unlikely(!(file= get_new_handler(NULL, thd->mem_root, ht)))) if (unlikely(!(file= get_new_handler(NULL, thd->mem_root, ht))))
{
mem_alloc_error(sizeof(handler));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
}
/* prepare the action entry */ /* prepare the action entry */
exchange_entry.entry_type= DDL_LOG_ENTRY_CODE; exchange_entry.entry_type= DDL_LOG_ENTRY_CODE;
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#include "lock.h" // mysql_unlock_tables #include "lock.h" // mysql_unlock_tables
#include "strfunc.h" // find_type2, find_set #include "strfunc.h" // find_type2, find_set
#include "sql_truncate.h" // regenerate_locked_table #include "sql_truncate.h" // regenerate_locked_table
#include "sql_partition.h" // mem_alloc_error, #include "sql_partition.h" // generate_partition_syntax,
// generate_partition_syntax,
// partition_info // partition_info
// NOT_A_PARTITION_ID // NOT_A_PARTITION_ID
#include "sql_db.h" // load_db_opt_by_name #include "sql_db.h" // load_db_opt_by_name
...@@ -1146,12 +1145,9 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) ...@@ -1146,12 +1145,9 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
} }
hton= plugin_data(plugin, handlerton*); hton= plugin_data(plugin, handlerton*);
file= get_new_handler((TABLE_SHARE*)0, &mem_root, hton); file= get_new_handler((TABLE_SHARE*)0, &mem_root, hton);
if (!file) if (unlikely(!file))
{
mem_alloc_error(sizeof(handler));
goto error; goto error;
} }
}
switch (ddl_log_entry->action_type) switch (ddl_log_entry->action_type)
{ {
case DDL_LOG_REPLACE_ACTION: case DDL_LOG_REPLACE_ACTION:
...@@ -4492,12 +4488,10 @@ handler *mysql_create_frm_image(THD *thd, ...@@ -4492,12 +4488,10 @@ handler *mysql_create_frm_image(THD *thd,
db_options= create_info->table_options_with_row_type(); db_options= create_info->table_options_with_row_type();
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, if (unlikely(!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root,
create_info->db_type))) create_info->db_type))))
{
mem_alloc_error(sizeof(handler));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
}
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
partition_info *part_info= thd->work_part_info; partition_info *part_info= thd->work_part_info;
...@@ -4510,11 +4504,9 @@ handler *mysql_create_frm_image(THD *thd, ...@@ -4510,11 +4504,9 @@ handler *mysql_create_frm_image(THD *thd,
object with the default settings. object with the default settings.
*/ */
thd->work_part_info= part_info= new partition_info(); thd->work_part_info= part_info= new partition_info();
if (!part_info) if (unlikely(!part_info))
{
mem_alloc_error(sizeof(partition_info));
goto err; goto err;
}
file->set_auto_partitions(part_info); file->set_auto_partitions(part_info);
part_info->default_engine_type= create_info->db_type; part_info->default_engine_type= create_info->db_type;
part_info->is_auto_partitioned= TRUE; part_info->is_auto_partitioned= TRUE;
...@@ -4685,14 +4677,11 @@ handler *mysql_create_frm_image(THD *thd, ...@@ -4685,14 +4677,11 @@ handler *mysql_create_frm_image(THD *thd,
engines in partition clauses. engines in partition clauses.
*/ */
delete file; delete file;
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, if (unlikely(!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root,
engine_type))) engine_type))))
{
mem_alloc_error(sizeof(handler));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
} }
}
/* /*
Unless table's storage engine supports partitioning natively Unless table's storage engine supports partitioning natively
don't allow foreign keys on partitioned tables (they won't don't allow foreign keys on partitioned tables (they won't
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "sql_priv.h" #include "sql_priv.h"
#include "sql_parse.h" /* comp_*_creator */ #include "sql_parse.h" /* comp_*_creator */
#include "sql_table.h" /* primary_key_name */ #include "sql_table.h" /* primary_key_name */
#include "sql_partition.h" /* mem_alloc_error, partition_info, HASH_PARTITION */ #include "sql_partition.h" /* partition_info, HASH_PARTITION */
#include "sql_acl.h" /* *_ACL */ #include "sql_acl.h" /* *_ACL */
#include "sql_class.h" /* Key_part_spec, enum_filetype, Diag_condition_item_name */ #include "sql_class.h" /* Key_part_spec, enum_filetype, Diag_condition_item_name */
#include "slave.h" #include "slave.h"
...@@ -764,11 +764,8 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin) ...@@ -764,11 +764,8 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin)
Virtual_column_info *add_virtual_expression(THD *thd, Item *expr) Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
{ {
Virtual_column_info *v= new (thd->mem_root) Virtual_column_info(); Virtual_column_info *v= new (thd->mem_root) Virtual_column_info();
if (!v) if (unlikely(!v))
{
mem_alloc_error(sizeof(Virtual_column_info));
return 0; return 0;
}
v->expr= expr; v->expr= expr;
v->utf8= 0; /* connection charset */ v->utf8= 0; /* connection charset */
return v; return v;
...@@ -5316,7 +5313,7 @@ part_field_item: ...@@ -5316,7 +5313,7 @@ part_field_item:
if (unlikely(part_info->part_field_list.push_back($1.str, if (unlikely(part_info->part_field_list.push_back($1.str,
thd->mem_root))) thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
if (part_info->num_columns > MAX_REF_PARTS) if (unlikely(part_info->num_columns > MAX_REF_PARTS))
my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0),
"list of partition fields")); "list of partition fields"));
} }
...@@ -5393,6 +5390,7 @@ sub_part_field_item: ...@@ -5393,6 +5390,7 @@ sub_part_field_item:
if (unlikely(part_info->subpart_field_list.push_back($1.str, if (unlikely(part_info->subpart_field_list.push_back($1.str,
thd->mem_root))) thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
if (unlikely(part_info->subpart_field_list.elements > MAX_REF_PARTS)) if (unlikely(part_info->subpart_field_list.elements > MAX_REF_PARTS))
my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0),
"list of subpartition fields")); "list of subpartition fields"));
...@@ -5470,6 +5468,7 @@ part_definition: ...@@ -5470,6 +5468,7 @@ part_definition:
if (unlikely(!p_elem) || if (unlikely(!p_elem) ||
unlikely(part_info->partitions.push_back(p_elem, thd->mem_root))) unlikely(part_info->partitions.push_back(p_elem, thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
p_elem->part_state= PART_NORMAL; p_elem->part_state= PART_NORMAL;
p_elem->id= part_info->partitions.elements - 1; p_elem->id= part_info->partitions.elements - 1;
part_info->curr_part_elem= p_elem; part_info->curr_part_elem= p_elem;
...@@ -5819,6 +5818,7 @@ sub_part_definition: ...@@ -5819,6 +5818,7 @@ sub_part_definition:
if (unlikely(!sub_p_elem) || if (unlikely(!sub_p_elem) ||
unlikely(curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root))) unlikely(curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
sub_p_elem->id= curr_part->subpartitions.elements - 1; sub_p_elem->id= curr_part->subpartitions.elements - 1;
part_info->curr_part_elem= sub_p_elem; part_info->curr_part_elem= sub_p_elem;
part_info->use_default_subpartitions= FALSE; part_info->use_default_subpartitions= FALSE;
...@@ -8049,6 +8049,7 @@ add_partition_rule: ...@@ -8049,6 +8049,7 @@ add_partition_rule:
lex->part_info= new (thd->mem_root) partition_info(); lex->part_info= new (thd->mem_root) partition_info();
if (unlikely(!lex->part_info)) if (unlikely(!lex->part_info))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->alter_info.partition_flags|= ALTER_PARTITION_ADD; lex->alter_info.partition_flags|= ALTER_PARTITION_ADD;
DBUG_ASSERT(!Lex->create_info.if_not_exists()); DBUG_ASSERT(!Lex->create_info.if_not_exists());
lex->create_info.set($3); lex->create_info.set($3);
...@@ -8078,6 +8079,7 @@ reorg_partition_rule: ...@@ -8078,6 +8079,7 @@ reorg_partition_rule:
lex->part_info= new (thd->mem_root) partition_info(); lex->part_info= new (thd->mem_root) partition_info();
if (unlikely(!lex->part_info)) if (unlikely(!lex->part_info))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->no_write_to_binlog= $3; lex->no_write_to_binlog= $3;
} }
reorg_parts_rule reorg_parts_rule
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "sql_priv.h" #include "sql_priv.h"
#include "sql_parse.h" /* comp_*_creator */ #include "sql_parse.h" /* comp_*_creator */
#include "sql_table.h" /* primary_key_name */ #include "sql_table.h" /* primary_key_name */
#include "sql_partition.h" /* mem_alloc_error, partition_info, HASH_PARTITION */ #include "sql_partition.h" /* partition_info, HASH_PARTITION */
#include "sql_acl.h" /* *_ACL */ #include "sql_acl.h" /* *_ACL */
#include "sql_class.h" /* Key_part_spec, enum_filetype, Diag_condition_item_name */ #include "sql_class.h" /* Key_part_spec, enum_filetype, Diag_condition_item_name */
#include "slave.h" #include "slave.h"
...@@ -5135,10 +5135,8 @@ partitioning: ...@@ -5135,10 +5135,8 @@ partitioning:
LEX *lex= Lex; LEX *lex= Lex;
lex->part_info= new (thd->mem_root) partition_info(); lex->part_info= new (thd->mem_root) partition_info();
if (unlikely(!lex->part_info)) if (unlikely(!lex->part_info))
{
mem_alloc_error(sizeof(partition_info));
MYSQL_YYABORT; MYSQL_YYABORT;
}
if (lex->sql_command == SQLCOM_ALTER_TABLE) if (lex->sql_command == SQLCOM_ALTER_TABLE)
{ {
lex->alter_info.partition_flags|= ALTER_PARTITION_INFO; lex->alter_info.partition_flags|= ALTER_PARTITION_INFO;
...@@ -5255,10 +5253,8 @@ part_field_item: ...@@ -5255,10 +5253,8 @@ part_field_item:
part_info->num_columns++; part_info->num_columns++;
if (unlikely(part_info->part_field_list.push_back($1.str, if (unlikely(part_info->part_field_list.push_back($1.str,
thd->mem_root))) thd->mem_root)))
{
mem_alloc_error(1);
MYSQL_YYABORT; MYSQL_YYABORT;
}
if (unlikely(part_info->num_columns > MAX_REF_PARTS)) if (unlikely(part_info->num_columns > MAX_REF_PARTS))
my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0),
"list of partition fields")); "list of partition fields"));
...@@ -5335,10 +5331,8 @@ sub_part_field_item: ...@@ -5335,10 +5331,8 @@ sub_part_field_item:
partition_info *part_info= Lex->part_info; partition_info *part_info= Lex->part_info;
if (unlikely(part_info->subpart_field_list.push_back($1.str, if (unlikely(part_info->subpart_field_list.push_back($1.str,
thd->mem_root))) thd->mem_root)))
{
mem_alloc_error(1);
MYSQL_YYABORT; MYSQL_YYABORT;
}
if (unlikely(part_info->subpart_field_list.elements > MAX_REF_PARTS)) if (unlikely(part_info->subpart_field_list.elements > MAX_REF_PARTS))
my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0),
"list of subpartition fields")); "list of subpartition fields"));
...@@ -5713,10 +5707,8 @@ sub_part_definition: ...@@ -5713,10 +5707,8 @@ sub_part_definition:
} }
if (unlikely(!sub_p_elem) || if (unlikely(!sub_p_elem) ||
unlikely(curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root))) unlikely(curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root)))
{
mem_alloc_error(sizeof(partition_element));
MYSQL_YYABORT; MYSQL_YYABORT;
}
part_info->curr_part_elem= sub_p_elem; part_info->curr_part_elem= sub_p_elem;
part_info->use_default_subpartitions= FALSE; part_info->use_default_subpartitions= FALSE;
part_info->use_default_num_subpartitions= FALSE; part_info->use_default_num_subpartitions= FALSE;
...@@ -7923,6 +7915,7 @@ reorg_partition_rule: ...@@ -7923,6 +7915,7 @@ reorg_partition_rule:
lex->part_info= new (thd->mem_root) partition_info(); lex->part_info= new (thd->mem_root) partition_info();
if (unlikely(!lex->part_info)) if (unlikely(!lex->part_info))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->no_write_to_binlog= $3; lex->no_write_to_binlog= $3;
} }
reorg_parts_rule reorg_parts_rule
......
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