summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2015-08-27 10:07:32 +0300
committerMonty <monty@mariadb.org>2015-08-27 22:29:11 +0300
commit3bca8db4f90cd9a505b99009c44594c0fb1ec353 (patch)
treea96ef13450eeb6a9b420e592534044b44872f97e
parent3cb578c001b2feabd2410f281d20eb6566371453 (diff)
downloadmariadb-git-3bca8db4f90cd9a505b99009c44594c0fb1ec353.tar.gz
MDEV-6152: Remove calls to current_thd while creating Item
- Part 4: Removing calls to sql_alloc() and sql_calloc() Other things: - Added current_thd in some places to make it clear that it's called (easier to remove later) - Move memory allocation from Item_func_case::fix_length_and_dec() to Item_func_case::fix_fields() - Added mem_root to some new calls - Fixed some wrong UNINIT_VAR() calls - Fixed a bug in generate_partition_syntax() in case of errors - Added mem_root to argument to new thread_info - Simplified my_parse_error() call in sql_yacc.yy
-rw-r--r--include/my_global.h7
-rw-r--r--sql/ha_partition.cc9
-rw-r--r--sql/item.cc30
-rw-r--r--sql/item.h14
-rw-r--r--sql/item_cmpfunc.cc56
-rw-r--r--sql/item_cmpfunc.h7
-rw-r--r--sql/item_func.cc25
-rw-r--r--sql/item_func.h6
-rw-r--r--sql/item_row.h2
-rw-r--r--sql/item_sum.cc6
-rw-r--r--sql/opt_subselect.h13
-rw-r--r--sql/partition_info.cc29
-rw-r--r--sql/partition_info.h2
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_join_cache.cc6
-rw-r--r--sql/sql_partition.cc5
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_yacc.yy300
-rw-r--r--sql/unireg.cc12
22 files changed, 296 insertions, 253 deletions
diff --git a/include/my_global.h b/include/my_global.h
index e654d567d42..f7d8f795051 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -477,6 +477,13 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define UNINIT_VAR(x) x
#endif
+/* This is only to be used when reseting variables in a class constructor */
+#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
+#define LINT_INIT(x) x= 0
+#else
+#define LINT_INIT(x)
+#endif
+
#if !defined(HAVE_UINT)
#undef HAVE_UINT
#define HAVE_UINT
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index ffe35392989..f85cdc73650 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1693,8 +1693,8 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
} while (++i < num_parts);
}
if (m_reorged_parts &&
- !(m_reorged_file= (handler**)sql_calloc(sizeof(handler*)*
- (m_reorged_parts + 1))))
+ !(m_reorged_file= (handler**) thd->calloc(sizeof(handler*)*
+ (m_reorged_parts + 1))))
{
mem_alloc_error(sizeof(handler*)*(m_reorged_parts+1));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -1725,8 +1725,9 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
}
} while (++i < num_parts);
}
- if (!(new_file_array= (handler**)sql_calloc(sizeof(handler*)*
- (2*(num_remain_partitions + 1)))))
+ if (!(new_file_array= ((handler**)
+ thd->calloc(sizeof(handler*)*
+ (2*(num_remain_partitions + 1))))))
{
mem_alloc_error(sizeof(handler*)*2*(num_remain_partitions+1));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
diff --git a/sql/item.cc b/sql/item.cc
index 6e3707726d0..c624ebfef73 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2397,18 +2397,21 @@ const char *Item_ident::full_name() const
char *tmp;
if (!table_name || !field_name)
return field_name ? field_name : name ? name : "tmp_field";
+
if (db_name && db_name[0])
{
- tmp=(char*) sql_alloc((uint) strlen(db_name)+(uint) strlen(table_name)+
- (uint) strlen(field_name)+3);
+ THD *thd= current_thd;
+ tmp=(char*) thd->alloc((uint) strlen(db_name)+(uint) strlen(table_name)+
+ (uint) strlen(field_name)+3);
strxmov(tmp,db_name,".",table_name,".",field_name,NullS);
}
else
{
if (table_name[0])
{
- tmp= (char*) sql_alloc((uint) strlen(table_name) +
- (uint) strlen(field_name) + 2);
+ THD *thd= current_thd;
+ tmp= (char*) thd->alloc((uint) strlen(table_name) +
+ (uint) strlen(field_name) + 2);
strxmov(tmp, table_name, ".", field_name, NullS);
}
else
@@ -6276,10 +6279,11 @@ inline uint char_val(char X)
}
-void Item_hex_constant::hex_string_init(const char *str, uint str_length)
+void Item_hex_constant::hex_string_init(THD *thd, const char *str,
+ uint str_length)
{
max_length=(str_length+1)/2;
- char *ptr=(char*) sql_alloc(max_length+1);
+ char *ptr=(char*) thd->alloc(max_length+1);
if (!ptr)
{
str_value.set("", 0, &my_charset_bin);
@@ -6372,12 +6376,12 @@ Item_bin_string::Item_bin_string(THD *thd, const char *str, uint str_length):
Item_hex_hybrid(thd)
{
const char *end= str + str_length - 1;
+ char *ptr;
uchar bits= 0;
uint power= 1;
max_length= (str_length + 7) >> 3;
- char *ptr= (char*) sql_alloc(max_length + 1);
- if (!ptr)
+ if (!(ptr= (char*) thd->alloc(max_length + 1)))
return;
str_value.set(ptr, max_length, &my_charset_bin);
@@ -8260,9 +8264,10 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->field_name);
goto error;
}
- if (!(def_field= (Field*) sql_alloc(field_arg->field->size_of())))
+ if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of())))
goto error;
- memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of());
+ memcpy((void *)def_field, (void *)field_arg->field,
+ field_arg->field->size_of());
def_field->move_field_offset((my_ptrdiff_t)
(def_field->table->s->default_values -
def_field->table->record[0]));
@@ -8402,10 +8407,11 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
if (field_arg->field->table->insert_values)
{
- Field *def_field= (Field*) sql_alloc(field_arg->field->size_of());
+ Field *def_field= (Field*) thd->alloc(field_arg->field->size_of());
if (!def_field)
return TRUE;
- memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of());
+ memcpy((void *)def_field, (void *)field_arg->field,
+ field_arg->field->size_of());
def_field->move_field_offset((my_ptrdiff_t)
(def_field->table->insert_values -
def_field->table->record[0]));
diff --git a/sql/item.h b/sql/item.h
index f5fdb454e52..86dcd7abdbb 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -3172,16 +3172,16 @@ public:
class Item_hex_constant: public Item_basic_constant
{
private:
- void hex_string_init(const char *str, uint str_length);
+ void hex_string_init(THD *thd, const char *str, uint str_length);
public:
Item_hex_constant(THD *thd): Item_basic_constant(thd)
{
- hex_string_init("", 0);
+ hex_string_init(thd, "", 0);
}
Item_hex_constant(THD *thd, const char *str, uint str_length):
Item_basic_constant(thd)
{
- hex_string_init(str, str_length);
+ hex_string_init(thd, str, str_length);
}
enum Type type() const { return VARBIN_ITEM; }
enum Item_result result_type () const { return STRING_RESULT; }
@@ -3409,7 +3409,7 @@ class Item_args
{
protected:
Item **args, *tmp_arg[2];
- void set_arguments(List<Item> &list);
+ void set_arguments(THD *thd, List<Item> &list);
bool walk_args(Item_processor processor, bool walk_subquery, uchar *arg)
{
for (uint i= 0; i < arg_count; i++)
@@ -3463,9 +3463,9 @@ public:
args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
}
}
- Item_args(List<Item> &list)
+ Item_args(THD *thd, List<Item> &list)
{
- set_arguments(list);
+ set_arguments(thd, list);
}
Item_args(THD *thd, const Item_args *other);
inline Item **arguments() const { return args; }
@@ -3560,7 +3560,7 @@ public:
Item_func_or_sum(THD *thd, Item_func_or_sum *item):
Item_result_field(thd, item), Item_args(thd, item) { }
Item_func_or_sum(THD *thd, List<Item> &list):
- Item_result_field(thd), Item_args(list) { }
+ Item_result_field(thd), Item_args(thd, list) { }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
{
if (walk_args(processor, walk_subquery, arg))
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bc36b121b73..c1c12471a15 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2790,7 +2790,7 @@ Item_func_case::Item_func_case(THD *thd, List<Item> &list,
else_expr_num= list.elements;
list.push_back(else_expr_arg, thd->mem_root);
}
- set_arguments(list);
+ set_arguments(thd, list);
bzero(&cmp_items, sizeof(cmp_items));
}
@@ -2949,6 +2949,10 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
Item_func_case::val_int() -> Item_func_case::find_item()
*/
uchar buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2];
+
+ if (!(arg_buffer= (Item**) thd->alloc(sizeof(Item*)*(ncases+1))))
+ return TRUE;
+
bool res= Item_func::fix_fields(thd, ref);
/*
Call check_stack_overrun after fix_fields to be sure that stack variable
@@ -3002,14 +3006,11 @@ static void change_item_tree_if_needed(THD *thd,
void Item_func_case::fix_length_and_dec()
{
- Item **agg;
+ Item **agg= arg_buffer;
uint nagg;
uint found_types= 0;
THD *thd= current_thd;
- if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
- return;
-
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
maybe_null= 1;
@@ -3052,8 +3053,9 @@ void Item_func_case::fix_length_and_dec()
if (else_expr_num != -1)
agg_num_lengths(args[else_expr_num]);
max_length= my_decimal_precision_to_length_no_truncation(max_length +
- decimals, decimals,
- unsigned_flag);
+ decimals,
+ decimals,
+ unsigned_flag);
}
/*
@@ -3501,9 +3503,9 @@ Item *in_string::create_item(THD *thd)
}
-in_row::in_row(uint elements, Item * item)
+in_row::in_row(THD *thd, uint elements, Item * item)
{
- base= (char*) new cmp_item_row[count= elements];
+ base= (char*) new (thd->mem_root) cmp_item_row[count= elements];
size= sizeof(cmp_item_row);
compare= (qsort2_cmp) cmp_row;
/*
@@ -3532,7 +3534,7 @@ void in_row::set(uint pos, Item *item)
{
DBUG_ENTER("in_row::set");
DBUG_PRINT("enter", ("pos: %u item: 0x%lx", pos, (ulong) item));
- ((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item);
+ ((cmp_item_row*) base)[pos].store_value_by_template(current_thd, &tmp, item);
DBUG_VOID_RETURN;
}
@@ -3745,7 +3747,7 @@ void cmp_item_row::store_value(Item *item)
}
-void cmp_item_row::store_value_by_template(cmp_item *t, Item *item)
+void cmp_item_row::store_value_by_template(THD *thd, cmp_item *t, Item *item)
{
cmp_item_row *tmpl= (cmp_item_row*) t;
if (tmpl->n != item->cols())
@@ -3754,7 +3756,7 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item)
return;
}
n= tmpl->n;
- if ((comparators= (cmp_item **) sql_alloc(sizeof(cmp_item *)*n)))
+ if ((comparators= (cmp_item **) thd->alloc(sizeof(cmp_item *)*n)))
{
item->bring_value();
item->null_value= 0;
@@ -3762,7 +3764,7 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item)
{
if (!(comparators[i]= tmpl->comparators[i]->make_same()))
break; // new failed
- comparators[i]->store_value_by_template(tmpl->comparators[i],
+ comparators[i]->store_value_by_template(thd, tmpl->comparators[i],
item->element_index(i));
item->null_value|= item->element_index(i)->null_value;
}
@@ -4006,12 +4008,12 @@ void Item_func_in::fix_length_and_dec()
if (const_itm && !nulls_in_row())
{
- array= new in_row(arg_count-1, 0);
+ array= new (thd->mem_root) in_row(thd, arg_count-1, 0);
cmp= &((in_row*)array)->tmp;
}
else
{
- if (!(cmp= new cmp_item_row))
+ if (!(cmp= new (thd->mem_root) cmp_item_row))
return;
cmp_items[ROW_RESULT]= cmp;
}
@@ -4028,7 +4030,7 @@ void Item_func_in::fix_length_and_dec()
cmp= ((in_row*)array)->tmp.comparators + col;
else
cmp= ((cmp_item_row*)cmp_items[ROW_RESULT])->comparators + col;
- *cmp= new cmp_item_datetime(date_arg);
+ *cmp= new (thd->mem_root) cmp_item_datetime(date_arg);
}
}
}
@@ -4067,14 +4069,14 @@ void Item_func_in::fix_length_and_dec()
}
switch (cmp_type) {
case STRING_RESULT:
- array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
- cmp_collation.collation);
+ array=new (thd->mem_root) in_string(arg_count-1,(qsort2_cmp) srtcmp_in,
+ cmp_collation.collation);
break;
case INT_RESULT:
- array= new in_longlong(arg_count-1);
+ array= new (thd->mem_root) in_longlong(arg_count-1);
break;
case REAL_RESULT:
- array= new in_double(arg_count-1);
+ array= new (thd->mem_root) in_double(arg_count-1);
break;
case ROW_RESULT:
/*
@@ -4085,11 +4087,11 @@ void Item_func_in::fix_length_and_dec()
((in_row*)array)->tmp.store_value(args[0]);
break;
case DECIMAL_RESULT:
- array= new in_decimal(arg_count - 1);
+ array= new (thd->mem_root) in_decimal(arg_count - 1);
break;
case TIME_RESULT:
date_arg= find_date_time_item(args, arg_count, 0);
- array= new in_datetime(date_arg, arg_count - 1);
+ array= new (thd->mem_root) in_datetime(date_arg, arg_count - 1);
break;
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
@@ -5063,16 +5065,18 @@ bool Item_func_like::find_selective_predicates_list_processor(uchar *arg)
(find_selective_predicates_list_processor_data *) arg;
if (use_sampling && used_tables() == data->table->map)
{
- COND_STATISTIC *stat= (COND_STATISTIC *)sql_alloc(sizeof(COND_STATISTIC));
- if (!stat)
+ THD *thd= data->table->in_use;
+ COND_STATISTIC *stat;
+ Item *arg0;
+ if (!(stat= (COND_STATISTIC *) thd->alloc(sizeof(COND_STATISTIC))))
return TRUE;
stat->cond= this;
- Item *arg0= args[0]->real_item();
+ arg0= args[0]->real_item();
if (args[1]->const_item() && arg0->type() == FIELD_ITEM)
stat->field_arg= ((Item_field *)arg0)->field;
else
stat->field_arg= NULL;
- data->list.push_back(stat);
+ data->list.push_back(stat, thd->mem_root);
}
return FALSE;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index ebb51d2ae30..d1a0c7295db 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1105,7 +1105,7 @@ public:
static cmp_item* get_comparator(Item_result type, Item * warn_item,
CHARSET_INFO *cs);
virtual cmp_item *make_same()= 0;
- virtual void store_value_by_template(cmp_item *tmpl, Item *item)
+ virtual void store_value_by_template(THD *thd, cmp_item *tmpl, Item *item)
{
store_value(item);
}
@@ -1300,6 +1300,7 @@ class Item_func_case :public Item_func_hybrid_field_type
DTCollation cmp_collation;
cmp_item *cmp_items[6]; /* For all result types */
cmp_item *case_item;
+ Item **arg_buffer;
public:
Item_func_case(THD *thd, List<Item> &list, Item *first_expr_arg,
Item *else_expr_arg);
@@ -1405,7 +1406,7 @@ public:
int cmp(Item *arg);
int compare(cmp_item *arg);
cmp_item *make_same();
- void store_value_by_template(cmp_item *tmpl, Item *);
+ void store_value_by_template(THD *thd, cmp_item *tmpl, Item *);
friend void Item_func_in::fix_length_and_dec();
};
@@ -1414,7 +1415,7 @@ class in_row :public in_vector
{
cmp_item_row tmp;
public:
- in_row(uint elements, Item *);
+ in_row(THD *thd, uint elements, Item *);
~in_row();
void set(uint pos,Item *item);
uchar *get_value(Item *item);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 504f2c1dec5..78a6f914e5b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -89,14 +89,14 @@ static inline bool test_if_sum_overflows_ull(ulonglong arg1, ulonglong arg2)
}
-void Item_args::set_arguments(List<Item> &list)
+void Item_args::set_arguments(THD *thd, List<Item> &list)
{
arg_count= list.elements;
if (arg_count <= 2)
{
args= tmp_arg;
}
- else if (!(args= (Item**) sql_alloc(sizeof(Item*) * arg_count)))
+ else if (!(args= (Item**) thd->alloc(sizeof(Item*) * arg_count)))
{
arg_count= 0;
return;
@@ -3501,7 +3501,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
if ((f_args.arg_count=arg_count))
{
if (!(f_args.arg_type= (Item_result*)
- sql_alloc(f_args.arg_count*sizeof(Item_result))))
+ thd->alloc(f_args.arg_count*sizeof(Item_result))))
{
free_udf(u_d);
@@ -3543,13 +3543,14 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
}
//TODO: why all following memory is not allocated with 1 call of sql_alloc?
if (!(buffers=new String[arg_count]) ||
- !(f_args.args= (char**) sql_alloc(arg_count * sizeof(char *))) ||
- !(f_args.lengths= (ulong*) sql_alloc(arg_count * sizeof(long))) ||
- !(f_args.maybe_null= (char*) sql_alloc(arg_count * sizeof(char))) ||
- !(num_buffer= (char*) sql_alloc(arg_count *
+ !(f_args.args= (char**) thd->alloc(arg_count * sizeof(char *))) ||
+ !(f_args.lengths= (ulong*) thd->alloc(arg_count * sizeof(long))) ||
+ !(f_args.maybe_null= (char*) thd->alloc(arg_count * sizeof(char))) ||
+ !(num_buffer= (char*) thd->alloc(arg_count *
ALIGN_SIZE(sizeof(double)))) ||
- !(f_args.attributes= (char**) sql_alloc(arg_count * sizeof(char *))) ||
- !(f_args.attribute_lengths= (ulong*) sql_alloc(arg_count *
+ !(f_args.attributes= (char**) thd->alloc(arg_count *
+ sizeof(char *))) ||
+ !(f_args.attribute_lengths= (ulong*) thd->alloc(arg_count *
sizeof(long))))
{
free_udf(u_d);
@@ -6507,7 +6508,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
{
maybe_null= 1;
m_name->init_qname(current_thd);
- dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
+ dummy_table= (TABLE*) thd->calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
dummy_table->s= (TABLE_SHARE*) (dummy_table+1);
}
@@ -6519,7 +6520,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg,
{
maybe_null= 1;
m_name->init_qname(current_thd);
- dummy_table= (TABLE*) sql_calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
+ dummy_table= (TABLE*) thd->calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE));
dummy_table->s= (TABLE_SHARE*) (dummy_table+1);
}
@@ -6631,7 +6632,7 @@ Item_func_sp::init_result_field(THD *thd)
if (sp_result_field->pack_length() > sizeof(result_buf))
{
void *tmp;
- if (!(tmp= sql_alloc(sp_result_field->pack_length())))
+ if (!(tmp= thd->alloc(sp_result_field->pack_length())))
DBUG_RETURN(TRUE);
sp_result_field->move_field((uchar*) tmp);
}
diff --git a/sql/item_func.h b/sql/item_func.h
index b9e431377b1..676b818baf8 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -103,7 +103,7 @@ public:
Item_func(THD *thd, List<Item> &list):
Item_func_or_sum(thd, list), allowed_arg_cols(1)
{
- set_arguments(list);
+ set_arguments(thd, list);
}
// Constructor used for Item_cond_and/or (see Item comment)
Item_func(THD *thd, Item_func *item)
@@ -134,10 +134,10 @@ public:
bool eq(const Item *item, bool binary_cmp) const;
virtual Item *key_item() const { return args[0]; }
virtual bool const_item() const { return const_item_cache; }
- void set_arguments(List<Item> &list)
+ void set_arguments(THD *thd, List<Item> &list)
{
allowed_arg_cols= 1;
- Item_args::set_arguments(list);
+ Item_args::set_arguments(thd, list);
sync_with_sum_func_and_with_field(list);
list.empty(); // Fields are used
}
diff --git a/sql/item_row.h b/sql/item_row.h
index 0de547be327..cf55eddc19c 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -36,7 +36,7 @@ class Item_row: public Item,
bool with_null;
public:
Item_row(THD *thd, List<Item> &list):
- Item(thd), Item_args(list), not_null_tables_cache(0), with_null(0)
+ Item(thd), Item_args(thd, list), not_null_tables_cache(0), with_null(0)
{ }
Item_row(THD *thd, Item_row *item):
Item(thd),
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 0eff2b6cec9..b67986f0fb0 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -404,7 +404,7 @@ bool Item_sum::collect_outer_ref_processor(uchar *param)
Item_sum::Item_sum(THD *thd, List<Item> &list): Item_func_or_sum(thd, list),
forced_const(FALSE)
{
- if (!(orig_args= (Item **) sql_alloc(sizeof(Item *) * arg_count)))
+ if (!(orig_args= (Item **) thd->alloc(sizeof(Item *) * arg_count)))
{
args= NULL;
}
@@ -3197,8 +3197,8 @@ Item_func_group_concat(THD *thd, Name_resolution_context *context_arg,
(for possible order items in temporary tables)
order - arg_count_order
*/
- if (!(args= (Item**) sql_alloc(sizeof(Item*) * arg_count * 2 +
- sizeof(ORDER*)*arg_count_order)))
+ if (!(args= (Item**) thd->alloc(sizeof(Item*) * arg_count * 2 +
+ sizeof(ORDER*)*arg_count_order)))
return;
order= (ORDER**)(args + arg_count);
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index 3da94d05521..a2f6b644bf2 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -95,12 +95,13 @@ public:
bound_sj_equalities(0),
quick_uses_applicable_index(FALSE)
{
- UNINIT_VAR(quick_max_loose_keypart); /* Protected by quick_uses_applicable_index */
+ /* Protected by quick_uses_applicable_index */
+ LINT_INIT(quick_max_loose_keypart);
/* The following are protected by best_loose_scan_cost!= DBL_MAX */
- UNINIT_VAR(best_loose_scan_key);
- UNINIT_VAR(best_loose_scan_records);
- UNINIT_VAR(best_max_loose_keypart);
- UNINIT_VAR(best_loose_scan_start_key);
+ LINT_INIT(best_loose_scan_key);
+ LINT_INIT(best_loose_scan_records);
+ LINT_INIT(best_max_loose_keypart);
+ LINT_INIT(best_loose_scan_start_key);
}
void init(JOIN *join, JOIN_TAB *s, table_map remaining_tables)
@@ -122,7 +123,7 @@ public:
s->emb_sj_nest->sj_in_exprs < 64 &&
((remaining_tables & s->emb_sj_nest->sj_inner_tables) == // (2)
s->emb_sj_nest->sj_inner_tables) && // (2)
- join->cur_sj_inner_tables == 0 && // (3)
+ join->cur_sj_inner_tables == 0 && // (3)
!(remaining_tables &
s->emb_sj_nest->nested_join->sj_corr_tables) && // (4)
remaining_tables & s->emb_sj_nest->nested_join->sj_depends_on &&// (5)
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 5bd2471d757..f16ed0e879e 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1222,8 +1222,8 @@ bool partition_info::check_range_constants(THD *thd)
part_column_list_val *UNINIT_VAR(current_largest_col_val);
uint num_column_values= part_field_list.elements;
uint size_entries= sizeof(part_column_list_val) * num_column_values;
- range_col_array= (part_column_list_val*)sql_calloc(num_parts *
- size_entries);
+ range_col_array= (part_column_list_val*) thd->calloc(num_parts *
+ size_entries);
if (unlikely(range_col_array == NULL))
{
mem_alloc_error(num_parts * size_entries);
@@ -1260,7 +1260,7 @@ bool partition_info::check_range_constants(THD *thd)
longlong part_range_value;
bool signed_flag= !part_expr->unsigned_flag;
- range_int_array= (longlong*)sql_alloc(num_parts * sizeof(longlong));
+ range_int_array= (longlong*) thd->alloc(num_parts * sizeof(longlong));
if (unlikely(range_int_array == NULL))
{
mem_alloc_error(num_parts * sizeof(longlong));
@@ -1474,7 +1474,7 @@ bool partition_info::check_list_constants(THD *thd)
size_entries= column_list ?
(num_column_values * sizeof(part_column_list_val)) :
sizeof(LIST_PART_ENTRY);
- ptr= sql_calloc((num_list_values+1) * size_entries);
+ ptr= thd->calloc((num_list_values+1) * size_entries);
if (unlikely(ptr == NULL))
{
mem_alloc_error(num_list_values * size_entries);
@@ -1972,7 +1972,7 @@ bool partition_info::check_partition_field_length()
the binary collation.
*/
-bool partition_info::set_up_charset_field_preps()
+bool partition_info::set_up_charset_field_preps(THD *thd)
{
Field *field, **ptr;
uchar **char_ptrs;
@@ -1998,14 +1998,14 @@ bool partition_info::set_up_charset_field_preps()
}
}
size= tot_part_fields * sizeof(char*);
- if (!(char_ptrs= (uchar**)sql_calloc(size)))
+ if (!(char_ptrs= (uchar**)thd->calloc(size)))
goto error;
part_field_buffers= char_ptrs;
- if (!(char_ptrs= (uchar**)sql_calloc(size)))
+ if (!(char_ptrs= (uchar**)thd->calloc(size)))
goto error;
restore_part_field_ptrs= char_ptrs;
size= (tot_part_fields + 1) * sizeof(Field*);
- if (!(char_ptrs= (uchar**)sql_alloc(size)))
+ if (!(char_ptrs= (uchar**)thd->alloc(size)))
goto error;
part_charset_field_array= (Field**)char_ptrs;
ptr= part_field_array;
@@ -2016,7 +2016,7 @@ bool partition_info::set_up_charset_field_preps()
{
uchar *field_buf;
size= field->pack_length();
- if (!(field_buf= (uchar*) sql_calloc(size)))
+ if (!(field_buf= (uchar*) thd->calloc(size)))
goto error;
part_charset_field_array[i]= field;
part_field_buffers[i++]= field_buf;
@@ -2038,14 +2038,14 @@ bool partition_info::set_up_charset_field_preps()
}
}
size= tot_subpart_fields * sizeof(char*);
- if (!(char_ptrs= (uchar**) sql_calloc(size)))
+ if (!(char_ptrs= (uchar**) thd->calloc(size)))
goto error;
subpart_field_buffers= char_ptrs;
- if (!(char_ptrs= (uchar**) sql_calloc(size)))
+ if (!(char_ptrs= (uchar**) thd->calloc(size)))
goto error;
restore_subpart_field_ptrs= char_ptrs;
size= (tot_subpart_fields + 1) * sizeof(Field*);
- if (!(char_ptrs= (uchar**) sql_alloc(size)))
+ if (!(char_ptrs= (uchar**) thd->alloc(size)))
goto error;
subpart_charset_field_array= (Field**)char_ptrs;
ptr= subpart_field_array;
@@ -2057,7 +2057,7 @@ bool partition_info::set_up_charset_field_preps()
if (!field_is_partition_charset(field))
continue;
size= field->pack_length();
- if (!(field_buf= (uchar*) sql_calloc(size)))
+ if (!(field_buf= (uchar*) thd->calloc(size)))
goto error;
subpart_charset_field_array[i]= field;
subpart_field_buffers[i++]= field_buf;
@@ -2686,14 +2686,13 @@ bool partition_info::fix_column_value_functions(THD *thd,
}
thd->got_warning= save_got_warning;
thd->variables.sql_mode= save_sql_mode;
- if (!(val_ptr= (uchar*) sql_calloc(len)))
+ if (!(val_ptr= (uchar*) thd->memdup(field->ptr, len)))
{
mem_alloc_error(len);
result= TRUE;
goto end;
}
col_val->column_value= val_ptr;
- memcpy(val_ptr, field->ptr, len);
}
}
col_val->fixed= 2;
diff --git a/sql/partition_info.h b/sql/partition_info.h
index 8d423f6997a..df7010b2ab3 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -335,7 +335,7 @@ public:
bool set_part_expr(char *start_token, Item *item_ptr,
char *end_token, bool is_subpart);
static int compare_column_values(const void *a, const void *b);
- bool set_up_charset_field_preps();
+ bool set_up_charset_field_preps(THD *thd);
bool check_partition_field_length();
bool init_column_part(THD *thd);
bool add_column_list_value(THD *thd, Item *item);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 74cbc336896..2ba67cb1b00 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -1721,7 +1721,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
table_str.length= filename_to_tablename(file->name,
tname, sizeof(tname)-1);
- table_str.str= (char*) sql_memdup(tname, table_str.length + 1);
+ table_str.str= (char*) thd->memdup(tname, table_str.length + 1);
Table_ident *old_ident= new Table_ident(thd, *old_db, table_str, 0);
Table_ident *new_ident= new Table_ident(thd, new_db, table_str, 0);
if (!old_ident || !new_ident ||
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 813dd075738..8995684b8f6 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -906,7 +906,7 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, uint num_of_tables_arg)
num_of_tables(num_of_tables_arg), error(0),
do_delete(0), transactional_tables(0), normal_tables(0), error_handled(0)
{
- tempfiles= (Unique **) sql_calloc(sizeof(Unique *) * num_of_tables);
+ tempfiles= (Unique **) thd_arg->calloc(sizeof(Unique *) * num_of_tables);
}
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 46ef66bfd1b..731cc7267d5 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -328,8 +328,8 @@ int JOIN_CACHE::alloc_fields()
{
uint ptr_cnt= external_key_arg_fields+blobs+1;
uint fields_size= sizeof(CACHE_FIELD)*fields;
- field_descr= (CACHE_FIELD*) sql_alloc(fields_size +
- sizeof(CACHE_FIELD*)*ptr_cnt);
+ field_descr= (CACHE_FIELD*) join->thd->alloc(fields_size +
+ sizeof(CACHE_FIELD*)*ptr_cnt);
blob_ptr= (CACHE_FIELD **) ((uchar *) field_descr + fields_size);
return (field_descr == NULL);
}
@@ -2679,7 +2679,7 @@ int JOIN_CACHE_HASHED::init(bool for_explain)
if ((rc= JOIN_CACHE::init(for_explain)) || for_explain)
DBUG_RETURN (rc);
- if (!(key_buff= (uchar*) sql_alloc(key_length)))
+ if (!(key_buff= (uchar*) join->thd->alloc(key_length)))
DBUG_RETURN(1);
/* Take into account a reference to the next record in the key chain */
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 07de64d30bb..8e77d77205c 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1756,7 +1756,7 @@ bool fix_partition_func(THD *thd, TABLE *table,
goto end;
if (unlikely(set_up_partition_bitmaps(thd, part_info)))
goto end;
- if (unlikely(part_info->set_up_charset_field_preps()))
+ if (unlikely(part_info->set_up_charset_field_preps(thd)))
{
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
goto end;
@@ -2653,8 +2653,7 @@ char *generate_partition_syntax(partition_info *part_info,
{
if (!use_sql_alloc)
my_free(buf);
- else
- buf= NULL;
+ buf= NULL;
}
else
buf[*buf_length]= 0;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2a573b38f53..9d95bdfd617 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -22484,7 +22484,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
another extra byte to not get warnings from purify in
Field_string::val_int
*/
- if (!(tmp= (uchar*) sql_alloc(field->pack_length()+2)))
+ if (!(tmp= (uchar*) thd->alloc(field->pack_length()+2)))
goto err;
if (copy)
{
@@ -22739,7 +22739,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
new_field->update_null_value();
List<Item> list;
list.push_back(new_field, thd->mem_root);
- suv->set_arguments(list);
+ suv->set_arguments(thd, list);
item_field= suv;
}
else
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f33d8c5778e..6c400bcdd31 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2333,10 +2333,8 @@ static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
class thread_info :public ilink {
public:
- static void *operator new(size_t size)
- {
- return (void*) sql_alloc((uint) size);
- }
+ static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
+ { return alloc_root(mem_root, size); }
static void operator delete(void *ptr __attribute__((unused)),
size_t size __attribute__((unused)))
{ TRASH(ptr, size); }
@@ -2440,7 +2438,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
(!user || (!tmp->system_thread &&
tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
{
- thread_info *thd_info= new thread_info;
+ thread_info *thd_info= new (thd->mem_root) thread_info;
thd_info->thread_id=tmp->thread_id;
thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index fbd40d848a2..2ce4a08410d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3648,8 +3648,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(TRUE);
}
- (*key_info_buffer)= key_info= (KEY*) sql_calloc(sizeof(KEY) * (*key_count));
- key_part_info=(KEY_PART_INFO*) sql_calloc(sizeof(KEY_PART_INFO)*key_parts);
+ (*key_info_buffer)= key_info= (KEY*) thd->calloc(sizeof(KEY) * (*key_count));
+ key_part_info=(KEY_PART_INFO*) thd->calloc(sizeof(KEY_PART_INFO)*key_parts);
if (!*key_info_buffer || ! key_part_info)
DBUG_RETURN(TRUE); // Out of memory
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index eaf82df9004..b1f2cafaafd 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -96,7 +96,7 @@ int yylex(void *yylval, void *yythd);
#define MYSQL_YYABORT_UNLESS(A) \
if (!(A)) \
{ \
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));\
+ my_parse_error(thd, ER_SYNTAX_ERROR); \
MYSQL_YYABORT; \
}
@@ -140,25 +140,31 @@ int yylex(void *yylval, void *yythd);
parser.
*/
-void my_parse_error(const char *s, const char *yytext=0)
+static void my_parse_error_intern(THD *thd, const char *err_text,
+ const char *yytext)
{
- THD *thd= current_thd;
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
-
- if (!yytext)
- yytext= lip->get_tok_start();
+ Lex_input_stream *lip= &thd->m_parser_state->m_lip;
if (!yytext)
- yytext= "";
-
+ {
+ if (!(yytext= lip->get_tok_start()))
+ yytext= "";
+ }
/* Push an error into the error stack */
- ErrConvString err(yytext, strlen(yytext), thd->variables.character_set_client);
- my_printf_error(ER_PARSE_ERROR, ER_THD(thd, ER_PARSE_ERROR), MYF(0), s,
- err.ptr(), lip->yylineno);
+ ErrConvString err(yytext, strlen(yytext),
+ thd->variables.character_set_client);
+ my_printf_error(ER_PARSE_ERROR, ER_THD(thd, ER_PARSE_ERROR), MYF(0),
+ err_text, err.ptr(), lip->yylineno);
+}
+
+
+static void my_parse_error(THD *thd, uint err_number, const char *yytext=0)
+{
+ return my_parse_error_intern(thd, ER_THD(thd, err_number), yytext);
}
void LEX::parse_error()
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
}
@@ -194,7 +200,7 @@ void MYSQLerror(THD *thd, const char *s)
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
s= ER_THD(thd, ER_SYNTAX_ERROR);
- my_parse_error(s);
+ my_parse_error_intern(thd, s, 0);
}
@@ -646,11 +652,11 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal,
@param lex The parser state.
- @param is_union_distinct True if the union preceding the new select statement
- uses UNION DISTINCT.
+ @param is_union_distinct True if the union preceding the new select
+ statement uses UNION DISTINCT.
@param is_top_level This should be @c TRUE if the newly created SELECT_LEX
- is a non-nested statement.
+ is a non-nested statement.
@return <code>false</code> if successful, <code>true</code> if an error was
reported. In the latter case parsing should stop.
@@ -680,7 +686,7 @@ bool add_select_to_union_list(LEX *lex, bool is_union_distinct,
}
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
{
- my_parse_error(ER_THD(lex->thd, ER_SYNTAX_ERROR));
+ my_parse_error(lex->thd, ER_SYNTAX_ERROR);
return TRUE;
}
/* This counter shouldn't be incremented for UNION parts */
@@ -708,7 +714,7 @@ bool setup_select_in_parentheses(LEX *lex)
/*
if (sel->set_braces(1))
{
- my_parse_error(ER_THD(lex->thd, ER_SYNTAX_ERROR));
+ my_parse_error(lex->thd, ER_SYNTAX_ERROR);
return TRUE;
}
*/
@@ -718,7 +724,7 @@ bool setup_select_in_parentheses(LEX *lex)
sel->master_unit()->first_select()->linkage ==
UNION_TYPE)
{
- my_parse_error(ER_THD(lex->thd, ER_SYNTAX_ERROR));
+ my_parse_error(lex->thd, ER_SYNTAX_ERROR);
return TRUE;
}
if (sel->linkage == UNION_TYPE &&
@@ -3431,7 +3437,7 @@ signal_allowed_expr:
SIGNAL/RESIGNAL ...
SET <signal condition item name> = @foo := expr
*/
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -4613,7 +4619,8 @@ tablespace_name:
ident
{
LEX *lex= Lex;
- lex->alter_tablespace_info= new st_alter_tablespace();
+ lex->alter_tablespace_info= (new (thd->mem_root)
+ st_alter_tablespace());
if (lex->alter_tablespace_info == NULL)
MYSQL_YYABORT;
lex->alter_tablespace_info->tablespace_name= $1.str;
@@ -4625,7 +4632,8 @@ logfile_group_name:
ident
{
LEX *lex= Lex;
- lex->alter_tablespace_info= new st_alter_tablespace();
+ lex->alter_tablespace_info= (new (thd->mem_root)
+ st_alter_tablespace());
if (lex->alter_tablespace_info == NULL)
MYSQL_YYABORT;
lex->alter_tablespace_info->logfile_group_name= $1.str;
@@ -4899,7 +4907,7 @@ partitioning:
PARTITION_SYM have_partitioning
{
LEX *lex= Lex;
- lex->part_info= new partition_info();
+ lex->part_info= new (thd->mem_root) partition_info();
if (!lex->part_info)
{
mem_alloc_error(sizeof(partition_info));
@@ -4938,7 +4946,7 @@ partition_entry:
LEX *lex= Lex;
if (!lex->part_info)
{
- my_parse_error(ER_THD(thd, ER_PARTITION_ENTRY_ERROR));
+ my_parse_error(thd, ER_PARTITION_ENTRY_ERROR);
MYSQL_YYABORT;
}
/*
@@ -4993,7 +5001,7 @@ opt_key_algo:
Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_55;
break;
default:
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -5122,7 +5130,7 @@ part_func_expr:
lex->safe_to_cache_query= 1;
if (not_corr_func)
{
- my_parse_error(ER_THD(thd, ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR));
+ my_parse_error(thd, ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR);
MYSQL_YYABORT;
}
$$=$1;
@@ -5171,7 +5179,7 @@ part_defs:
if (part_info->num_parts !=
count_curr_parts)
{
- my_parse_error(ER_THD(thd, ER_PARTITION_WRONG_NO_PART_ERROR));
+ my_parse_error(thd, ER_PARTITION_WRONG_NO_PART_ERROR);
MYSQL_YYABORT;
}
}
@@ -5192,7 +5200,7 @@ part_definition:
PARTITION_SYM
{
partition_info *part_info= Lex->part_info;
- partition_element *p_elem= new partition_element();
+ partition_element *p_elem= new (thd->mem_root) partition_element();
if (!p_elem ||
part_info->partitions.push_back(p_elem, thd->mem_root))
@@ -5290,7 +5298,7 @@ part_func_max:
part_info->num_columns != 1U)
{
part_info->print_debug("Kilroy II", NULL);
- my_parse_error(ER_THD(thd, ER_PARTITION_COLUMN_LIST_ERROR));
+ my_parse_error(thd, ER_PARTITION_COLUMN_LIST_ERROR);
MYSQL_YYABORT;
}
else
@@ -5321,7 +5329,7 @@ part_values_in:
part_info->num_columns > MAX_REF_PARTS)
{
part_info->print_debug("Kilroy III", NULL);
- my_parse_error(ER_THD(thd, ER_PARTITION_COLUMN_LIST_ERROR));
+ my_parse_error(thd, ER_PARTITION_COLUMN_LIST_ERROR);
MYSQL_YYABORT;
}
/*
@@ -5342,7 +5350,7 @@ part_values_in:
partition_info *part_info= Lex->part_info;
if (part_info->num_columns < 2U)
{
- my_parse_error(ER_THD(thd, ER_ROW_SINGLE_PARTITION_FIELD_ERROR));
+ my_parse_error(thd, ER_ROW_SINGLE_PARTITION_FIELD_ERROR);
MYSQL_YYABORT;
}
}
@@ -5383,7 +5391,7 @@ part_value_item:
error.
*/
part_info->print_debug("Kilroy I", NULL);
- my_parse_error(ER_THD(thd, ER_PARTITION_COLUMN_LIST_ERROR));
+ my_parse_error(thd, ER_PARTITION_COLUMN_LIST_ERROR);
MYSQL_YYABORT;
}
part_info->curr_list_object= 0;
@@ -5401,7 +5409,7 @@ part_value_expr_item:
partition_info *part_info= Lex->part_info;
if (part_info->part_type == LIST_PARTITION)
{
- my_parse_error(ER_THD(thd, ER_MAXVALUE_IN_VALUES_IN));
+ my_parse_error(thd, ER_MAXVALUE_IN_VALUES_IN);
MYSQL_YYABORT;
}
if (part_info->add_max_value(thd))
@@ -5417,7 +5425,7 @@ part_value_expr_item:
if (!lex->safe_to_cache_query)
{
- my_parse_error(ER_THD(thd, ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR));
+ my_parse_error(thd, ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR);
MYSQL_YYABORT;
}
if (part_info->add_column_list_value(thd, part_expr))
@@ -5439,7 +5447,7 @@ opt_sub_partition:
We come here when we have defined subpartitions on the first
partition but not on all the subsequent partitions.
*/
- my_parse_error(ER_THD(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR));
+ my_parse_error(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR);
MYSQL_YYABORT;
}
}
@@ -5451,7 +5459,7 @@ opt_sub_partition:
if (part_info->num_subparts !=
part_info->count_curr_subparts)
{
- my_parse_error(ER_THD(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR));
+ my_parse_error(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR);
MYSQL_YYABORT;
}
}
@@ -5459,7 +5467,7 @@ opt_sub_partition:
{
if (part_info->partitions.elements > 1)
{
- my_parse_error(ER_THD(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR));
+ my_parse_error(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR);
MYSQL_YYABORT;
}
part_info->num_subparts= part_info->count_curr_subparts;
@@ -5478,7 +5486,8 @@ sub_part_definition:
{
partition_info *part_info= Lex->part_info;
partition_element *curr_part= part_info->current_partition;
- partition_element *sub_p_elem= new partition_element(curr_part);
+ partition_element *sub_p_elem= new (thd->mem_root)
+ partition_element(curr_part);
if (part_info->use_default_subpartitions &&
part_info->partitions.elements >= 2)
{
@@ -5493,7 +5502,7 @@ sub_part_definition:
the second partition (the current partition processed
have already been put into the partitions list.
*/
- my_parse_error(ER_THD(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR));
+ my_parse_error(thd, ER_PARTITION_WRONG_NO_SUBPART_ERROR);
MYSQL_YYABORT;
}
if (!sub_p_elem ||
@@ -5703,7 +5712,7 @@ create_table_option:
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
break;
default:
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
@@ -5724,7 +5733,7 @@ create_table_option:
Lex->create_info.stats_auto_recalc= HA_STATS_AUTO_RECALC_ON;
break;
default:
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
Lex->create_info.used_fields|= HA_CREATE_USED_STATS_AUTO_RECALC;
@@ -5744,7 +5753,7 @@ create_table_option:
Lex->create_info.table_options|= HA_OPTION_STATS_PERSISTENT;
break;
default:
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
Lex->create_info.used_fields|= HA_CREATE_USED_STATS_PERSISTENT;
@@ -5767,7 +5776,7 @@ create_table_option:
we can store the higher bits from stats_sample_pages in .frm too. */
if ($3 == 0 || $3 > 0xffff)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
Lex->create_info.stats_sample_pages=$3;
@@ -6057,23 +6066,25 @@ key_def:
| opt_constraint FOREIGN KEY_SYM opt_if_not_exists opt_ident
{
if (Lex->check_add_key($4) ||
- !(Lex->last_key= new Key(Key::MULTIPLE, $1.str ? $1 : $5,
- HA_KEY_ALG_UNDEF, true, $4)))
+ !(Lex->last_key= (new (thd->mem_root)
+ Key(Key::MULTIPLE, $1.str ? $1 : $5,
+ HA_KEY_ALG_UNDEF, true, $4))))
MYSQL_YYABORT;
Lex->option_list= NULL;
}
'(' key_list ')' references
{
LEX *lex=Lex;
- Key *key= new Foreign_key($5.str ? $5 : $1,
- lex->last_key->columns,
- $10->db,
- $10->table,
- lex->ref_list,
- lex->fk_delete_opt,
- lex->fk_update_opt,
- lex->fk_match_option,
- $4);
+ Key *key= (new (thd->mem_root)
+ Foreign_key($5.str ? $5 : $1,
+ lex->last_key->columns,
+ $10->db,
+ $10->table,
+ lex->ref_list,
+ lex->fk_delete_opt,
+ lex->fk_update_opt,
+ lex->fk_match_option,
+ $4));
if (key == NULL)
MYSQL_YYABORT;
/*
@@ -6112,7 +6123,7 @@ field_spec:
field_ident
{
LEX *lex=Lex;
- Create_field *f= new Create_field();
+ Create_field *f= new (thd->mem_root) Create_field();
if (check_string_char_length(&$1, 0, NAME_CHAR_LEN,
system_charset_info, 1))
@@ -6216,7 +6227,7 @@ parse_vcol_expr:
virtual_column_func:
remember_name expr remember_end
{
- Virtual_column_info *v= new Virtual_column_info();
+ Virtual_column_info *v= new (thd->mem_root) Virtual_column_info();
if (!v)
{
mem_alloc_error(sizeof(Virtual_column_info));
@@ -6752,7 +6763,7 @@ ws_nweights:
{
if ($2 == 0)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -6840,14 +6851,14 @@ opt_ref_list:
ref_list:
ref_list ',' ident
{
- Key_part_spec *key= new Key_part_spec($3, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec($3, 0);
if (key == NULL)
MYSQL_YYABORT;
Lex->ref_list.push_back(key, thd->mem_root);
}
| ident
{
- Key_part_spec *key= new Key_part_spec($1, 0);
+ Key_part_spec *key= new (thd->mem_root) Key_part_spec($1, 0);
if (key == NULL)
MYSQL_YYABORT;
LEX *lex= Lex;
@@ -7073,7 +7084,7 @@ key_list:
key_part:
ident
{
- $$= new Key_part_spec($1, 0);
+ $$= new (thd->mem_root) Key_part_spec($1, 0);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -7084,7 +7095,7 @@ key_part:
{
my_error(ER_KEY_PART_0, MYF(0), $1.str);
}
- $$= new Key_part_spec($1, (uint) key_part_len);
+ $$= new (thd->mem_root) Key_part_spec($1, (uint) key_part_len);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -7263,7 +7274,7 @@ alter:
{
if (!($7 || $8 || $9 || $10 || $11))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
/*
@@ -7489,7 +7500,7 @@ add_partition_rule:
opt_no_write_to_binlog
{
LEX *lex= Lex;
- lex->part_info= new partition_info();
+ lex->part_info= new (thd->mem_root) partition_info();
if (!lex->part_info)
{
mem_alloc_error(sizeof(partition_info));
@@ -7521,7 +7532,7 @@ reorg_partition_rule:
REORGANIZE_SYM PARTITION_SYM opt_no_write_to_binlog
{
LEX *lex= Lex;
- lex->part_info= new partition_info();
+ lex->part_info= new (thd->mem_root) partition_info();
if (!lex->part_info)
{
mem_alloc_error(sizeof(partition_info));
@@ -7614,7 +7625,8 @@ alter_list_item:
| DROP opt_column opt_if_exists_table_element field_ident opt_restrict
{
LEX *lex=Lex;
- Alter_drop *ad= new Alter_drop(Alter_drop::COLUMN, $4.str, $3);
+ Alter_drop *ad= (new (thd->mem_root)
+ Alter_drop(Alter_drop::COLUMN, $4.str, $3));
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
@@ -7623,7 +7635,8 @@ alter_list_item:
| DROP FOREIGN KEY_SYM opt_if_exists_table_element field_ident
{
LEX *lex=Lex;
- Alter_drop *ad= new Alter_drop(Alter_drop::FOREIGN_KEY, $5.str, $4);
+ Alter_drop *ad= (new (thd->mem_root)
+ Alter_drop(Alter_drop::FOREIGN_KEY, $5.str, $4));
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
@@ -7632,8 +7645,9 @@ alter_list_item:
| DROP PRIMARY_SYM KEY_SYM
{
LEX *lex=Lex;
- Alter_drop *ad= new Alter_drop(Alter_drop::KEY, primary_key_name,
- FALSE);
+ Alter_drop *ad= (new (thd->mem_root)
+ Alter_drop(Alter_drop::KEY, primary_key_name,
+ FALSE));
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
@@ -7642,7 +7656,8 @@ alter_list_item:
| DROP key_or_index opt_if_exists_table_element field_ident
{
LEX *lex=Lex;
- Alter_drop *ad= new Alter_drop(Alter_drop::KEY, $4.str, $3);
+ Alter_drop *ad= (new (thd->mem_root)
+ Alter_drop(Alter_drop::KEY, $4.str, $3));
if (ad == NULL)
MYSQL_YYABORT;
lex->alter_info.drop_list.push_back(ad, thd->mem_root);
@@ -7663,7 +7678,7 @@ alter_list_item:
| ALTER opt_column field_ident SET DEFAULT signed_literal
{
LEX *lex=Lex;
- Alter_column *ac= new Alter_column($3.str,$6);
+ Alter_column *ac= new (thd->mem_root) Alter_column($3.str,$6);
if (ac == NULL)
MYSQL_YYABORT;
lex->alter_info.alter_list.push_back(ac, thd->mem_root);
@@ -7672,7 +7687,8 @@ alter_list_item:
| ALTER opt_column field_ident DROP DEFAULT
{
LEX *lex=Lex;
- Alter_column *ac= new Alter_column($3.str, (Item*) 0);
+ Alter_column *ac= (new (thd->mem_root)
+ Alter_column($3.str, (Item*) 0));
if (ac == NULL)
MYSQL_YYABORT;
lex->alter_info.alter_list.push_back(ac, thd->mem_root);
@@ -7879,7 +7895,7 @@ start:
if (($3 & MYSQL_START_TRANS_OPT_READ_WRITE) &&
($3 & MYSQL_START_TRANS_OPT_READ_ONLY))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
lex->start_transaction_opt= $3;
@@ -8081,7 +8097,7 @@ persistent_column_stat_spec:
| '('
{
LEX* lex= thd->lex;
- lex->column_list= new List<LEX_STRING>;
+ lex->column_list= new (thd->mem_root) List<LEX_STRING>;
if (lex->column_list == NULL)
MYSQL_YYABORT;
}
@@ -8094,7 +8110,7 @@ persistent_index_stat_spec:
| '('
{
LEX* lex= thd->lex;
- lex->index_list= new List<LEX_STRING>;
+ lex->index_list= new (thd->mem_root) List<LEX_STRING>;
if (lex->index_list == NULL)
MYSQL_YYABORT;
}
@@ -10064,7 +10080,7 @@ function_call_generic:
{
if (lex->current_select->inc_in_sum_expr())
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10407,7 +10423,7 @@ variable_aux:
/* disallow "SELECT @@global.global.variable" */
if ($3.str && $4.str && check_reserved_words(&$3))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
if (!($$= get_system_var(thd, $2, $3, $4)))
@@ -10463,7 +10479,7 @@ in_sum_expr:
LEX *lex= Lex;
if (lex->current_select->inc_in_sum_expr())
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10567,7 +10583,7 @@ opt_else:
when_list:
WHEN_SYM expr THEN_SYM expr
{
- $$= new List<Item>;
+ $$= new (thd->mem_root) List<Item>;
if ($$ == NULL)
MYSQL_YYABORT;
$$->push_back($2, thd->mem_root);
@@ -10590,7 +10606,7 @@ table_ref:
LEX *lex= Lex;
if (!($$= lex->current_select->nest_last_join(lex->thd)))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10808,7 +10824,7 @@ table_factor:
{
if (sel->set_braces(1))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10858,7 +10874,7 @@ table_factor:
SELECT_LEX *sel= lex->current_select;
SELECT_LEX_UNIT *unit= sel->master_unit();
lex->current_select= sel= unit->outer_select();
- Table_ident *ti= new Table_ident(unit);
+ Table_ident *ti= new (thd->mem_root) Table_ident(unit);
if (ti == NULL)
MYSQL_YYABORT;
if (!($$= sel->add_table_to_list(lex->thd,
@@ -10880,7 +10896,7 @@ table_factor:
Tables with or without joins within parentheses cannot
have aliases, and we ruled out derived tables above.
*/
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
else
@@ -10916,7 +10932,7 @@ select_derived_union:
{
if ($1 && $2)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10939,7 +10955,7 @@ select_derived_union:
{
if ($1 != NULL)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10953,13 +10969,13 @@ select_init2_derived:
SELECT_LEX * sel= lex->current_select;
if (lex->current_select->set_braces(0))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
if (sel->linkage == UNION_TYPE &&
sel->master_unit()->first_select()->braces)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -10999,7 +11015,7 @@ select_derived:
MYSQL_YYABORT;
if (!$3 && $$)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -11012,7 +11028,7 @@ select_derived2:
if (!lex->expr_allows_subselect ||
lex->sql_command == (int)SQLCOM_PURGE)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE ||
@@ -11049,7 +11065,7 @@ select_derived_init:
if (!sel->embedding || sel->end_nested_join(lex->thd))
{
/* we are not in parentheses */
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
embedding= Select->embedding;
@@ -11127,7 +11143,7 @@ key_usage_list:
using_list:
ident
{
- if (!($$= new List<String>))
+ if (!($$= new (thd->mem_root) List<String>))
MYSQL_YYABORT;
String *s= new (thd->mem_root) String((const char *) $1.str,
$1.length,
@@ -11562,8 +11578,8 @@ delete_limit_clause:
Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT);
sel->explicit_limit= 1;
}
- | LIMIT ROWS_SYM EXAMINED_SYM { my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR)); MYSQL_YYABORT; }
- | LIMIT limit_option ROWS_SYM EXAMINED_SYM { my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR)); MYSQL_YYABORT; }
+ | LIMIT ROWS_SYM EXAMINED_SYM { my_parse_error(thd, ER_SYNTAX_ERROR); MYSQL_YYABORT; }
+ | LIMIT limit_option ROWS_SYM EXAMINED_SYM { my_parse_error(thd, ER_SYNTAX_ERROR); MYSQL_YYABORT; }
;
int_num:
@@ -11607,7 +11623,7 @@ real_ulonglong_num:
dec_num_error:
dec_num
- { my_parse_error(ER_THD(thd, ER_ONLY_INTEGERS_ALLOWED)); }
+ { my_parse_error(thd, ER_ONLY_INTEGERS_ALLOWED); }
;
dec_num:
@@ -11710,7 +11726,7 @@ select_var_ident: select_outvar
select_outvar:
'@' ident_or_text
{
- $$ = Lex->result ? new my_var_user($2) : NULL;
+ $$ = Lex->result ? new (thd->mem_root) my_var_user($2) : NULL;
}
| ident_or_text
{
@@ -11721,8 +11737,10 @@ select_outvar:
my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
MYSQL_YYABORT;
}
- $$ = Lex->result ? new my_var_sp($1, t->offset, t->type, Lex->sphead)
- : NULL;
+ $$ = Lex->result ? (new (thd->mem_root)
+ my_var_sp($1, t->offset, t->type,
+ Lex->sphead)) :
+ NULL;
}
;
@@ -11758,7 +11776,7 @@ into_destination:
if (!lex->describe)
{
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
- if (!(lex->exchange= new sql_exchange($2.str,1)))
+ if (!(lex->exchange= new (thd->mem_root) sql_exchange($2.str,1)))
MYSQL_YYABORT;
if (!(lex->result=
new (thd->mem_root) select_dump(thd, lex->exchange)))
@@ -11805,7 +11823,8 @@ drop:
| DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident {}
{
LEX *lex=Lex;
- Alter_drop *ad= new Alter_drop(Alter_drop::KEY, $4.str, $3);
+ Alter_drop *ad= (new (thd->mem_root)
+ Alter_drop(Alter_drop::KEY, $4.str, $3));
if (ad == NULL)
MYSQL_YYABORT;
lex->sql_command= SQLCOM_DROP_INDEX;
@@ -12324,7 +12343,7 @@ table_wild_list:
table_wild_one:
ident opt_wild
{
- Table_ident *ti= new Table_ident($1);
+ Table_ident *ti= new (thd->mem_root) Table_ident($1);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12337,7 +12356,7 @@ table_wild_one:
}
| ident '.' ident opt_wild
{
- Table_ident *ti= new Table_ident(thd, $1, $3, 0);
+ Table_ident *ti= new (thd->mem_root) Table_ident(thd, $1, $3, 0);
if (ti == NULL)
MYSQL_YYABORT;
if (!Select->add_table_to_list(thd,
@@ -12766,12 +12785,12 @@ show_param:
ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str);
if (!table || !table->old_format)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR), $2);
+ my_parse_error(thd, ER_SYNTAX_ERROR, $2);
MYSQL_YYABORT;
}
if (lex->wild && table->idx_field1 < 0)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR), $3);
+ my_parse_error(thd, ER_SYNTAX_ERROR, $3);
MYSQL_YYABORT;
}
if (make_schema_select(thd, Lex->current_select, table))
@@ -12977,7 +12996,7 @@ flush_lock:
{
if (Lex->query_tables == NULL) // Table list can't be empty
{
- my_parse_error(ER_THD(thd, ER_NO_TABLES_USED));
+ my_parse_error(thd, ER_NO_TABLES_USED);
MYSQL_YYABORT;
}
Lex->type|= REFRESH_FOR_EXPORT;
@@ -13048,7 +13067,7 @@ flush_option:
ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str);
if (!table || !table->reset_table)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR), $2);
+ my_parse_error(thd, ER_SYNTAX_ERROR, $2);
MYSQL_YYABORT;
}
Lex->view_list.push_back((LEX_STRING*)
@@ -13218,7 +13237,7 @@ load:
lex->local_file= $5;
lex->duplicates= DUP_ERROR;
lex->ignore= 0;
- if (!(lex->exchange= new sql_exchange($7.str, 0, $2)))
+ if (!(lex->exchange= new (thd->mem_root) sql_exchange($7.str, 0, $2)))
MYSQL_YYABORT;
}
opt_duplicate INTO TABLE_SYM table_ident opt_use_partition
@@ -14713,7 +14732,7 @@ option_value_following_option_type:
Not in trigger assigning value to new row,
and option_type preceding local variable is illegal.
*/
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
}
@@ -14753,7 +14772,7 @@ option_value_no_option_type:
item= new (thd->mem_root) Item_func_set_user_var(thd, $2, $4);
if (item == NULL)
MYSQL_YYABORT;
- set_var_user *var= new set_var_user(item);
+ set_var_user *var= new (thd->mem_root) set_var_user(item);
if (var == NULL)
MYSQL_YYABORT;
Lex->var_list.push_back(var, thd->mem_root);
@@ -14776,9 +14795,10 @@ option_value_no_option_type:
CHARSET_INFO *cs2;
cs2= $2 ? $2: global_system_variables.character_set_client;
set_var_collation_client *var;
- var= new set_var_collation_client(cs2,
- thd->variables.collation_database,
- cs2);
+ var= (new (thd->mem_root)
+ set_var_collation_client(cs2,
+ thd->variables.collation_database,
+ cs2));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14794,7 +14814,7 @@ option_value_no_option_type:
if (spc && spc->find_variable(names, false))
my_error(ER_SP_BAD_VAR_SHADOW, MYF(0), names.str);
else
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
@@ -14812,7 +14832,7 @@ option_value_no_option_type:
MYSQL_YYABORT;
}
set_var_collation_client *var;
- var= new set_var_collation_client(cs3, cs3, cs3);
+ var= new (thd->mem_root) set_var_collation_client(cs3, cs3, cs3);
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14824,8 +14844,9 @@ option_value_no_option_type:
if (!(user=(LEX_USER *) thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
user->user= current_user;
- set_var_default_role *var= new set_var_default_role(user,
- $3->user);
+ set_var_default_role *var= (new (thd->mem_root)
+ set_var_default_role(user,
+ $3->user));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14836,7 +14857,8 @@ option_value_no_option_type:
| DEFAULT ROLE_SYM grant_role FOR_SYM user
{
LEX *lex = Lex;
- set_var_default_role *var= new set_var_default_role($5, $3->user);
+ set_var_default_role *var= (new (thd->mem_root)
+ set_var_default_role($5, $3->user));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14847,7 +14869,7 @@ option_value_no_option_type:
| ROLE_SYM ident_or_text
{
LEX *lex = Lex;
- set_var_role *var= new set_var_role($2);
+ set_var_role *var= new (thd->mem_root) set_var_role($2);
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14855,7 +14877,8 @@ option_value_no_option_type:
| PASSWORD_SYM opt_for_user text_or_password
{
LEX *lex = Lex;
- set_var_password *var= new set_var_password(lex->definer);
+ set_var_password *var= (new (thd->mem_root)
+ set_var_password(lex->definer));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14898,7 +14921,7 @@ internal_variable_name:
LEX *lex= Lex;
if (check_reserved_words(&$1))
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_TRIGGER &&
@@ -14963,10 +14986,11 @@ transaction_access_mode:
Item *item= new (thd->mem_root) Item_int(thd, (int32) $1);
if (item == NULL)
MYSQL_YYABORT;
- set_var *var= new set_var(thd, lex->option_type,
- find_sys_var(thd, "tx_read_only"),
- &null_lex_str,
- item);
+ set_var *var= (new (thd->mem_root)
+ set_var(thd, lex->option_type,
+ find_sys_var(thd, "tx_read_only"),
+ &null_lex_str,
+ item));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -14980,10 +15004,11 @@ isolation_level:
Item *item= new (thd->mem_root) Item_int(thd, (int32) $3);
if (item == NULL)
MYSQL_YYABORT;
- set_var *var= new set_var(thd, lex->option_type,
- find_sys_var(thd, "tx_isolation"),
- &null_lex_str,
- item);
+ set_var *var= (new (thd->mem_root)
+ set_var(thd, lex->option_type,
+ find_sys_var(thd, "tx_isolation"),
+ &null_lex_str,
+ item));
if (var == NULL)
MYSQL_YYABORT;
lex->var_list.push_back(var, thd->mem_root);
@@ -15211,7 +15236,7 @@ handler_rkey_function:
LEX *lex=Lex;
lex->ha_read_mode = RKEY;
lex->ha_rkey_mode=$1;
- if (!(lex->insert_list= new List_item))
+ if (!(lex->insert_list= new (thd->mem_root) List_item))
MYSQL_YYABORT;
}
'(' values ')'
@@ -15245,7 +15270,7 @@ revoke_command:
LEX *lex= Lex;
if (lex->columns.elements)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
lex->sql_command= SQLCOM_REVOKE;
@@ -15256,7 +15281,7 @@ revoke_command:
LEX *lex= Lex;
if (lex->columns.elements)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
lex->sql_command= SQLCOM_REVOKE;
@@ -15307,7 +15332,7 @@ grant_command:
LEX *lex= Lex;
if (lex->columns.elements)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
lex->sql_command= SQLCOM_GRANT;
@@ -15319,7 +15344,7 @@ grant_command:
LEX *lex= Lex;
if (lex->columns.elements)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
lex->sql_command= SQLCOM_GRANT;
@@ -15665,7 +15690,8 @@ column_list_id:
point->rights |= lex->which_columns;
else
{
- LEX_COLUMN *col= new LEX_COLUMN (*new_str,lex->which_columns);
+ LEX_COLUMN *col= (new (thd->mem_root)
+ LEX_COLUMN(*new_str,lex->which_columns));
if (col == NULL)
MYSQL_YYABORT;
lex->columns.push_back(col, thd->mem_root);
@@ -15948,7 +15974,7 @@ subselect_start:
if (!lex->expr_allows_subselect ||
lex->sql_command == (int)SQLCOM_PURGE)
{
- my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR));
+ my_parse_error(thd, ER_SYNTAX_ERROR);
MYSQL_YYABORT;
}
/*
@@ -16386,9 +16412,9 @@ sf_tail:
- The user deploys 5.{N+1}. At this point, 'select foo()'
means something different, and the user code is most likely
broken (it's only safe if the code is 'select db.foo()').
- With a warning printed when the SF is loaded (which has to occur
- before the call), the warning will provide a hint explaining
- the root cause of a later failure of 'select foo()'.
+ With a warning printed when the SF is loaded (which has to
+ occur before the call), the warning will provide a hint
+ explaining the root cause of a later failure of 'select foo()'.
With no warning printed, the user code will fail with no
apparent reason.
Printing a warning each time db_load_routine is executed for
diff --git a/sql/unireg.cc b/sql/unireg.cc
index ad35368a755..49503794c38 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -583,14 +583,14 @@ static bool pack_header(THD *thd, uchar *forminfo,
The HEX representation is created from this copy.
*/
field->save_interval= field->interval;
- field->interval= (TYPELIB*) sql_alloc(sizeof(TYPELIB));
+ field->interval= (TYPELIB*) thd->alloc(sizeof(TYPELIB));
*field->interval= *field->save_interval;
field->interval->type_names=
- (const char **) sql_alloc(sizeof(char*) *
- (field->interval->count+1));
+ (const char **) thd->alloc(sizeof(char*) *
+ (field->interval->count+1));
field->interval->type_names[field->interval->count]= 0;
field->interval->type_lengths=
- (uint *) sql_alloc(sizeof(uint) * field->interval->count);
+ (uint *) thd->alloc(sizeof(uint) * field->interval->count);
for (uint pos= 0; pos < field->interval->count; pos++)
{
@@ -600,8 +600,8 @@ static bool pack_header(THD *thd, uchar *forminfo,
length= field->save_interval->type_lengths[pos];
hex_length= length * 2;
field->interval->type_lengths[pos]= hex_length;
- field->interval->type_names[pos]= dst= (char*) sql_alloc(hex_length +
- 1);
+ field->interval->type_names[pos]= dst=
+ (char*) thd->alloc(hex_length + 1);
octet2hex(dst, src, length);
}
}