summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/feedback/feedback.cc13
-rw-r--r--sql/events.cc34
-rw-r--r--sql/field.cc2
-rw-r--r--sql/handler.cc28
-rw-r--r--sql/item.cc209
-rw-r--r--sql/item.h32
-rw-r--r--sql/item_cmpfunc.cc87
-rw-r--r--sql/item_cmpfunc.h56
-rw-r--r--sql/item_create.cc4
-rw-r--r--sql/item_func.cc16
-rw-r--r--sql/item_subselect.cc213
-rw-r--r--sql/item_sum.cc23
-rw-r--r--sql/item_sum.h13
-rw-r--r--sql/item_xmlfunc.cc244
-rw-r--r--sql/log_event.cc27
-rw-r--r--sql/opt_index_cond_pushdown.cc12
-rw-r--r--sql/opt_subselect.cc37
-rw-r--r--sql/opt_table_elimination.cc2
-rw-r--r--sql/protocol.cc2
-rw-r--r--sql/repl_failsafe.cc13
-rw-r--r--sql/set_var.cc21
-rw-r--r--sql/set_var.h18
-rw-r--r--sql/slave.cc111
-rw-r--r--sql/sp_head.cc24
-rw-r--r--sql/sp_rcontext.cc2
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_admin.cc8
-rw-r--r--sql/sql_analyse.cc24
-rw-r--r--sql/sql_base.cc8
-rw-r--r--sql/sql_class.cc69
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_error.cc8
-rw-r--r--sql/sql_explain.cc72
-rw-r--r--sql/sql_expression_cache.cc3
-rw-r--r--sql/sql_get_diagnostics.cc2
-rw-r--r--sql/sql_help.cc45
-rw-r--r--sql/sql_join_cache.cc2
-rw-r--r--sql/sql_parse.cc29
-rw-r--r--sql/sql_prepare.cc11
-rw-r--r--sql/sql_profile.cc9
-rw-r--r--sql/sql_repl.cc17
-rw-r--r--sql/sql_select.cc107
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_show.cc150
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_union.cc4
-rw-r--r--sql/sql_update.cc4
-rw-r--r--sql/sql_yacc.yy170
-rw-r--r--sql/table.cc10
-rw-r--r--storage/sphinx/ha_sphinx.cc5
-rw-r--r--storage/spider/spd_sys_table.cc12
51 files changed, 1146 insertions, 881 deletions
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc
index f1f4febc69e..a762522136e 100644
--- a/plugin/feedback/feedback.cc
+++ b/plugin/feedback/feedback.cc
@@ -99,20 +99,23 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
nrc.init();
nrc.resolve_in_table_list_only(tables);
- res= new Item_cond_or(thd);
+ res= new (thd->mem_root) Item_cond_or(thd);
if (!res)
return OOM;
for (; filter->str; filter++)
{
- Item_field *fld= new Item_field(thd, &nrc, db, table, field);
- Item_string *pattern= new Item_string(thd, filter->str, filter->length, cs);
- Item_string *escape= new Item_string(thd, "\\", 1, cs);
+ Item_field *fld= new (thd->mem_root) Item_field(thd, &nrc, db, table,
+ field);
+ Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str,
+ filter->length, cs);
+ Item_string *escape= new (thd->mem_root) Item_string(thd, "\\", 1, cs);
if (!fld || !pattern || !escape)
return OOM;
- Item_func_like *like= new Item_func_like(thd, fld, pattern, escape, 0);
+ Item_func_like *like= new (thd->mem_root) Item_func_like(thd, fld, pattern,
+ escape, 0);
if (!like)
return OOM;
diff --git a/sql/events.cc b/sql/events.cc
index 911a683b723..a346d02fc39 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -632,37 +632,43 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
List<Item> field_list;
LEX_STRING sql_mode;
const String *tz_name;
-
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_show_create_event");
show_str.length(0);
if (et->get_create_event(thd, &show_str))
DBUG_RETURN(TRUE);
- field_list.push_back(new Item_empty_string(thd, "Event", NAME_CHAR_LEN));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "Event", NAME_CHAR_LEN));
if (sql_mode_string_representation(thd, et->sql_mode, &sql_mode))
DBUG_RETURN(TRUE);
- field_list.push_back(new Item_empty_string(thd, "sql_mode",
- (uint) sql_mode.length));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "sql_mode",
+ (uint) sql_mode.length));
tz_name= et->time_zone->get_name();
- field_list.push_back(new Item_empty_string(thd, "time_zone",
- tz_name->length()));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "time_zone", tz_name->length()));
- field_list.push_back(new Item_empty_string(thd, "Create Event",
- show_str.length()));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "Create Event",
+ show_str.length()));
- field_list.push_back(
- new Item_empty_string(thd, "character_set_client", MY_CS_NAME_SIZE));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "character_set_client",
+ MY_CS_NAME_SIZE));
- field_list.push_back(
- new Item_empty_string(thd, "collation_connection", MY_CS_NAME_SIZE));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "collation_connection",
+ MY_CS_NAME_SIZE));
- field_list.push_back(
- new Item_empty_string(thd, "Database Collation", MY_CS_NAME_SIZE));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "Database Collation",
+ MY_CS_NAME_SIZE));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
diff --git a/sql/field.cc b/sql/field.cc
index a65f09acafa..7eb340b6b65 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -10097,7 +10097,7 @@ Create_field::Create_field(THD *thd, Field *old_field, Field *orig_field)
StringBuffer<MAX_FIELD_WIDTH> tmp(charset);
String *res= orig_field->val_str(&tmp);
char *pos= (char*) sql_strmake(res->ptr(), res->length());
- def= new Item_string(thd, pos, res->length(), charset);
+ def= new (thd->mem_root) Item_string(thd, pos, res->length(), charset);
}
orig_field->move_field_offset(-diff); // Back to record[0]
}
diff --git a/sql/handler.cc b/sql/handler.cc
index e2c24c7842a..eec6e5c1212 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1981,16 +1981,21 @@ bool mysql_xa_recover(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysql_xa_recover");
- field_list.push_back(new Item_int(thd, "formatID", 0,
- MY_INT32_NUM_DECIMAL_DIGITS));
- field_list.push_back(new Item_int(thd, "gtrid_length", 0,
- MY_INT32_NUM_DECIMAL_DIGITS));
- field_list.push_back(new Item_int(thd, "bqual_length", 0,
- MY_INT32_NUM_DECIMAL_DIGITS));
- field_list.push_back(new Item_empty_string(thd, "data",
- XIDDATASIZE));
+ field_list.push_back(new (mem_root)
+ Item_int(thd, "formatID", 0,
+ MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new (mem_root)
+ Item_int(thd, "gtrid_length", 0,
+ MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new (mem_root)
+ Item_int(thd, "bqual_length", 0,
+ MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(thd, "data",
+ XIDDATASIZE));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -5525,11 +5530,12 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
bool result;
- field_list.push_back(new Item_empty_string(thd, "Type", 10));
- field_list.push_back(new Item_empty_string(thd, "Name", FN_REFLEN));
- field_list.push_back(new Item_empty_string(thd, "Status", 10));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Type", 10));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Name", FN_REFLEN));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Status", 10));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
diff --git a/sql/item.cc b/sql/item.cc
index da7dbba9f53..1639dbecc52 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -693,7 +693,7 @@ Item* Item::set_expr_cache(THD *thd)
{
DBUG_ENTER("Item::set_expr_cache");
Item_cache_wrapper *wrapper;
- if ((wrapper= new Item_cache_wrapper(thd, this)) &&
+ if ((wrapper= new (thd->mem_root) Item_cache_wrapper(thd, this)) &&
!wrapper->fix_fields(thd, (Item**)&wrapper))
{
if (wrapper->set_cache(thd))
@@ -1046,7 +1046,7 @@ Item *Item::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
if (!needs_charset_converter(tocs))
return this;
- Item_func_conv_charset *conv= new Item_func_conv_charset(thd, this, tocs, 1);
+ Item_func_conv_charset *conv= new (thd->mem_root) Item_func_conv_charset(thd, this, tocs, 1);
return conv->safe ? conv : NULL;
}
@@ -1058,7 +1058,7 @@ Item *Item::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
Example:
Item_singlerow_subselect has "Item_cache **row".
Creating of Item_func_conv_charset followed by THD::change_item_tree()
- should not change row[i] from Item_cache directly to Item_func_conv_charset, because Item_singlerow_subselect
+ should not change row[i] from Item_cache directly to Item_func_conv_charset,
because Item_singlerow_subselect later calls Item_cache-specific methods,
e.g. row[i]->store() and row[i]->cache_value().
@@ -1079,7 +1079,7 @@ Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
if (conv == example)
return this;
Item_cache *cache;
- if (!conv || !(cache= new Item_cache_str(thd, conv)))
+ if (!conv || !(cache= new (thd->mem_root) Item_cache_str(thd, conv)))
return NULL; // Safe conversion is not possible, or OEM
cache->setup(thd, conv);
cache->fixed= false; // Make Item::fix_fields() happy
@@ -1135,8 +1135,10 @@ Item *Item::const_charset_converter(THD *thd, CHARSET_INFO *tocs,
DBUG_ASSERT(fixed);
StringBuffer<64>tmp;
String *s= val_str(&tmp);
+ MEM_ROOT *mem_root= thd->mem_root;
+
if (!s)
- return new Item_null(thd, (char *) func_name, tocs);
+ return new (mem_root) Item_null(thd, (char *) func_name, tocs);
if (!needs_charset_converter(s->length(), tocs))
{
@@ -1147,14 +1149,16 @@ Item *Item::const_charset_converter(THD *thd, CHARSET_INFO *tocs,
}
uint conv_errors;
- Item_string *conv= func_name ?
- new Item_static_string_func(thd, func_name,
- s, tocs, &conv_errors,
- collation.derivation,
- collation.repertoire) :
- new Item_string(thd, s, tocs, &conv_errors,
- collation.derivation,
- collation.repertoire);
+ Item_string *conv= (func_name ?
+ new (mem_root)
+ Item_static_string_func(thd, func_name,
+ s, tocs, &conv_errors,
+ collation.derivation,
+ collation.repertoire) :
+ new (mem_root)
+ Item_string(thd, s, tocs, &conv_errors,
+ collation.derivation,
+ collation.repertoire));
if (!conv || (conv_errors && lossless))
{
@@ -1797,9 +1801,10 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array,
Item *real_itm= real_item();
ref_pointer_array[el]= real_itm;
- if (!(item_ref= new Item_aggregate_ref(thd,
- &thd->lex->current_select->context,
- ref_pointer_array + el, 0, name)))
+ if (!(item_ref= (new (thd->mem_root)
+ Item_aggregate_ref(thd,
+ &thd->lex->current_select->context,
+ ref_pointer_array + el, 0, name))))
return; // fatal_error is set
if (type() == SUM_FUNC_ITEM)
item_ref->depended_from= ((Item_sum *) this)->depended_from();
@@ -2091,7 +2096,7 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
if (conv == *arg)
continue;
if (!conv && ((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
- conv= new Item_func_conv_charset(thd, *arg, coll.collation, 1);
+ conv= new (thd->mem_root) Item_func_conv_charset(thd, *arg, coll.collation, 1);
if (!conv)
{
@@ -2885,6 +2890,13 @@ void Item_decimal::set_decimal_value(my_decimal *value_par)
}
+Item *Item_decimal::clone_item(THD *thd)
+{
+ return new (thd->mem_root) Item_decimal(thd, name, &decimal_value, decimals,
+ max_length);
+}
+
+
String *Item_float::val_str(String *str)
{
// following assert is redundant, because fixed=1 assigned in constructor
@@ -2903,6 +2915,13 @@ my_decimal *Item_float::val_decimal(my_decimal *decimal_value)
}
+Item *Item_float::clone_item(THD *thd)
+{
+ return new (thd->mem_root) Item_float(thd, name, value, decimals,
+ max_length);
+}
+
+
void Item_string::print(String *str, enum_query_type query_type)
{
const bool print_introducer=
@@ -3084,6 +3103,11 @@ Item *Item_null::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
return this;
}
+Item *Item_null::clone_item(THD *thd)
+{
+ return new (thd->mem_root) Item_null(thd, name);
+}
+
/*********************** Item_param related ******************************/
/**
@@ -3698,24 +3722,28 @@ bool Item_param::basic_const_item() const
}
+/* see comments in the header file */
+
Item *
Item_param::clone_item(THD *thd)
{
- /* see comments in the header file */
+ MEM_ROOT *mem_root= thd->mem_root;
switch (state) {
case NULL_VALUE:
- return new Item_null(thd, name);
+ return new (mem_root) Item_null(thd, name);
case INT_VALUE:
return (unsigned_flag ?
- new Item_uint(thd, name, value.integer, max_length) :
- new Item_int(thd, name, value.integer, max_length));
+ new (mem_root) Item_uint(thd, name, value.integer, max_length) :
+ new (mem_root) Item_int(thd, name, value.integer, max_length));
case REAL_VALUE:
- return new Item_float(thd, name, value.real, decimals, max_length);
+ return new (mem_root) Item_float(thd, name, value.real, decimals,
+ max_length);
case STRING_VALUE:
case LONG_DATA_VALUE:
- return new Item_string(thd, name, str_value.c_ptr_quick(),
- str_value.length(), str_value.charset(),
- collation.derivation, collation.repertoire);
+ return new (mem_root) Item_string(thd, name, str_value.c_ptr_quick(),
+ str_value.length(), str_value.charset(),
+ collation.derivation,
+ collation.repertoire);
case TIME_VALUE:
break;
case NO_VALUE:
@@ -3969,18 +3997,19 @@ bool Item_param::append_for_log(THD *thd, String *str)
Item_copy *Item_copy::create(THD *thd, Item *item)
{
+ MEM_ROOT *mem_root= thd->mem_root;
switch (item->result_type())
{
case STRING_RESULT:
- return new Item_copy_string(thd, item);
+ return new (mem_root) Item_copy_string(thd, item);
case REAL_RESULT:
- return new Item_copy_float(thd, item);
+ return new (mem_root) Item_copy_float(thd, item);
case INT_RESULT:
return item->unsigned_flag ?
- new Item_copy_uint(thd, item) :
- new Item_copy_int(thd, item);
+ new (mem_root) Item_copy_uint(thd, item) :
+ new (mem_root) Item_copy_int(thd, item);
case DECIMAL_RESULT:
- return new Item_copy_decimal(thd, item);
+ return new (mem_root) Item_copy_decimal(thd, item);
case TIME_RESULT:
case ROW_RESULT:
case IMPOSSIBLE_RESULT:
@@ -4778,7 +4807,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
fix_inner_refs() function.
*/
;
- if (!(rf= new Item_outer_ref(thd, context, this)))
+ if (!(rf= new (thd->mem_root) Item_outer_ref(thd, context, this)))
return -1;
thd->change_item_tree(reference, rf);
select->inner_refs_list.push_back(rf);
@@ -4885,13 +4914,16 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
save= *ref;
*ref= NULL; // Don't call set_properties()
rf= (place == IN_HAVING ?
- new Item_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used) :
+ new (thd->mem_root)
+ Item_ref(thd, context, ref, (char*) table_name,
+ (char*) field_name, alias_name_used) :
(!select->group_list.elements ?
- new Item_direct_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used) :
- new Item_outer_ref(thd, context, ref, (char*) table_name,
- (char*) field_name, alias_name_used)));
+ new (thd->mem_root)
+ Item_direct_ref(thd, context, ref, (char*) table_name,
+ (char*) field_name, alias_name_used) :
+ new (thd->mem_root)
+ Item_outer_ref(thd, context, ref, (char*) table_name,
+ (char*) field_name, alias_name_used)));
*ref= save;
if (!rf)
return -1;
@@ -4924,7 +4956,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
if (last_checked_context->select_lex->having_fix_field)
{
Item_ref *rf;
- rf= new Item_ref(thd, context, (*from_field)->table->s->db.str,
+ rf= new (thd->mem_root) Item_ref(thd, context, (*from_field)->table->s->db.str,
(*from_field)->table->alias.c_ptr(),
(char*) field_name);
if (!rf)
@@ -5020,7 +5052,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
{
uint counter;
enum_resolution_type resolution;
- Item** res= find_item_in_list(this, thd->lex->current_select->item_list,
+ Item** res= find_item_in_list(this,
+ thd->lex->current_select->item_list,
&counter, REPORT_EXCEPT_NOT_FOUND,
&resolution);
if (!res)
@@ -5058,8 +5091,9 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
Item_ref to point to the Item in the select list and replace the
Item_field created by the parser with the new Item_ref.
*/
- Item_ref *rf= new Item_ref(thd, context, db_name, table_name,
- field_name);
+ Item_ref *rf= new (thd->mem_root)
+ Item_ref(thd, context, db_name, table_name,
+ field_name);
if (!rf)
return 1;
bool err= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1);
@@ -5350,12 +5384,12 @@ static void convert_zerofill_number_to_string(THD *thd, Item **item, Field_num *
res= (*item)->val_str(&tmp);
if ((*item)->is_null())
- *item= new Item_null(thd);
+ *item= new (thd->mem_root) Item_null(thd);
else
{
field->prepend_zeros(res);
pos= (char *) sql_strmake (res->ptr(), res->length());
- *item= new Item_string(thd, pos, res->length(), field->charset());
+ *item= new (thd->mem_root) Item_string(thd, pos, res->length(), field->charset());
}
}
@@ -6043,6 +6077,14 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
}
+Item *Item_string::clone_item(THD *thd)
+{
+ return new (thd->mem_root)
+ Item_string(thd, name, str_value.ptr(),
+ str_value.length(), collation.collation);
+}
+
+
static int save_int_value_in_field (Field *field, longlong nr,
bool null_value, bool unsigned_flag)
{
@@ -6059,6 +6101,12 @@ int Item_int::save_in_field(Field *field, bool no_conversions)
}
+Item *Item_int::clone_item(THD *thd)
+{
+ return new (thd->mem_root) Item_int(thd, name, value, max_length);
+}
+
+
void Item_datetime::set(longlong packed)
{
unpack_time(packed, &ltime);
@@ -6090,18 +6138,25 @@ Item *Item_int_with_ref::clone_item(THD *thd)
parameter markers.
*/
return (ref->unsigned_flag ?
- new Item_uint(thd, ref->name, ref->val_int(), ref->max_length) :
- new Item_int(thd, ref->name, ref->val_int(), ref->max_length));
+ new (thd->mem_root)
+ Item_uint(thd, ref->name, ref->val_int(), ref->max_length) :
+ new (thd->mem_root)
+ Item_int(thd, ref->name, ref->val_int(), ref->max_length));
}
Item_num *Item_uint::neg(THD *thd)
{
- Item_decimal *item= new Item_decimal(thd, value, 1);
+ Item_decimal *item= new (thd->mem_root) Item_decimal(thd, value, 1);
return item->neg(thd);
}
+Item *Item_uint::clone_item(THD *thd)
+{
+ return new (thd->mem_root) Item_uint(thd, name, value, max_length);
+}
+
static uint nr_of_decimals(const char *str, const char *end)
{
const char *decimal_point;
@@ -6665,7 +6720,7 @@ Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg)
ref_pointer_array[el]= (Item*)this;
all_fields->push_front((Item*)this);
- ref= new Item_ref(thd, &select->context, ref_pointer_array + el,
+ ref= new (thd->mem_root) Item_ref(thd, &select->context, ref_pointer_array + el,
table_name, field_name);
return ref;
}
@@ -6959,7 +7014,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
if (from_field != not_found_field)
{
Item_field* fld;
- if (!(fld= new Item_field(thd, from_field)))
+ if (!(fld= new (thd->mem_root) Item_field(thd, from_field)))
goto error;
thd->change_item_tree(reference, fld);
mark_as_dependent(thd, last_checked_context->select_lex,
@@ -7406,7 +7461,7 @@ Item *Item_ref::get_tmp_table_item(THD *thd)
if (!result_field)
return (*ref)->get_tmp_table_item(thd);
- Item_field *item= new Item_field(thd, result_field);
+ Item_field *item= new (thd->mem_root) Item_field(thd, result_field);
if (item)
{
item->table_name= table_name;
@@ -7884,11 +7939,11 @@ int Item_cache_wrapper::save_in_field(Field *to, bool no_conversions)
}
-Item* Item_cache_wrapper::get_tmp_table_item(THD *thd_arg)
+Item* Item_cache_wrapper::get_tmp_table_item(THD *thd)
{
if (!orig_item->with_sum_func && !orig_item->const_item())
- return new Item_field(thd_arg, result_field);
- return copy_or_same(thd_arg);
+ return new (thd->mem_root) Item_field(thd, result_field);
+ return copy_or_same(thd);
}
@@ -8575,11 +8630,13 @@ Item_result item_cmp_type(Item_result a,Item_result b)
void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
{
Item *item= *ref;
- Item *new_item= NULL;
if (item->basic_const_item())
return; // Can't be better
+
+ Item *new_item= NULL;
Item_result res_type=item_cmp_type(comp_item->cmp_type(), item->cmp_type());
char *name=item->name; // Alloced by sql_alloc
+ MEM_ROOT *mem_root= thd->mem_root;
switch (res_type) {
case TIME_RESULT:
@@ -8589,7 +8646,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
/* the following call creates a constant and puts it in new_item */
get_datetime_value(thd, &ref_copy, &new_item, comp_item, &is_null);
if (is_null)
- new_item= new Item_null(thd, name);
+ new_item= new (mem_root) Item_null(thd, name);
break;
}
case STRING_RESULT:
@@ -8598,12 +8655,12 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
String tmp(buff,sizeof(buff),&my_charset_bin),*result;
result=item->val_str(&tmp);
if (item->null_value)
- new_item= new Item_null(thd, name);
+ new_item= new (mem_root) Item_null(thd, name);
else
{
uint length= result->length();
char *tmp_str= sql_strmake(result->ptr(), length);
- new_item= new Item_string(thd, name, tmp_str, length, result->charset());
+ new_item= new (mem_root) Item_string(thd, name, tmp_str, length, result->charset());
}
break;
}
@@ -8612,8 +8669,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
longlong result=item->val_int();
uint length=item->max_length;
bool null_value=item->null_value;
- new_item= (null_value ? (Item*) new Item_null(thd, name) :
- (Item*) new Item_int(thd, name, result, length));
+ new_item= (null_value ? (Item*) new (mem_root) Item_null(thd, name) :
+ (Item*) new (mem_root) Item_int(thd, name, result, length));
break;
}
case ROW_RESULT:
@@ -8651,8 +8708,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
double result= item->val_real();
uint length=item->max_length,decimals=item->decimals;
bool null_value=item->null_value;
- new_item= (null_value ? (Item*) new Item_null(thd, name) : (Item*)
- new Item_float(thd, name, result, decimals, length));
+ new_item= (null_value ? (Item*) new (mem_root) Item_null(thd, name) : (Item*)
+ new (mem_root) Item_float(thd, name, result, decimals, length));
break;
}
case DECIMAL_RESULT:
@@ -8662,8 +8719,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
uint length= item->max_length, decimals= item->decimals;
bool null_value= item->null_value;
new_item= (null_value ?
- (Item*) new Item_null(thd, name) :
- (Item*) new Item_decimal(thd, name, result, length, decimals));
+ (Item*) new (mem_root) Item_null(thd, name) :
+ (Item*) new (mem_root) Item_decimal(thd, name, result, length, decimals));
break;
}
case IMPOSSIBLE_RESULT:
@@ -8803,21 +8860,23 @@ Item_cache* Item_cache::get_cache(THD *thd, const Item *item)
@return cache item
*/
-Item_cache* Item_cache::get_cache(THD *thd, const Item *item, const Item_result type)
+Item_cache* Item_cache::get_cache(THD *thd, const Item *item,
+ const Item_result type)
{
+ MEM_ROOT *mem_root= thd->mem_root;
switch (type) {
case INT_RESULT:
- return new Item_cache_int(thd, item->field_type());
+ return new (mem_root) Item_cache_int(thd, item->field_type());
case REAL_RESULT:
- return new Item_cache_real(thd);
+ return new (mem_root) Item_cache_real(thd);
case DECIMAL_RESULT:
- return new Item_cache_decimal(thd);
+ return new (mem_root) Item_cache_decimal(thd);
case STRING_RESULT:
- return new Item_cache_str(thd, item);
+ return new (mem_root) Item_cache_str(thd, item);
case ROW_RESULT:
- return new Item_cache_row(thd);
+ return new (mem_root) Item_cache_row(thd);
case TIME_RESULT:
- return new Item_cache_temporal(thd, item->field_type());
+ return new (mem_root) Item_cache_temporal(thd, item->field_type());
case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0);
break;
@@ -8922,7 +8981,8 @@ int Item_cache_int::save_in_field(Field *field, bool no_conversions)
}
-Item_cache_temporal::Item_cache_temporal(THD *thd, enum_field_types field_type_arg):
+Item_cache_temporal::Item_cache_temporal(THD *thd,
+ enum_field_types field_type_arg):
Item_cache_int(thd, field_type_arg)
{
if (mysql_type_to_time_type(cached_field_type) == MYSQL_TIMESTAMP_ERROR)
@@ -9050,6 +9110,15 @@ void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg)
}
+Item *Item_cache_temporal::clone_item(THD *thd)
+{
+ Item_cache_temporal *item= new (thd->mem_root)
+ Item_cache_temporal(thd, cached_field_type);
+ item->store_packed(value, example);
+ return item;
+}
+
+
bool Item_cache_real::cache_value()
{
if (!example)
diff --git a/sql/item.h b/sql/item.h
index 1d0c535e43f..dfbef6ad085 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -610,9 +610,9 @@ class Item: public Type_std_attributes
*/
uint join_tab_idx;
+ static void *operator new(size_t size);
+
public:
- static void *operator new(size_t size) throw ()
- { return sql_alloc(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,size_t size) { TRASH(ptr, size); }
@@ -2454,7 +2454,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
bool basic_const_item() const { return 1; }
- Item *clone_item(THD *thd) { return new Item_null(thd, name); }
+ Item *clone_item(THD *thd);
bool is_null() { return 1; }
virtual inline void print(String *str, enum_query_type query_type)
@@ -2663,7 +2663,7 @@ public:
String *val_str(String*);
int save_in_field(Field *field, bool no_conversions);
bool basic_const_item() const { return 1; }
- Item *clone_item(THD *thd) { return new Item_int(thd, name, value, max_length); }
+ Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
Item_num *neg(THD *thd) { value= -value; return this; }
uint decimal_precision() const
@@ -2684,8 +2684,7 @@ public:
double val_real()
{ DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
String *val_str(String*);
- Item *clone_item(THD *thd)
- { return new Item_uint(thd, name, value, max_length); }
+ Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
Item_num *neg(THD *thd);
uint decimal_precision() const { return max_length; }
@@ -2729,10 +2728,7 @@ public:
my_decimal *val_decimal(my_decimal *val) { return &decimal_value; }
int save_in_field(Field *field, bool no_conversions);
bool basic_const_item() const { return 1; }
- Item *clone_item(THD *thd)
- {
- return new Item_decimal(thd, name, &decimal_value, decimals, max_length);
- }
+ Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
Item_num *neg(THD *thd)
{
@@ -2788,8 +2784,7 @@ public:
String *val_str(String*);
my_decimal *val_decimal(my_decimal *);
bool basic_const_item() const { return 1; }
- Item *clone_item(THD *thd)
- { return new Item_float(thd, name, value, decimals, max_length); }
+ Item *clone_item(THD *thd);
Item_num *neg(THD *thd) { value= -value; return this; }
virtual void print(String *str, enum_query_type query_type);
bool eq(const Item *item, bool binary_cmp) const
@@ -2914,11 +2909,7 @@ public:
{
return str_eq(&str_value, item, binary_cmp);
}
- Item *clone_item(THD *thd)
- {
- return new Item_string(thd, name, str_value.ptr(),
- str_value.length(), collation.collation);
- }
+ Item *clone_item(THD *thd);
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
return const_charset_converter(thd, tocs, true);
@@ -4849,12 +4840,7 @@ public:
is a constant and need not be optimized further.
Important when storing packed datetime values.
*/
- Item *clone_item(THD *thd)
- {
- Item_cache_temporal *item= new Item_cache_temporal(thd, cached_field_type);
- item->store_packed(value, example);
- return item;
- }
+ Item *clone_item(THD *thd);
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 564b445ed09..c2cf4e78271 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -442,7 +442,7 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item,
if (0 == field_cmp)
{
- Item *tmp= new Item_int_with_ref(thd, field->val_int(), *item,
+ Item *tmp= new (thd->mem_root) Item_int_with_ref(thd, field->val_int(), *item,
MY_TEST(field->flags & UNSIGNED_FLAG));
if (tmp)
thd->change_item_tree(item, tmp);
@@ -878,7 +878,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
{
Query_arena backup;
Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup);
- Item_cache_temporal *cache= new Item_cache_temporal(thd, f_type);
+ Item_cache_temporal *cache= new (thd->mem_root) Item_cache_temporal(thd, f_type);
if (save_arena)
thd->set_query_arena(save_arena);
@@ -3475,6 +3475,12 @@ uchar *in_string::get_value(Item *item)
return (uchar*) item->val_str(&tmp);
}
+Item *in_string::create_item(THD *thd)
+{
+ return new (thd->mem_root) Item_string_for_in_vector(thd, collation);
+}
+
+
in_row::in_row(uint elements, Item * item)
{
base= (char*) new cmp_item_row[count= elements];
@@ -3531,6 +3537,16 @@ uchar *in_longlong::get_value(Item *item)
return (uchar*) &tmp;
}
+Item *in_longlong::create_item(THD *thd)
+{
+ /*
+ We're created a signed INT, this may not be correct in
+ general case (see BUG#19342).
+ */
+ return new (thd->mem_root) Item_int(thd, (longlong)0);
+}
+
+
void in_datetime::set(uint pos,Item *item)
{
Item **tmp_item= &item;
@@ -3552,6 +3568,12 @@ uchar *in_datetime::get_value(Item *item)
return (uchar*) &tmp;
}
+Item *in_datetime::create_item(THD *thd)
+{
+ return new (thd->mem_root) Item_datetime(thd);
+}
+
+
in_double::in_double(uint elements)
:in_vector(elements,sizeof(double),(qsort2_cmp) cmp_double, 0)
{}
@@ -3569,6 +3591,11 @@ uchar *in_double::get_value(Item *item)
return (uchar*) &tmp;
}
+Item *in_double::create_item(THD *thd)
+{
+ return new (thd->mem_root) Item_float(thd, 0.0, 0);
+}
+
in_decimal::in_decimal(uint elements)
:in_vector(elements, sizeof(my_decimal),(qsort2_cmp) cmp_decimal, 0)
@@ -3596,6 +3623,11 @@ uchar *in_decimal::get_value(Item *item)
return (uchar *)result;
}
+Item *in_decimal::create_item(THD *thd)
+{
+ return new (thd->mem_root) Item_decimal(thd, 0, FALSE);
+}
+
cmp_item* cmp_item::get_comparator(Item_result type, Item *warn_item,
CHARSET_INFO *cs)
@@ -4220,6 +4252,15 @@ Item_cond::Item_cond(THD *thd, Item_cond *item)
}
+Item *Item_cond_and::copy_andor_structure(THD *thd)
+{
+ Item_cond_and *item;
+ if ((item= new (thd->mem_root) Item_cond_and(thd, this)))
+ item->copy_andor_arguments(thd, this);
+ return item;
+}
+
+
void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item)
{
List_iterator_fast<Item> li(item->list);
@@ -4284,7 +4325,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
Query_arena backup, *arena;
Item *new_item;
arena= thd->activate_stmt_arena_if_needed(&backup);
- if ((new_item= new Item_func_ne(thd, item, new Item_int(thd, 0, 1))))
+ if ((new_item= new (thd->mem_root) Item_func_ne(thd, item, new (thd->mem_root) Item_int(thd, 0, 1))))
li.replace(item= new_item);
if (arena)
thd->restore_active_arena(arena, &backup);
@@ -4606,7 +4647,7 @@ void Item_cond::neg_arguments(THD *thd)
Item *new_item= item->neg_transformer(thd);
if (!new_item)
{
- if (!(new_item= new Item_func_not(thd, item)))
+ if (!(new_item= new (thd->mem_root) Item_func_not(thd, item)))
return; // Fatal OEM error
}
(void) li.replace(new_item);
@@ -4624,7 +4665,6 @@ void Item_cond_and::mark_as_condition_AND_part(TABLE_LIST *embedding)
}
}
-
/**
Evaluation of AND(expr, expr, expr ...).
@@ -4682,6 +4722,15 @@ longlong Item_cond_or::val_int()
return 0;
}
+Item *Item_cond_or::copy_andor_structure(THD *thd)
+{
+ Item_cond_or *item;
+ if ((item= new (thd->mem_root) Item_cond_or(thd, this)))
+ item->copy_andor_arguments(thd, this);
+ return item;
+}
+
+
/**
Create an AND expression from two expressions.
@@ -4709,7 +4758,7 @@ Item *and_expressions(THD *thd, Item *a, Item *b, Item **org_item)
if (a == *org_item)
{
Item_cond *res;
- if ((res= new Item_cond_and(thd, a, (Item*) b)))
+ if ((res= new (thd->mem_root) Item_cond_and(thd, a, (Item*) b)))
{
res->used_tables_cache= a->used_tables() | b->used_tables();
res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables();
@@ -5527,7 +5576,7 @@ bool Item_func_not::fix_fields(THD *thd, Item **ref)
Item *new_item;
bool rc= TRUE;
arena= thd->activate_stmt_arena_if_needed(&backup);
- if ((new_item= new Item_func_eq(thd, args[0], new Item_int(thd, 0, 1))))
+ if ((new_item= new (thd->mem_root) Item_func_eq(thd, args[0], new (thd->mem_root) Item_int(thd, 0, 1))))
{
new_item->name= name;
rc= (*ref= new_item)->fix_fields(thd, ref);
@@ -5579,7 +5628,7 @@ Item *Item_func_xor::neg_transformer(THD *thd)
*/
Item *Item_func_isnull::neg_transformer(THD *thd)
{
- Item *item= new Item_func_isnotnull(thd, args[0]);
+ Item *item= new (thd->mem_root) Item_func_isnotnull(thd, args[0]);
return item;
}
@@ -5589,7 +5638,7 @@ Item *Item_func_isnull::neg_transformer(THD *thd)
*/
Item *Item_func_isnotnull::neg_transformer(THD *thd)
{
- Item *item= new Item_func_isnull(thd, args[0]);
+ Item *item= new (thd->mem_root) Item_func_isnull(thd, args[0]);
return item;
}
@@ -5598,7 +5647,7 @@ Item *Item_cond_and::neg_transformer(THD *thd) /* NOT(a AND b AND ...) -> */
/* NOT a OR NOT b OR ... */
{
neg_arguments(thd);
- Item *item= new Item_cond_or(thd, list);
+ Item *item= new (thd->mem_root) Item_cond_or(thd, list);
return item;
}
@@ -5607,7 +5656,7 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
/* NOT a AND NOT b AND ... */
{
neg_arguments(thd);
- Item *item= new Item_cond_and(thd, list);
+ Item *item= new (thd->mem_root) Item_cond_and(thd, list);
return item;
}
@@ -5615,7 +5664,7 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
Item *Item_func_nop_all::neg_transformer(THD *thd)
{
/* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */
- Item_func_not_all *new_item= new Item_func_not_all(thd, args[0]);
+ Item_func_not_all *new_item= new (thd->mem_root) Item_func_not_all(thd, args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
allany->create_comp_func(FALSE);
allany->all= !allany->all;
@@ -5626,7 +5675,7 @@ Item *Item_func_nop_all::neg_transformer(THD *thd)
Item *Item_func_not_all::neg_transformer(THD *thd)
{
/* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */
- Item_func_nop_all *new_item= new Item_func_nop_all(thd, args[0]);
+ Item_func_nop_all *new_item= new (thd->mem_root) Item_func_nop_all(thd, args[0]);
Item_allany_subselect *allany= (Item_allany_subselect*)args[0];
allany->all= !allany->all;
allany->create_comp_func(TRUE);
@@ -5636,37 +5685,37 @@ Item *Item_func_not_all::neg_transformer(THD *thd)
Item *Item_func_eq::negated_item(THD *thd) /* a = b -> a != b */
{
- return new Item_func_ne(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_ne(thd, args[0], args[1]);
}
Item *Item_func_ne::negated_item(THD *thd) /* a != b -> a = b */
{
- return new Item_func_eq(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_eq(thd, args[0], args[1]);
}
Item *Item_func_lt::negated_item(THD *thd) /* a < b -> a >= b */
{
- return new Item_func_ge(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_ge(thd, args[0], args[1]);
}
Item *Item_func_ge::negated_item(THD *thd) /* a >= b -> a < b */
{
- return new Item_func_lt(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_lt(thd, args[0], args[1]);
}
Item *Item_func_gt::negated_item(THD *thd) /* a > b -> a <= b */
{
- return new Item_func_le(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_le(thd, args[0], args[1]);
}
Item *Item_func_le::negated_item(THD *thd) /* a <= b -> a > b */
{
- return new Item_func_gt(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_gt(thd, args[0], args[1]);
}
/**
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 83f3afaa009..fc1fe1bd344 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -971,10 +971,7 @@ public:
~in_string();
void set(uint pos,Item *item);
uchar *get_value(Item *item);
- Item* create_item(THD *thd)
- {
- return new Item_string_for_in_vector(thd, collation);
- }
+ Item* create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
String *str=((String*) base)+pos;
@@ -1001,15 +998,7 @@ public:
in_longlong(uint elements);
void set(uint pos,Item *item);
uchar *get_value(Item *item);
-
- Item* create_item(THD *thd)
- {
- /*
- We're created a signed INT, this may not be correct in
- general case (see BUG#19342).
- */
- return new Item_int(thd, (longlong)0);
- }
+ Item* create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
((Item_int*) item)->value= ((packed_longlong*) base)[pos].val;
@@ -1042,10 +1031,7 @@ public:
lval_cache(0) {};
void set(uint pos,Item *item);
uchar *get_value(Item *item);
- Item* create_item(THD *thd)
- {
- return new Item_datetime(thd);
- }
+ Item *create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
packed_longlong *val= reinterpret_cast<packed_longlong*>(base)+pos;
@@ -1063,10 +1049,7 @@ public:
in_double(uint elements);
void set(uint pos,Item *item);
uchar *get_value(Item *item);
- Item *create_item(THD *thd)
- {
- return new Item_float(thd, 0.0, 0);
- }
+ Item *create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
((Item_float*)item)->value= ((double*) base)[pos];
@@ -1082,10 +1065,7 @@ public:
in_decimal(uint elements);
void set(uint pos, Item *item);
uchar *get_value(Item *item);
- Item *create_item(THD *thd)
- {
- return new Item_decimal(thd, 0, FALSE);
- }
+ Item *create_item(THD *thd);
void value_to_item(uint pos, Item *item)
{
my_decimal *dec= ((my_decimal *)base) + pos;
@@ -2178,13 +2158,7 @@ public:
const char *func_name() const { return "and"; }
table_map not_null_tables() const
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
- Item* copy_andor_structure(THD *thd)
- {
- Item_cond_and *item;
- if ((item= new Item_cond_and(thd, this)))
- item->copy_andor_arguments(thd, this);
- return item;
- }
+ Item *copy_andor_structure(THD *thd);
Item *neg_transformer(THD *thd);
void mark_as_condition_AND_part(TABLE_LIST *embedding);
virtual uint exists2in_reserved_items() { return list.elements; };
@@ -2217,13 +2191,7 @@ public:
longlong val_int();
const char *func_name() const { return "or"; }
table_map not_null_tables() const { return and_tables_cache; }
- Item* copy_andor_structure(THD *thd)
- {
- Item_cond_or *item;
- if ((item= new Item_cond_or(thd, this)))
- item->copy_andor_arguments(thd, this);
- return item;
- }
+ Item *copy_andor_structure(THD *thd);
Item *neg_transformer(THD *thd);
};
@@ -2253,16 +2221,6 @@ inline bool is_cond_or(Item *item)
return (cond_item->functype() == Item_func::COND_OR_FUNC);
}
-/* Some useful inline functions */
-
-inline Item *and_conds(THD *thd, Item *a, Item *b)
-{
- if (!b) return a;
- if (!a) return b;
- return new Item_cond_and(thd, a, b);
-}
-
-
Item *and_expressions(Item *a, Item *b, Item **org_item);
longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
diff --git a/sql/item_create.cc b/sql/item_create.cc
index e7bdc95a3dd..8c6d02623c6 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -5234,7 +5234,7 @@ Create_func_round::create_native(THD *thd, LEX_STRING name,
case 1:
{
Item *param_1= item_list->pop();
- Item *i0 = new (thd->mem_root) Item_int(thd, (char*)"0", 0, 1);
+ Item *i0= new (thd->mem_root) Item_int(thd, (char*)"0", 0, 1);
func= new (thd->mem_root) Item_func_round(thd, param_1, i0, 0);
break;
}
@@ -6397,7 +6397,7 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums)
for (uint i= 0; (key= it++); i++)
{
dfs[i].key= key;
- dfs[i].value= new Item_null(thd);
+ dfs[i].value= new (thd->mem_root) Item_null(thd);
dfs[i].type= DYN_COL_INT;
args->push_back(dfs[i].key);
args->push_back(dfs[i].value);
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3da1e62a6d2..52f5a3709c2 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -727,7 +727,7 @@ void Item_func::signal_divide_by_null()
Item *Item_func::get_tmp_table_item(THD *thd)
{
if (!with_sum_func && !const_item())
- return new Item_field(thd, result_field);
+ return new (thd->mem_root) Item_field(thd, result_field);
return copy_or_same(thd);
}
@@ -5534,8 +5534,10 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command,
LEX *sav_lex= thd->lex, lex_tmp;
thd->lex= &lex_tmp;
lex_start(thd);
- tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(thd, name,
- new Item_null(thd))));
+ tmp_var_list.push_back(new (thd->mem_root)
+ set_var_user(new (thd->mem_root)
+ Item_func_set_user_var(thd, name,
+ new (thd->mem_root) Item_null(thd))));
/* Create the variable */
if (sql_set_variables(thd, &tmp_var_list, false))
{
@@ -5699,7 +5701,7 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const
bool Item_func_get_user_var::set_value(THD *thd,
sp_rcontext * /*ctx*/, Item **it)
{
- Item_func_set_user_var *suv= new Item_func_set_user_var(thd, get_name(), *it);
+ Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, get_name(), *it);
/*
Item_func_set_user_var is not fixed after construction, call
fix_fields().
@@ -6114,10 +6116,10 @@ void Item_func_match::init_search(THD *thd, bool no_order)
if (key == NO_SUCH_KEY)
{
List<Item> fields;
- fields.push_back(new Item_string(thd, " ", 1, cmp_collation.collation));
+ fields.push_back(new (thd->mem_root) Item_string(thd, " ", 1, cmp_collation.collation));
for (uint i= 1; i < arg_count; i++)
fields.push_back(args[i]);
- concat_ws= new Item_func_concat_ws(thd, fields);
+ concat_ws= new (thd->mem_root) Item_func_concat_ws(thd, fields);
/*
Above function used only to get value and do not need fix_fields for it:
Item_string - basic constant
@@ -6465,7 +6467,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
set_if_smaller(component_name->length, MAX_SYS_VAR_LENGTH);
- return new Item_func_get_system_var(thd, var, var_type, component_name,
+ return new (thd->mem_root) Item_func_get_system_var(thd, var, var_type, component_name,
NULL, 0);
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index ba283a11563..a93b17b826a 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -875,7 +875,7 @@ bool Item_subselect::const_item() const
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
{
if (!with_sum_func && !const_item())
- return new Item_field(thd_arg, result_field);
+ return new (thd->mem_root) Item_field(thd_arg, result_field);
return copy_or_same(thd_arg);
}
@@ -1013,7 +1013,7 @@ void Item_maxmin_subselect::no_rows_in_result()
*/
if (parsing_place != SELECT_LIST || const_item())
return;
- value= Item_cache::get_cache(thd, new Item_null(thd));
+ value= Item_cache::get_cache(thd, new (thd->mem_root) Item_null(thd));
null_value= 0;
was_values= 0;
make_const();
@@ -1031,7 +1031,7 @@ void Item_singlerow_subselect::no_rows_in_result()
*/
if (parsing_place != SELECT_LIST || const_item())
return;
- value= Item_cache::get_cache(thd, new Item_null(thd));
+ value= Item_cache::get_cache(thd, new (thd->mem_root) Item_null(thd));
reset();
make_const();
}
@@ -1448,7 +1448,7 @@ void Item_exists_subselect::fix_length_and_dec()
an IN always requires LIMIT 1)
*/
thd->change_item_tree(&unit->global_parameters()->select_limit,
- new Item_int(thd, (int32) 1));
+ new (thd->mem_root) Item_int(thd, (int32) 1));
DBUG_PRINT("info", ("Set limit to 1"));
DBUG_VOID_RETURN;
}
@@ -1819,7 +1819,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
As far as Item_in_optimizer does not substitute itself on fix_fields
we can use same item for all selects.
*/
- expr= new Item_direct_ref(thd, &select_lex->context,
+ expr= new (thd->mem_root) Item_direct_ref(thd, &select_lex->context,
(Item**)optimizer->get_cache(),
(char *)"<no matter>",
(char *)in_left_expr_name);
@@ -1887,7 +1887,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
(ALL && (> || =>)) || (ANY && (< || =<))
for ALL condition is inverted
*/
- item= new Item_sum_max(thd, *select_lex->ref_pointer_array);
+ item= new (thd->mem_root) Item_sum_max(thd, *select_lex->ref_pointer_array);
}
else
{
@@ -1895,7 +1895,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
(ALL && (< || =<)) || (ANY && (> || =>))
for ALL condition is inverted
*/
- item= new Item_sum_min(thd, *select_lex->ref_pointer_array);
+ item= new (thd->mem_root) Item_sum_min(thd, *select_lex->ref_pointer_array);
}
if (upper_item)
upper_item->set_sum_test(item);
@@ -1936,7 +1936,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
else
{
Item_maxmin_subselect *item;
- subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
+ subs= item= new (thd->mem_root) Item_maxmin_subselect(thd, this, select_lex, func->l_op());
if (upper_item)
upper_item->set_sub_test(item);
/*
@@ -2056,7 +2056,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
We can encounter "NULL IN (SELECT ...)". Wrap the added condition
within a trig_cond.
*/
- item= new Item_func_trig_cond(thd, item, get_cond_guard(0));
+ item= new (thd->mem_root) Item_func_trig_cond(thd, item, get_cond_guard(0));
}
if (!join_having)
@@ -2300,42 +2300,50 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true);
Item *item_eq=
- new Item_func_eq(thd, new
- Item_direct_ref(thd, &select_lex->context,
- (*optimizer->get_cache())->
- addr(i),
- (char *)"<no matter>",
- (char *)in_left_expr_name),
- new
+ new (thd->mem_root)
+ Item_func_eq(thd, new (thd->mem_root)
+ Item_direct_ref(thd, &select_lex->context,
+ (*optimizer->get_cache())->
+ addr(i),
+ (char *)"<no matter>",
+ (char *)in_left_expr_name),
+ new (thd->mem_root)
+ Item_ref(thd, &select_lex->context,
+ select_lex->ref_pointer_array + i,
+ (char *)"<no matter>",
+ (char *)"<list ref>"));
+ Item *item_isnull=
+ new (thd->mem_root)
+ Item_func_isnull(thd,
+ new (thd->mem_root)
Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array + i,
+ select_lex->ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>"));
- Item *item_isnull=
- new Item_func_isnull(thd, new
- Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array+i,
- (char *)"<no matter>",
- (char *)"<list ref>"));
- Item *col_item= new Item_cond_or(thd, item_eq, item_isnull);
+ Item *col_item= new (thd->mem_root)
+ Item_cond_or(thd, item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
- if (!(col_item= new Item_func_trig_cond(thd, col_item, get_cond_guard(i))))
+ if (!(col_item= new (thd->mem_root)
+ Item_func_trig_cond(thd, col_item, get_cond_guard(i))))
DBUG_RETURN(true);
}
*having_item= and_items(thd, *having_item, col_item);
Item *item_nnull_test=
- new Item_is_not_null_test(thd, this,
- new Item_ref(thd, &select_lex->context,
- select_lex->
- ref_pointer_array + i,
- (char *)"<no matter>",
- (char *)"<list ref>"));
+ new (thd->mem_root)
+ Item_is_not_null_test(thd, this,
+ new (thd->mem_root)
+ Item_ref(thd, &select_lex->context,
+ select_lex->
+ ref_pointer_array + i,
+ (char *)"<no matter>",
+ (char *)"<list ref>"));
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
if (!(item_nnull_test=
- new Item_func_trig_cond(thd, item_nnull_test, get_cond_guard(i))))
+ new (thd->mem_root)
+ Item_func_trig_cond(thd, item_nnull_test, get_cond_guard(i))))
DBUG_RETURN(true);
}
item_having_part2= and_items(thd, item_having_part2, item_nnull_test);
@@ -2356,51 +2364,56 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true);
- item=
- new Item_func_eq(thd, new
- Item_direct_ref(thd, &select_lex->context,
- (*optimizer->get_cache())->
- addr(i),
- (char *)"<no matter>",
- (char *)in_left_expr_name),
- new
- Item_direct_ref(thd, &select_lex->context,
- select_lex->
- ref_pointer_array+i,
- (char *)"<no matter>",
- (char *)"<list ref>"));
+ item= new (thd->mem_root)
+ Item_func_eq(thd,
+ new (thd->mem_root)
+ Item_direct_ref(thd, &select_lex->context,
+ (*optimizer->get_cache())->
+ addr(i),
+ (char *)"<no matter>",
+ (char *)in_left_expr_name),
+ new (thd->mem_root)
+ Item_direct_ref(thd, &select_lex->context,
+ select_lex->
+ ref_pointer_array+i,
+ (char *)"<no matter>",
+ (char *)"<list ref>"));
if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null)
{
Item *having_col_item=
- new Item_is_not_null_test(thd, this,
- new
- Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array + i,
- (char *)"<no matter>",
- (char *)"<list ref>"));
+ new (thd->mem_root)
+ Item_is_not_null_test(thd, this,
+ new (thd->mem_root)
+ Item_ref(thd, &select_lex->context,
+ select_lex->ref_pointer_array + i,
+ (char *)"<no matter>",
+ (char *)"<list ref>"));
- item_isnull= new
- Item_func_isnull(thd, new
+ item_isnull= new (thd->mem_root)
+ Item_func_isnull(thd,
+ new (thd->mem_root)
Item_direct_ref(thd, &select_lex->context,
select_lex->
ref_pointer_array+i,
(char *)"<no matter>",
(char *)"<list ref>"));
- item= new Item_cond_or(thd, item, item_isnull);
+ item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
if (left_expr->element_index(i)->maybe_null)
{
- if (!(item= new Item_func_trig_cond(thd, item, get_cond_guard(i))))
+ if (!(item= new (thd->mem_root)
+ Item_func_trig_cond(thd, item, get_cond_guard(i))))
DBUG_RETURN(true);
- if (!(having_col_item=
- new Item_func_trig_cond(thd, having_col_item, get_cond_guard(i))))
+ if (!(having_col_item= new (thd->mem_root)
+ Item_func_trig_cond(thd, having_col_item, get_cond_guard(i))))
DBUG_RETURN(true);
}
*having_item= and_items(thd, *having_item, having_col_item);
}
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{
- if (!(item= new Item_func_trig_cond(thd, item, get_cond_guard(i))))
+ if (!(item= new (thd->mem_root)
+ Item_func_trig_cond(thd, item, get_cond_guard(i))))
DBUG_RETURN(true);
}
*where_item= and_items(thd, *where_item, item);
@@ -2567,7 +2580,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
join_arg->having= select_lex->having;
}
join_arg->thd->change_item_tree(&unit->global_parameters()->select_limit,
- new Item_int(thd, (int32) 1));
+ new (thd->mem_root) Item_int(thd, (int32) 1));
unit->select_limit_cnt= 1;
DBUG_RETURN(false);
@@ -2594,7 +2607,7 @@ bool Item_exists_subselect::select_prepare_to_be_in()
Query_arena *arena, backup;
bool result;
arena= thd->activate_stmt_arena_if_needed(&backup);
- result= (!(optimizer= new Item_in_optimizer(thd, new Item_int(thd, 1), this)));
+ result= (!(optimizer= new (thd->mem_root) Item_in_optimizer(thd, new (thd->mem_root) Item_int(thd, 1), this)));
if (arena)
thd->restore_active_arena(arena, &backup);
if (result)
@@ -2814,13 +2827,17 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
/* remove the parts from condition */
if (!upper_not || !local_field->maybe_null)
- *eq_ref= new Item_int(thd, 1);
+ *eq_ref= new (thd->mem_root) Item_int(thd, 1);
else
{
- *eq_ref= new Item_func_isnotnull(thd,
- new Item_field(thd,
- ((Item_field*)(local_field->real_item()))->context,
- ((Item_field*)(local_field->real_item()))->field));
+ *eq_ref= new (thd->mem_root)
+ Item_func_isnotnull(thd,
+ new (thd->mem_root)
+ Item_field(thd,
+ ((Item_field*)(local_field->
+ real_item()))->context,
+ ((Item_field*)(local_field->
+ real_item()))->field));
if((*eq_ref)->fix_fields(thd, (Item **)eq_ref))
{
res= TRUE;
@@ -2840,7 +2857,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
left_exp= outer_exp;
else
{
- if (!(left_exp= new Item_row(thd, outer)))
+ if (!(left_exp= new (thd->mem_root) Item_row(thd, outer)))
{
res= TRUE;
goto out;
@@ -2882,10 +2899,11 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
As far as Item_ref_in_optimizer do not substitute itself on fix_fields
we can use same item for all selects.
*/
- in_subs->expr= new Item_direct_ref(thd, &first_select->context,
- (Item**)optimizer->get_cache(),
- (char *)"<no matter>",
- (char *)in_left_expr_name);
+ in_subs->expr= new (thd->mem_root)
+ Item_direct_ref(thd, &first_select->context,
+ (Item**)optimizer->get_cache(),
+ (char *)"<no matter>",
+ (char *)in_left_expr_name);
if (in_subs->fix_fields(thd, optimizer->arguments() + 1))
{
res= TRUE;
@@ -2947,14 +2965,17 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
if (eqs.elements() == 1)
{
exp= (optimizer->arguments()[0]->maybe_null ?
- (Item*)
- new Item_cond_and(thd,
- new Item_func_isnotnull(thd,
- new Item_direct_ref(thd, &unit->outer_select()->context,
- optimizer->arguments(),
- (char *)"<no matter>",
- (char *)exists_outer_expr_name)),
- optimizer) :
+ (Item*) new (thd->mem_root)
+ Item_cond_and(thd,
+ new (thd->mem_root)
+ Item_func_isnotnull(thd,
+ new (thd->mem_root)
+ Item_direct_ref(thd,
+ &unit->outer_select()->context,
+ optimizer->arguments(),
+ (char *)"<no matter>",
+ (char *)exists_outer_expr_name)),
+ optimizer) :
(Item *)optimizer);
}
else
@@ -2970,18 +2991,20 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg)
if (optimizer->arguments()[0]->maybe_null)
{
and_list->
- push_front(
- new Item_func_isnotnull(thd,
- new Item_direct_ref(thd, &unit->outer_select()->context,
- optimizer->arguments()[0]->addr(i),
- (char *)"<no matter>",
- (char *)exists_outer_expr_name)));
+ push_front(new (thd->mem_root)
+ Item_func_isnotnull(thd,
+ new (thd->mem_root)
+ Item_direct_ref(thd,
+ &unit->outer_select()->context,
+ optimizer->arguments()[0]->addr(i),
+ (char *)"<no matter>",
+ (char *)exists_outer_expr_name)));
}
}
if (and_list->elements > 0)
{
and_list->push_front(optimizer);
- exp= new Item_cond_and(thd, *and_list);
+ exp= new (thd->mem_root) Item_cond_and(thd, *and_list);
}
else
exp= optimizer;
@@ -3056,7 +3079,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
arena= thd->activate_stmt_arena_if_needed(&backup);
if (!optimizer)
{
- result= (!(optimizer= new Item_in_optimizer(thd, left_expr, this)));
+ result= (!(optimizer= new (thd->mem_root) Item_in_optimizer(thd, left_expr, this)));
if (result)
goto out;
}
@@ -3122,7 +3145,7 @@ bool Item_exists_subselect::fix_fields(THD *thd, Item **ref)
{
DBUG_ENTER("Item_exists_subselect::fix_fields");
if (exists_transformed)
- DBUG_RETURN( !( (*ref)= new Item_int(thd, 1)));
+ DBUG_RETURN( !( (*ref)= new (thd->mem_root) Item_int(thd, 1)));
DBUG_RETURN(Item_subselect::fix_fields(thd, ref));
}
@@ -3134,7 +3157,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
DBUG_ENTER("Item_in_subselect::fix_fields");
if (test_strategy(SUBS_SEMI_JOIN))
- DBUG_RETURN( !( (*ref)= new Item_int(thd, 1)) );
+ DBUG_RETURN( !( (*ref)= new (thd->mem_root) Item_int(thd, 1)) );
/*
Check if the outer and inner IN operands match in those cases when we
@@ -4888,7 +4911,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
DBUG_ENTER("subselect_hash_sj_engine::make_semi_join_conds");
DBUG_ASSERT(semi_join_conds == NULL);
- if (!(semi_join_conds= new Item_cond_and(thd)))
+ if (!(semi_join_conds= new (thd->mem_root) Item_cond_and(thd)))
DBUG_RETURN(TRUE);
if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST))))
@@ -4912,8 +4935,8 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
/* Item for the corresponding field from the materialized temp table. */
Item_field *right_col_item;
- if (!(right_col_item= new Item_field(thd, context, tmp_table->field[i])) ||
- !(eq_cond= new Item_func_eq(thd, item_in->left_expr->element_index(i),
+ if (!(right_col_item= new (thd->mem_root) Item_field(thd, context, tmp_table->field[i])) ||
+ !(eq_cond= new (thd->mem_root) Item_func_eq(thd, item_in->left_expr->element_index(i),
right_col_item)) ||
(((Item_cond_and*)semi_join_conds)->add(eq_cond)))
{
@@ -5520,9 +5543,9 @@ bool Ordered_key::init(MY_BITMAP *columns_to_index)
{
if (!bitmap_is_set(columns_to_index, i))
continue;
- cur_tmp_field= new Item_field(thd, tbl->field[i]);
+ cur_tmp_field= new (thd->mem_root) Item_field(thd, tbl->field[i]);
/* Create the predicate (tmp_column[i] < outer_ref[i]). */
- fn_less_than= new Item_func_lt(thd, cur_tmp_field,
+ fn_less_than= new (thd->mem_root) Item_func_lt(thd, cur_tmp_field,
search_key->element_index(i));
fn_less_than->fix_fields(thd, (Item**) &fn_less_than);
key_columns[cur_key_col]= cur_tmp_field;
@@ -5554,9 +5577,9 @@ bool Ordered_key::init(int col_idx)
key_columns= (Item_field**) thd->alloc(sizeof(Item_field*));
compare_pred= (Item_func_lt**) thd->alloc(sizeof(Item_func_lt*));
- key_columns[0]= new Item_field(thd, tbl->field[col_idx]);
+ key_columns[0]= new (thd->mem_root) Item_field(thd, tbl->field[col_idx]);
/* Create the predicate (tmp_column[i] < outer_ref[i]). */
- compare_pred[0]= new Item_func_lt(thd, key_columns[0],
+ compare_pred[0]= new (thd->mem_root) Item_func_lt(thd, key_columns[0],
search_key->element_index(col_idx));
compare_pred[0]->fix_fields(thd, (Item**)&compare_pred[0]);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index e6748263072..e20b47c67d6 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -490,7 +490,7 @@ Item *Item_sum::get_tmp_table_item(THD *thd)
if (arg->type() == Item::FIELD_ITEM)
((Item_field*) arg)->field= result_field_tmp++;
else
- sum_item->args[i]= new Item_field(thd, result_field_tmp++);
+ sum_item->args[i]= new (thd->mem_root) Item_field(thd, result_field_tmp++);
}
}
}
@@ -610,6 +610,10 @@ void Item_sum::cleanup()
forced_const= FALSE;
}
+Item *Item_sum::result_item(THD *thd, Field *field)
+{
+ return new (thd->mem_root) Item_field(thd, field);
+}
/**
Compare keys consisting of single field that cannot be compared as binary.
@@ -1759,6 +1763,12 @@ Item *Item_sum_std::copy_or_same(THD* thd)
}
+Item *Item_sum_std::result_item(THD *thd, Field *field)
+{
+ return new (thd->mem_root) Item_std_field(thd, this);
+}
+
+
/*
Variance
*/
@@ -1989,6 +1999,11 @@ void Item_sum_variance::update_field()
}
+Item *Item_sum_variance::result_item(THD *thd, Field *field)
+{
+ return new (thd->mem_root) Item_variance_field(thd, this);
+}
+
/* min & max */
void Item_sum_hybrid::clear()
@@ -2477,6 +2492,12 @@ void Item_sum_avg::update_field()
}
+Item *Item_sum_avg::result_item(THD *thd, Field *field)
+{
+ return new (thd->mem_root) Item_avg_field(thd, hybrid_type, this);
+}
+
+
void Item_sum_hybrid::update_field()
{
switch (hybrid_type) {
diff --git a/sql/item_sum.h b/sql/item_sum.h
index c061d0f833b..b5613161d7c 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -431,8 +431,8 @@ public:
virtual void update_field()=0;
virtual bool keep_field_type(void) const { return 0; }
virtual void fix_length_and_dec() { maybe_null=1; null_value=1; }
- virtual Item *result_item(THD *thd, Field *field)
- { return new Item_field(thd, field); }
+ virtual Item *result_item(THD *thd, Field *field);
+
/*
Return bitmap of tables that are needed to evaluate the item.
@@ -879,8 +879,7 @@ public:
String *val_str(String *str);
void reset_field();
void update_field();
- Item *result_item(THD *thd, Field *field)
- { return new Item_avg_field(thd, hybrid_type, this); }
+ Item *result_item(THD *thd, Field *field);
void no_rows_in_result() {}
const char *func_name() const
{
@@ -977,8 +976,7 @@ public:
my_decimal *val_decimal(my_decimal *);
void reset_field();
void update_field();
- Item *result_item(THD *thd, Field *field)
- { return new Item_variance_field(thd, this); }
+ Item *result_item(THD *thd, Field *field);
void no_rows_in_result() {}
const char *func_name() const
{ return sample ? "var_samp(" : "variance("; }
@@ -1019,8 +1017,7 @@ class Item_sum_std :public Item_sum_variance
{}
enum Sumfunctype sum_func () const { return STD_FUNC; }
double val_real();
- Item *result_item(THD *thd, Field *field)
- { return new Item_std_field(thd, this); }
+ Item *result_item(THD *thd, Field *field);
const char *func_name() const { return "std("; }
Item *copy_or_same(THD* thd);
enum Item_result result_type () const { return REAL_RESULT; }
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 1508c501c06..c1140946e87 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -840,7 +840,8 @@ String *Item_nodeset_func_elementbyindex::val_nodeset(String *nodeset)
static Item* nodeset2bool(MY_XPATH *xpath, Item *item)
{
if (item->type() == Item::XPATH_NODESET)
- return new Item_xpath_cast_bool(xpath->thd, item, xpath->pxml);
+ return new (xpath->thd->mem_root)
+ Item_xpath_cast_bool(xpath->thd, item, xpath->pxml);
return item;
}
@@ -912,14 +913,15 @@ static Item* nodeset2bool(MY_XPATH *xpath, Item *item)
*/
static Item *eq_func(THD *thd, int oper, Item *a, Item *b)
{
+ MEM_ROOT *mem_root= thd->mem_root;
switch (oper)
{
- case '=': return new Item_func_eq(thd, a, b);
- case '!': return new Item_func_ne(thd, a, b);
- case MY_XPATH_LEX_GE: return new Item_func_ge(thd, a, b);
- case MY_XPATH_LEX_LE: return new Item_func_le(thd, a, b);
- case MY_XPATH_LEX_GREATER: return new Item_func_gt(thd, a, b);
- case MY_XPATH_LEX_LESS: return new Item_func_lt(thd, a, b);
+ case '=': return new (mem_root) Item_func_eq(thd, a, b);
+ case '!': return new (mem_root) Item_func_ne(thd, a, b);
+ case MY_XPATH_LEX_GE: return new (mem_root) Item_func_ge(thd, a, b);
+ case MY_XPATH_LEX_LE: return new (mem_root) Item_func_le(thd, a, b);
+ case MY_XPATH_LEX_GREATER: return new (mem_root) Item_func_gt(thd, a, b);
+ case MY_XPATH_LEX_LESS: return new (mem_root) Item_func_lt(thd, a, b);
}
return 0;
}
@@ -939,14 +941,15 @@ static Item *eq_func(THD *thd, int oper, Item *a, Item *b)
*/
static Item *eq_func_reverse(THD *thd, int oper, Item *a, Item *b)
{
+ MEM_ROOT *mem_root= thd->mem_root;
switch (oper)
{
- case '=': return new Item_func_eq(thd, a, b);
- case '!': return new Item_func_ne(thd, a, b);
- case MY_XPATH_LEX_GE: return new Item_func_le(thd, a, b);
- case MY_XPATH_LEX_LE: return new Item_func_ge(thd, a, b);
- case MY_XPATH_LEX_GREATER: return new Item_func_lt(thd, a, b);
- case MY_XPATH_LEX_LESS: return new Item_func_gt(thd, a, b);
+ case '=': return new (mem_root) Item_func_eq(thd, a, b);
+ case '!': return new (mem_root) Item_func_ne(thd, a, b);
+ case MY_XPATH_LEX_GE: return new (mem_root) Item_func_le(thd, a, b);
+ case MY_XPATH_LEX_LE: return new (mem_root) Item_func_ge(thd, a, b);
+ case MY_XPATH_LEX_GREATER: return new (mem_root) Item_func_lt(thd, a, b);
+ case MY_XPATH_LEX_LESS: return new (mem_root) Item_func_gt(thd, a, b);
}
return 0;
}
@@ -992,24 +995,25 @@ static Item *create_comparator(MY_XPATH *xpath,
in a loop through all of the nodes in the node set.
*/
- Item_string *fake= new Item_string_xml_non_const(xpath->thd, "", 0,
- xpath->cs);
+ THD *thd= xpath->thd;
+ Item_string *fake= (new (thd->mem_root)
+ Item_string_xml_non_const(thd, "", 0, xpath->cs));
Item_nodeset_func *nodeset;
Item *scalar, *comp;
if (a->type() == Item::XPATH_NODESET)
{
nodeset= (Item_nodeset_func*) a;
scalar= b;
- comp= eq_func(xpath->thd, oper, (Item*)fake, scalar);
+ comp= eq_func(thd, oper, (Item*)fake, scalar);
}
else
{
nodeset= (Item_nodeset_func*) b;
scalar= a;
- comp= eq_func_reverse(xpath->thd, oper, fake, scalar);
+ comp= eq_func_reverse(thd, oper, fake, scalar);
}
- return new Item_nodeset_to_const_comparator(xpath->thd, nodeset, comp,
- xpath->pxml);
+ return (new (thd->mem_root)
+ Item_nodeset_to_const_comparator(thd, nodeset, comp, xpath->pxml));
}
}
@@ -1026,6 +1030,9 @@ static Item *create_comparator(MY_XPATH *xpath,
static Item* nametestfunc(MY_XPATH *xpath,
int type, Item *arg, const char *beg, uint len)
{
+ THD *thd= xpath->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
+
DBUG_ASSERT(arg != 0);
DBUG_ASSERT(arg->type() == Item::XPATH_NODESET);
DBUG_ASSERT(beg != 0);
@@ -1035,35 +1042,35 @@ static Item* nametestfunc(MY_XPATH *xpath,
switch (type)
{
case MY_XPATH_AXIS_ANCESTOR:
- res= new Item_nodeset_func_ancestorbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_ancestorbyname(thd, arg, beg, len,
xpath->pxml, 0);
break;
case MY_XPATH_AXIS_ANCESTOR_OR_SELF:
- res= new Item_nodeset_func_ancestorbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_ancestorbyname(thd, arg, beg, len,
xpath->pxml, 1);
break;
case MY_XPATH_AXIS_PARENT:
- res= new Item_nodeset_func_parentbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_parentbyname(thd, arg, beg, len,
xpath->pxml);
break;
case MY_XPATH_AXIS_DESCENDANT:
- res= new Item_nodeset_func_descendantbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_descendantbyname(thd, arg, beg, len,
xpath->pxml, 0);
break;
case MY_XPATH_AXIS_DESCENDANT_OR_SELF:
- res= new Item_nodeset_func_descendantbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_descendantbyname(thd, arg, beg, len,
xpath->pxml, 1);
break;
case MY_XPATH_AXIS_ATTRIBUTE:
- res= new Item_nodeset_func_attributebyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_attributebyname(thd, arg, beg, len,
xpath->pxml);
break;
case MY_XPATH_AXIS_SELF:
- res= new Item_nodeset_func_selfbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_selfbyname(thd, arg, beg, len,
xpath->pxml);
break;
default:
- res= new Item_nodeset_func_childbyname(xpath->thd, arg, beg, len,
+ res= new (mem_root) Item_nodeset_func_childbyname(thd, arg, beg, len,
xpath->pxml);
}
return res;
@@ -1173,43 +1180,46 @@ my_xpath_keyword(MY_XPATH *x,
static Item *create_func_true(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_bool(xpath->thd, 1);
+ return new (xpath->thd->mem_root) Item_bool(xpath->thd, 1);
}
static Item *create_func_false(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_bool(xpath->thd, 0);
+ return new (xpath->thd->mem_root) Item_bool(xpath->thd, 0);
}
static Item *create_func_not(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_func_not(xpath->thd, nodeset2bool(xpath, args[0]));
+ return new (xpath->thd->mem_root)
+ Item_func_not(xpath->thd, nodeset2bool(xpath, args[0]));
}
static Item *create_func_ceiling(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_func_ceiling(xpath->thd, args[0]);
+ return new (xpath->thd->mem_root) Item_func_ceiling(xpath->thd, args[0]);
}
static Item *create_func_floor(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_func_floor(xpath->thd, args[0]);
+ return new (xpath->thd->mem_root) Item_func_floor(xpath->thd, args[0]);
}
static Item *create_func_bool(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_xpath_cast_bool(xpath->thd, args[0], xpath->pxml);
+ return new (xpath->thd->mem_root)
+ Item_xpath_cast_bool(xpath->thd, args[0], xpath->pxml);
}
static Item *create_func_number(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_xpath_cast_number(xpath->thd, args[0]);
+ return new (xpath->thd->mem_root)
+ Item_xpath_cast_number(xpath->thd, args[0]);
}
@@ -1217,53 +1227,61 @@ static Item *create_func_string_length(MY_XPATH *xpath, Item **args,
uint nargs)
{
Item *arg= nargs ? args[0] : xpath->context;
- return arg ? new Item_func_char_length(xpath->thd, arg) : 0;
+ return arg ? new (xpath->thd->mem_root)
+ Item_func_char_length(xpath->thd, arg) : 0;
}
static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_func_round(xpath->thd, args[0],
- new Item_int(xpath->thd, (char *) "0", 0, 1), 0);
+ return new (xpath->thd->mem_root)
+ Item_func_round(xpath->thd, args[0],
+ new (xpath->thd->mem_root)
+ Item_int(xpath->thd, (char *) "0", 0, 1), 0);
}
static Item *create_func_last(MY_XPATH *xpath, Item **args, uint nargs)
{
- return xpath->context ?
- new Item_func_xpath_count(xpath->thd, xpath->context, xpath->pxml) :
- NULL;
+ return (xpath->context ?
+ new (xpath->thd->mem_root)
+ Item_func_xpath_count(xpath->thd, xpath->context, xpath->pxml) :
+ NULL);
}
static Item *create_func_position(MY_XPATH *xpath, Item **args, uint nargs)
{
- return xpath->context ?
- new Item_func_xpath_position(xpath->thd, xpath->context,
- xpath->pxml) : NULL;
+ return (xpath->context ?
+ new (xpath->thd->mem_root)
+ Item_func_xpath_position(xpath->thd, xpath->context, xpath->pxml) :
+ NULL);
}
static Item *create_func_contains(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_xpath_cast_bool(xpath->thd,
- new Item_func_locate(xpath->thd, args[0],
- args[1]), xpath->pxml);
+ return (new (xpath->thd->mem_root)
+ Item_xpath_cast_bool(xpath->thd,
+ new (xpath->thd->mem_root)
+ Item_func_locate(xpath->thd, args[0], args[1]),
+ xpath->pxml));
}
static Item *create_func_concat(MY_XPATH *xpath, Item **args, uint nargs)
{
- return new Item_func_concat(xpath->thd, args[0], args[1]);
+ return new (xpath->thd->mem_root)
+ Item_func_concat(xpath->thd, args[0], args[1]);
}
static Item *create_func_substr(MY_XPATH *xpath, Item **args, uint nargs)
{
+ THD *thd= xpath->thd;
if (nargs == 2)
- return new Item_func_substr(xpath->thd, args[0], args[1]);
- else
- return new Item_func_substr(xpath->thd, args[0], args[1], args[2]);
+ return new (thd->mem_root) Item_func_substr(thd, args[0], args[1]);
+ return new (thd->mem_root) Item_func_substr(thd, args[0], args[1], args[2]);
}
@@ -1271,7 +1289,7 @@ static Item *create_func_count(MY_XPATH *xpath, Item **args, uint nargs)
{
if (args[0]->type() != Item::XPATH_NODESET)
return 0;
- return new Item_func_xpath_count(xpath->thd, args[0], xpath->pxml);
+ return new (xpath->thd->mem_root) Item_func_xpath_count(xpath->thd, args[0], xpath->pxml);
}
@@ -1279,7 +1297,8 @@ static Item *create_func_sum(MY_XPATH *xpath, Item **args, uint nargs)
{
if (args[0]->type() != Item::XPATH_NODESET)
return 0;
- return new Item_func_xpath_sum(xpath->thd, args[0], xpath->pxml);
+ return new (xpath->thd->mem_root)
+ Item_func_xpath_sum(xpath->thd, args[0], xpath->pxml);
}
@@ -1652,10 +1671,11 @@ static int my_xpath_parse_AbsoluteLocationPath(MY_XPATH *xpath)
if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH))
{
- xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd,
- xpath->context,
- "*", 1,
- xpath->pxml, 1);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_descendantbyname(xpath->thd,
+ xpath->context,
+ "*", 1,
+ xpath->pxml, 1);
return my_xpath_parse_RelativeLocationPath(xpath);
}
@@ -1694,10 +1714,11 @@ static int my_xpath_parse_RelativeLocationPath(MY_XPATH *xpath)
while (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH))
{
if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH))
- xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd,
- xpath->context,
- "*", 1,
- xpath->pxml, 1);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_descendantbyname(xpath->thd,
+ xpath->context,
+ "*", 1,
+ xpath->pxml, 1);
if (!my_xpath_parse_Step(xpath))
{
xpath->error= 1;
@@ -1735,8 +1756,8 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath)
Item *prev_context= xpath->context;
String *context_cache;
context_cache= &((Item_nodeset_func*)xpath->context)->context_cache;
- xpath->context= new Item_nodeset_context_cache(xpath->thd, context_cache,
- xpath->pxml);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_context_cache(xpath->thd, context_cache, xpath->pxml);
xpath->context_cache= context_cache;
if(!my_xpath_parse_PredicateExpr(xpath))
@@ -1755,16 +1776,18 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath)
if (xpath->item->is_bool_type())
{
- xpath->context= new Item_nodeset_func_predicate(xpath->thd, prev_context,
- xpath->item,
- xpath->pxml);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_predicate(xpath->thd, prev_context,
+ xpath->item,
+ xpath->pxml);
}
else
{
- xpath->context= new Item_nodeset_func_elementbyindex(xpath->thd,
- prev_context,
- xpath->item,
- xpath->pxml);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_elementbyindex(xpath->thd,
+ prev_context,
+ xpath->item,
+ xpath->pxml);
}
}
return 1;
@@ -1886,9 +1909,10 @@ static int my_xpath_parse_AbbreviatedStep(MY_XPATH *xpath)
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT))
return 0;
if (my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT))
- xpath->context= new Item_nodeset_func_parentbyname(xpath->thd,
- xpath->context, "*",
- 1, xpath->pxml);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_parentbyname(xpath->thd,
+ xpath->context, "*",
+ 1, xpath->pxml);
return 1;
}
@@ -1917,9 +1941,10 @@ static int my_xpath_parse_PrimaryExpr_literal(MY_XPATH *xpath)
{
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_STRING))
return 0;
- xpath->item= new Item_string(xpath->thd, xpath->prevtok.beg + 1,
- xpath->prevtok.end - xpath->prevtok.beg - 2,
- xpath->cs);
+ xpath->item= new (xpath->thd->mem_root)
+ Item_string(xpath->thd, xpath->prevtok.beg + 1,
+ xpath->prevtok.end - xpath->prevtok.beg - 2,
+ xpath->cs);
return 1;
}
static int my_xpath_parse_PrimaryExpr(MY_XPATH *xpath)
@@ -2012,8 +2037,9 @@ static int my_xpath_parse_UnionExpr(MY_XPATH *xpath)
xpath->error= 1;
return 0;
}
- xpath->item= new Item_nodeset_func_union(xpath->thd, prev, xpath->item,
- xpath->pxml);
+ xpath->item= new (xpath->thd->mem_root)
+ Item_nodeset_func_union(xpath->thd, prev, xpath->item,
+ xpath->pxml);
}
return 1;
}
@@ -2059,10 +2085,11 @@ my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(MY_XPATH *xpath)
/* treat double slash (//) as /descendant-or-self::node()/ */
if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH))
- xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd,
- xpath->context,
- "*", 1,
- xpath->pxml, 1);
+ xpath->context= new (xpath->thd->mem_root)
+ Item_nodeset_func_descendantbyname(xpath->thd,
+ xpath->context,
+ "*", 1,
+ xpath->pxml, 1);
rc= my_xpath_parse_RelativeLocationPath(xpath);
/* push back the context and restore the item */
@@ -2124,8 +2151,9 @@ static int my_xpath_parse_OrExpr(MY_XPATH *xpath)
xpath->error= 1;
return 0;
}
- xpath->item= new Item_cond_or(xpath->thd, nodeset2bool(xpath, prev),
- nodeset2bool(xpath, xpath->item));
+ xpath->item= new (xpath->thd->mem_root)
+ Item_cond_or(xpath->thd, nodeset2bool(xpath, prev),
+ nodeset2bool(xpath, xpath->item));
}
return 1;
}
@@ -2156,8 +2184,9 @@ static int my_xpath_parse_AndExpr(MY_XPATH *xpath)
return 0;
}
- xpath->item= new Item_cond_and(xpath->thd, nodeset2bool(xpath, prev),
- nodeset2bool(xpath, xpath->item));
+ xpath->item= new (xpath->thd->mem_root)
+ Item_cond_and(xpath->thd, nodeset2bool(xpath, prev),
+ nodeset2bool(xpath, xpath->item));
}
return 1;
}
@@ -2319,6 +2348,8 @@ static int my_xpath_parse_AdditiveExpr(MY_XPATH *xpath)
{
int oper= xpath->prevtok.term;
Item *prev= xpath->item;
+ THD *thd= xpath->thd;
+
if (!my_xpath_parse_MultiplicativeExpr(xpath))
{
xpath->error= 1;
@@ -2326,9 +2357,11 @@ static int my_xpath_parse_AdditiveExpr(MY_XPATH *xpath)
}
if (oper == MY_XPATH_LEX_PLUS)
- xpath->item= new Item_func_plus(xpath->thd, prev, xpath->item);
+ xpath->item= new (thd->mem_root)
+ Item_func_plus(thd, prev, xpath->item);
else
- xpath->item= new Item_func_minus(xpath->thd, prev, xpath->item);
+ xpath->item= new (thd->mem_root)
+ Item_func_minus(thd, prev, xpath->item);
};
return 1;
}
@@ -2363,6 +2396,7 @@ static int my_xpath_parse_MultiplicativeExpr(MY_XPATH *xpath)
if (!my_xpath_parse_UnaryExpr(xpath))
return 0;
+ THD *thd= xpath->thd;
while (my_xpath_parse_MultiplicativeOperator(xpath))
{
int oper= xpath->prevtok.term;
@@ -2375,13 +2409,13 @@ static int my_xpath_parse_MultiplicativeExpr(MY_XPATH *xpath)
switch (oper)
{
case MY_XPATH_LEX_ASTERISK:
- xpath->item= new Item_func_mul(xpath->thd, prev, xpath->item);
+ xpath->item= new (thd->mem_root) Item_func_mul(thd, prev, xpath->item);
break;
case MY_XPATH_LEX_DIV:
- xpath->item= new Item_func_int_div(xpath->thd, prev, xpath->item);
+ xpath->item= new (thd->mem_root) Item_func_int_div(thd, prev, xpath->item);
break;
case MY_XPATH_LEX_MOD:
- xpath->item= new Item_func_mod(xpath->thd, prev, xpath->item);
+ xpath->item= new (thd->mem_root) Item_func_mod(thd, prev, xpath->item);
break;
}
}
@@ -2406,7 +2440,8 @@ static int my_xpath_parse_UnaryExpr(MY_XPATH *xpath)
return my_xpath_parse_UnionExpr(xpath);
if (!my_xpath_parse_UnaryExpr(xpath))
return 0;
- xpath->item= new Item_func_neg(xpath->thd, xpath->item);
+ xpath->item= new (xpath->thd->mem_root)
+ Item_func_neg(xpath->thd, xpath->item);
return 1;
}
@@ -2438,18 +2473,21 @@ static int my_xpath_parse_UnaryExpr(MY_XPATH *xpath)
static int my_xpath_parse_Number(MY_XPATH *xpath)
{
const char *beg;
+ THD *thd;
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DIGITS))
return 0;
beg= xpath->prevtok.beg;
+ thd= xpath->thd;
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT))
{
- xpath->item= new Item_int(xpath->thd, xpath->prevtok.beg,
+ xpath->item= new (thd->mem_root) Item_int(thd, xpath->prevtok.beg,
xpath->prevtok.end - xpath->prevtok.beg);
return 1;
}
my_xpath_parse_term(xpath, MY_XPATH_LEX_DIGITS);
- xpath->item= new Item_float(xpath->thd, beg, xpath->prevtok.end - beg);
+ xpath->item= new (thd->mem_root) Item_float(thd, beg,
+ xpath->prevtok.end - beg);
return 1;
}
@@ -2542,6 +2580,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
LEX_STRING name;
int user_var;
const char *dollar_pos;
+ THD *thd= xpath->thd;
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOLLAR) ||
(!(dollar_pos= xpath->prevtok.beg)) ||
(!((user_var= my_xpath_parse_term(xpath, MY_XPATH_LEX_AT) &&
@@ -2553,18 +2592,19 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
name.str= (char*) xpath->prevtok.beg;
if (user_var)
- xpath->item= new Item_func_get_user_var(xpath->thd, name);
+ xpath->item= new (thd->mem_root) Item_func_get_user_var(thd, name);
else
{
sp_variable *spv;
sp_pcontext *spc;
LEX *lex;
- if ((lex= current_thd->lex) &&
+ if ((lex= thd->lex) &&
(spc= lex->spcont) &&
(spv= spc->find_variable(name, false)))
{
- Item_splocal *splocal= new Item_splocal(xpath->thd, name, spv->offset,
- spv->type, 0);
+ Item_splocal *splocal= new (thd->mem_root)
+ Item_splocal(thd, name, spv->offset,
+ spv->type, 0);
#ifndef DBUG_OFF
if (splocal)
splocal->m_sp= lex->sphead;
@@ -2643,12 +2683,12 @@ my_xpath_parse(MY_XPATH *xpath, const char *str, const char *strend)
my_xpath_lex_init(&xpath->prevtok, str, strend);
my_xpath_lex_scan(xpath, &xpath->lasttok, str, strend);
- xpath->rootelement= new Item_nodeset_func_rootelement(xpath->thd,
- xpath->pxml);
+ xpath->rootelement= new (xpath->thd->mem_root)
+ Item_nodeset_func_rootelement(xpath->thd,
+ xpath->pxml);
- return
- my_xpath_parse_Expr(xpath) &&
- my_xpath_parse_term(xpath, MY_XPATH_LEX_EOF);
+ return (my_xpath_parse_Expr(xpath) &&
+ my_xpath_parse_term(xpath, MY_XPATH_LEX_EOF));
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 60636a58550..9459eb974ef 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1036,17 +1036,18 @@ int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name,
void Log_event::init_show_field_list(THD *thd, List<Item>* field_list)
{
- field_list->push_back(new Item_empty_string(thd, "Log_name", 20));
- field_list->push_back(new Item_return_int(thd, "Pos",
+ MEM_ROOT *mem_root= thd->mem_root;
+ field_list->push_back(new (mem_root) Item_empty_string(thd, "Log_name", 20));
+ field_list->push_back(new (mem_root) Item_return_int(thd, "Pos",
MY_INT32_NUM_DECIMAL_DIGITS,
MYSQL_TYPE_LONGLONG));
- field_list->push_back(new Item_empty_string(thd, "Event_type", 20));
- field_list->push_back(new Item_return_int(thd, "Server_id", 10,
+ field_list->push_back(new (mem_root) Item_empty_string(thd, "Event_type", 20));
+ field_list->push_back(new (mem_root) Item_return_int(thd, "Server_id", 10,
MYSQL_TYPE_LONG));
- field_list->push_back(new Item_return_int(thd, "End_log_pos",
+ field_list->push_back(new (mem_root) Item_return_int(thd, "End_log_pos",
MY_INT32_NUM_DECIMAL_DIGITS,
MYSQL_TYPE_LONGLONG));
- field_list->push_back(new Item_empty_string(thd, "Info", 20));
+ field_list->push_back(new (mem_root) Item_empty_string(thd, "Info", 20));
}
/**
@@ -5725,7 +5726,7 @@ void Load_log_event::set_fields(const char* affected_db,
const char* field = fields;
for (i= 0; i < num_fields; i++)
{
- field_list.push_back(new Item_field(thd, context,
+ field_list.push_back(new (thd->mem_root) Item_field(thd, context,
affected_db, table_name, field));
field+= field_lens[i] + 1;
}
@@ -7854,33 +7855,33 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
if (is_null)
{
- it= new Item_null(thd);
+ it= new (thd->mem_root) Item_null(thd);
}
else
{
switch (type) {
case REAL_RESULT:
float8get(real_val, val);
- it= new Item_float(thd, real_val, 0);
+ it= new (thd->mem_root) Item_float(thd, real_val, 0);
val= (char*) &real_val; // Pointer to value in native format
val_len= 8;
break;
case INT_RESULT:
int_val= (longlong) uint8korr(val);
- it= new Item_int(thd, int_val);
+ it= new (thd->mem_root) Item_int(thd, int_val);
val= (char*) &int_val; // Pointer to value in native format
val_len= 8;
break;
case DECIMAL_RESULT:
{
- Item_decimal *dec= new Item_decimal(thd, (uchar*) val+2, val[0], val[1]);
+ Item_decimal *dec= new (thd->mem_root) Item_decimal(thd, (uchar*) val+2, val[0], val[1]);
it= dec;
val= (char *)dec->val_decimal(NULL);
val_len= sizeof(my_decimal);
break;
}
case STRING_RESULT:
- it= new Item_string(thd, val, val_len, charset);
+ it= new (thd->mem_root) Item_string(thd, val, val_len, charset);
break;
case ROW_RESULT:
default:
@@ -7889,7 +7890,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
}
}
- Item_func_set_user_var *e= new Item_func_set_user_var(thd, user_var_name, it);
+ Item_func_set_user_var *e= new (thd->mem_root) Item_func_set_user_var(thd, user_var_name, it);
/*
Item_func_set_user_var can't substitute something else on its place =>
0 can be passed as last argument (reference on item)
diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc
index 43ad8494a74..848549c3b2d 100644
--- a/sql/opt_index_cond_pushdown.cc
+++ b/sql/opt_index_cond_pushdown.cc
@@ -192,7 +192,7 @@ static Item *make_cond_for_index(THD *thd, Item *cond, TABLE *table, uint keyno,
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
table_map used_tables= 0;
- Item_cond_and *new_cond= new Item_cond_and(thd);
+ Item_cond_and *new_cond= new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -227,7 +227,7 @@ static Item *make_cond_for_index(THD *thd, Item *cond, TABLE *table, uint keyno,
}
else /* It's OR */
{
- Item_cond_or *new_cond= new Item_cond_or(thd);
+ Item_cond_or *new_cond= new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -269,7 +269,7 @@ static Item *make_cond_remainder(THD *thd, Item *cond, TABLE *table, uint keyno,
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
/* Create new top level AND item */
- Item_cond_and *new_cond= new Item_cond_and(thd);
+ Item_cond_and *new_cond= new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -297,7 +297,7 @@ static Item *make_cond_remainder(THD *thd, Item *cond, TABLE *table, uint keyno,
}
else /* It's OR */
{
- Item_cond_or *new_cond= new Item_cond_or(thd);
+ Item_cond_or *new_cond= new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -420,8 +420,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
tab->select_cond= row_cond;
else
{
- COND *new_cond= new Item_cond_and(tab->join->thd, row_cond,
- idx_remainder_cond);
+ COND *new_cond= new (tab->join->thd->mem_root)
+ Item_cond_and(tab->join->thd, row_cond, idx_remainder_cond);
tab->select_cond= new_cond;
tab->select_cond->quick_fix_field();
((Item_cond_and*)tab->select_cond)->used_tables_cache=
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index b419997a8d6..a7449b1c995 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1136,7 +1136,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
&join->conds : &(in_subq->emb_on_expr_nest->on_expr);
Item *replace_me= in_subq->original_item();
if (replace_where_subcondition(join, tree, replace_me,
- new Item_int(thd, 1),
+ new (thd->mem_root) Item_int(thd, 1),
FALSE))
goto restore_arena_and_fail;
}
@@ -1595,7 +1595,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
{
nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr);
Item_func_eq *item_eq=
- new Item_func_eq(thd, subq_pred->left_expr,
+ new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr,
subq_lex->ref_pointer_array[0]);
item_eq->in_equality_no= 0;
sj_nest->sj_on_expr= and_items(thd, sj_nest->sj_on_expr, item_eq);
@@ -1607,7 +1607,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr->
element_index(i));
Item_func_eq *item_eq=
- new Item_func_eq(thd, subq_pred->left_expr->element_index(i),
+ new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr->element_index(i),
subq_lex->ref_pointer_array[i]);
item_eq->in_equality_no= i;
sj_nest->sj_on_expr= and_items(thd, sj_nest->sj_on_expr, item_eq);
@@ -3797,8 +3797,8 @@ static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm,
Item *res= NULL;
if (subq_pred->left_expr->cols() == 1)
{
- if (!(res= new Item_func_eq(thd, subq_pred->left_expr,
- new Item_field(thd, sjm->table->field[0]))))
+ if (!(res= new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr,
+ new (thd->mem_root) Item_field(thd, sjm->table->field[0]))))
return NULL; /* purecov: inspected */
}
else
@@ -3806,8 +3806,8 @@ static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm,
Item *conj;
for (uint i= 0; i < subq_pred->left_expr->cols(); i++)
{
- if (!(conj= new Item_func_eq(thd, subq_pred->left_expr->element_index(i),
- new Item_field(thd, sjm->table->field[i]))) ||
+ if (!(conj= new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr->element_index(i),
+ new (thd->mem_root) Item_field(thd, sjm->table->field[i]))) ||
!(res= and_items(thd, res, conj)))
return NULL; /* purecov: inspected */
}
@@ -3836,7 +3836,7 @@ static void remove_sj_conds(THD *thd, Item **tree)
while ((item= li++))
{
if (is_cond_sj_in_equality(item))
- li.replace(new Item_int(thd, 1));
+ li.replace(new (thd->mem_root) Item_int(thd, 1));
}
}
}
@@ -5102,7 +5102,7 @@ TABLE *create_dummy_tmp_table(THD *thd)
sjm_table_param.init();
sjm_table_param.field_count= 1;
List<Item> sjm_table_cols;
- Item *column_item= new Item_int(thd, 1);
+ Item *column_item= new (thd->mem_root) Item_int(thd, 1);
sjm_table_cols.push_back(column_item);
if (!(table= create_tmp_table(thd, &sjm_table_param,
sjm_table_cols, (ORDER*) 0,
@@ -5194,6 +5194,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
TABLE_LIST *table;
NESTED_JOIN *nested_join;
List_iterator<TABLE_LIST> li(*join_list);
+ THD *thd= join->thd;
DBUG_ENTER("setup_jtbm_semi_joins");
while ((table= li++))
@@ -5242,7 +5243,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
(subselect_single_select_engine*)subq_pred->engine;
select_value_catcher *new_sink;
if (!(new_sink=
- new (join->thd->mem_root) select_value_catcher(join->thd, subq_pred)))
+ new (thd->mem_root) select_value_catcher(thd, subq_pred)))
DBUG_RETURN(TRUE);
if (new_sink->setup(&engine->select_lex->join->fields_list) ||
engine->select_lex->join->change_result(new_sink, NULL) ||
@@ -5262,14 +5263,14 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
Item *eq_cond;
for (uint i= 0; i < subq_pred->left_expr->cols(); i++)
{
- eq_cond= new Item_func_eq(join->thd,
- subq_pred->left_expr->element_index(i),
- new_sink->row[i]);
+ eq_cond= new (thd->mem_root)
+ Item_func_eq(thd, subq_pred->left_expr->element_index(i),
+ new_sink->row[i]);
if (!eq_cond)
DBUG_RETURN(1);
- if (!((*join_where)= and_items(join->thd, *join_where, eq_cond)) ||
- (*join_where)->fix_fields(join->thd, join_where))
+ if (!((*join_where)= and_items(thd, *join_where, eq_cond)) ||
+ (*join_where)->fix_fields(thd, join_where))
DBUG_RETURN(1);
}
}
@@ -5281,7 +5282,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
/* Set up a dummy TABLE*, optimizer code needs JOIN_TABs to have TABLE */
TABLE *dummy_table;
- if (!(dummy_table= create_dummy_tmp_table(join->thd)))
+ if (!(dummy_table= create_dummy_tmp_table(thd)))
DBUG_RETURN(1);
table->table= dummy_table;
table->table->pos_in_table_list= table;
@@ -5307,9 +5308,9 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list,
Item *sj_conds= hash_sj_engine->semi_join_conds;
- (*join_where)= and_items(join->thd, *join_where, sj_conds);
+ (*join_where)= and_items(thd, *join_where, sj_conds);
if (!(*join_where)->fixed)
- (*join_where)->fix_fields(join->thd, join_where);
+ (*join_where)->fix_fields(thd, join_where);
}
table->table->maybe_null= MY_TEST(join->mixed_implicit_grouping);
}
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc
index 9f133b97683..dad236de845 100644
--- a/sql/opt_table_elimination.cc
+++ b/sql/opt_table_elimination.cc
@@ -1217,7 +1217,7 @@ void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *ctx,
}
case Item_func::ISNULL_FUNC:
{
- Item *tmp=new Item_null(thd);
+ Item *tmp=new (thd->mem_root) Item_null(thd);
if (tmp)
check_equality(ctx, eq_mod, *and_level, cond_func, args[0], tmp);
break;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 542bdc2d4ea..ed962f3bdd1 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -1248,7 +1248,7 @@ bool Protocol_text::send_out_parameters(List<Item_param> *sp_params)
continue; // It's an IN-parameter.
Item_func_set_user_var *suv=
- new Item_func_set_user_var(thd, *user_var_name, item_param);
+ new (thd->mem_root) Item_func_set_user_var(thd, *user_var_name, item_param);
/*
Item_func_set_user_var is not fixed after construction, call
fix_fields().
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 1c7c8c013ea..4860935e9bf 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -230,18 +230,19 @@ bool show_slave_hosts(THD* thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("show_slave_hosts");
- field_list.push_back(new Item_return_int(thd, "Server_id", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Server_id", 10,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Host", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Host", 20));
if (opt_show_slave_auth_info)
{
- field_list.push_back(new Item_empty_string(thd, "User", 20));
- field_list.push_back(new Item_empty_string(thd, "Password", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "User", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Password", 20));
}
- field_list.push_back(new Item_return_int(thd, "Port", 7, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Master_id", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Port", 7, MYSQL_TYPE_LONG));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Master_id", 10,
MYSQL_TYPE_LONG));
if (protocol->send_result_set_metadata(&field_list,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 53a7d2ad39a..24e4e63e9cf 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -788,12 +788,33 @@ int set_var::light_check(THD *thd)
Consider set_var::check() method if there is a need to return
an error due to logics.
*/
+
int set_var::update(THD *thd)
{
return value ? var->update(thd, this) : var->set_default(thd, this);
}
+set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
+ const LEX_STRING *base_name_arg, Item *value_arg)
+ :var(var_arg), type(type_arg), base(*base_name_arg)
+{
+ /*
+ If the set value is a field, change it to a string to allow things like
+ SET table_type=MYISAM;
+ */
+ if (value_arg && value_arg->type() == Item::FIELD_ITEM)
+ {
+ Item_field *item= (Item_field*) value_arg;
+ // names are utf8
+ if (!(value= new (thd->mem_root) Item_string_sys(thd, item->field_name)))
+ value=value_arg; /* Give error message later */
+ }
+ else
+ value=value_arg;
+}
+
+
/*****************************************************************************
Functions to handle SET @user_variable=const_expr
*****************************************************************************/
diff --git a/sql/set_var.h b/sql/set_var.h
index e559f6bf810..d10edb07133 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -286,23 +286,7 @@ public:
LEX_STRING base; /**< for structured variables, like keycache_name.variable_name */
set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
- const LEX_STRING *base_name_arg, Item *value_arg)
- :var(var_arg), type(type_arg), base(*base_name_arg)
- {
- /*
- If the set value is a field, change it to a string to allow things like
- SET table_type=MYISAM;
- */
- if (value_arg && value_arg->type() == Item::FIELD_ITEM)
- {
- Item_field *item= (Item_field*) value_arg;
- // names are utf8
- if (!(value=new Item_string_sys(thd, item->field_name)))
- value=value_arg; /* Give error message later */
- }
- else
- value=value_arg;
- }
+ const LEX_STRING *base_name_arg, Item *value_arg);
virtual bool is_system() { return 1; }
int check(THD *thd);
int update(THD *thd);
diff --git a/sql/slave.cc b/sql/slave.cc
index 9b074f6488b..b254496ed41 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2515,113 +2515,114 @@ static bool send_show_master_info_header(THD *thd, bool full,
List<Item> field_list;
Protocol *protocol= thd->protocol;
Master_info *mi;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("show_master_info_header");
if (full)
{
- field_list.push_back(new Item_empty_string(thd, "Connection_name",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Connection_name",
MAX_CONNECTION_NAME));
- field_list.push_back(new Item_empty_string(thd, "Slave_SQL_State",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_SQL_State",
30));
}
- field_list.push_back(new Item_empty_string(thd, "Slave_IO_State",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_IO_State",
30));
- field_list.push_back(new Item_empty_string(thd, "Master_Host",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_Host",
sizeof(mi->host)));
- field_list.push_back(new Item_empty_string(thd, "Master_User",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_User",
sizeof(mi->user)));
- field_list.push_back(new Item_return_int(thd, "Master_Port", 7,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Master_Port", 7,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Connect_Retry", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Connect_Retry", 10,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Master_Log_File",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_Log_File",
FN_REFLEN));
- field_list.push_back(new Item_return_int(thd, "Read_Master_Log_Pos", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Read_Master_Log_Pos", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd, "Relay_Log_File",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Relay_Log_File",
FN_REFLEN));
- field_list.push_back(new Item_return_int(thd, "Relay_Log_Pos", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Relay_Log_Pos", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd, "Relay_Master_Log_File",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Relay_Master_Log_File",
FN_REFLEN));
- field_list.push_back(new Item_empty_string(thd, "Slave_IO_Running", 3));
- field_list.push_back(new Item_empty_string(thd, "Slave_SQL_Running", 3));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Do_DB", 20));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_DB", 20));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Do_Table", 20));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Table",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_IO_Running", 3));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_SQL_Running", 3));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Do_DB", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Ignore_DB", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Do_Table", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Ignore_Table",
23));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Wild_Do_Table",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Wild_Do_Table",
24));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Wild_Ignore_Table",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Wild_Ignore_Table",
28));
- field_list.push_back(new Item_return_int(thd, "Last_Errno", 4,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Last_Errno", 4,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Last_Error", 20));
- field_list.push_back(new Item_return_int(thd, "Skip_Counter", 10,
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Last_Error", 20));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Skip_Counter", 10,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Exec_Master_Log_Pos", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Exec_Master_Log_Pos", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_return_int(thd, "Relay_Log_Space", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Relay_Log_Space", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd, "Until_Condition", 6));
- field_list.push_back(new Item_empty_string(thd, "Until_Log_File", FN_REFLEN));
- field_list.push_back(new Item_return_int(thd, "Until_Log_Pos", 10,
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Until_Condition", 6));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Until_Log_File", FN_REFLEN));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Until_Log_Pos", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Allowed", 7));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_CA_File",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Allowed", 7));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_CA_File",
sizeof(mi->ssl_ca)));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_CA_Path",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_CA_Path",
sizeof(mi->ssl_capath)));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Cert",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Cert",
sizeof(mi->ssl_cert)));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Cipher",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Cipher",
sizeof(mi->ssl_cipher)));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Key",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Key",
sizeof(mi->ssl_key)));
- field_list.push_back(new Item_return_int(thd, "Seconds_Behind_Master", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Seconds_Behind_Master", 10,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd,
+ field_list.push_back(new (mem_root) Item_empty_string(thd,
"Master_SSL_Verify_Server_Cert",
3));
- field_list.push_back(new Item_return_int(thd, "Last_IO_Errno", 4,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Last_IO_Errno", 4,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Last_IO_Error", 20));
- field_list.push_back(new Item_return_int(thd, "Last_SQL_Errno", 4,
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Last_IO_Error", 20));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Last_SQL_Errno", 4,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Last_SQL_Error", 20));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Server_Ids",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Last_SQL_Error", 20));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Ignore_Server_Ids",
FN_REFLEN));
- field_list.push_back(new Item_return_int(thd, "Master_Server_Id",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Master_Server_Id",
sizeof(ulong),
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Crl",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Crl",
sizeof(mi->ssl_crl)));
- field_list.push_back(new Item_empty_string(thd, "Master_SSL_Crlpath",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Crlpath",
sizeof(mi->ssl_crlpath)));
- field_list.push_back(new Item_empty_string(thd, "Using_Gtid",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Using_Gtid",
sizeof("Current_Pos")-1));
- field_list.push_back(new Item_empty_string(thd, "Gtid_IO_Pos", 30));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Do_Domain_Ids",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Gtid_IO_Pos", 30));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Do_Domain_Ids",
FN_REFLEN));
- field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Domain_Ids",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Ignore_Domain_Ids",
FN_REFLEN));
- field_list.push_back(new Item_empty_string(thd, "Parallel_Mode",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Parallel_Mode",
sizeof("conservative")-1));
if (full)
{
- field_list.push_back(new Item_return_int(thd, "Retried_transactions",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Retried_transactions",
10, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Max_relay_log_size",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Max_relay_log_size",
10, MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_return_int(thd, "Executed_log_entries",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Executed_log_entries",
10, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Slave_received_heartbeats",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Slave_received_heartbeats",
10, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_float(thd, "Slave_heartbeat_period",
+ field_list.push_back(new (mem_root) Item_float(thd, "Slave_heartbeat_period",
0.0, 3, 10));
- field_list.push_back(new Item_empty_string(thd, "Gtid_Slave_Pos",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Gtid_Slave_Pos",
gtid_pos_length));
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 92e73774226..72a1faf7276 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2021,7 +2021,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
if (spvar->mode == sp_variable::MODE_OUT)
{
- Item_null *null_item= new Item_null(thd);
+ Item_null *null_item= new (thd->mem_root) Item_null(thd);
Item *tmp_item= null_item;
if (!null_item ||
@@ -2561,6 +2561,7 @@ sp_head::show_create_routine(THD *thd, int type)
LEX_STRING sql_mode;
bool full_access;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("sp_head::show_create_routine");
DBUG_PRINT("info", ("routine %s", m_name.str));
@@ -2575,8 +2576,8 @@ sp_head::show_create_routine(THD *thd, int type)
/* Send header. */
- fields.push_back(new Item_empty_string(thd, col1_caption, NAME_CHAR_LEN));
- fields.push_back(new Item_empty_string(thd, "sql_mode", sql_mode.length));
+ fields.push_back(new (mem_root) Item_empty_string(thd, col1_caption, NAME_CHAR_LEN));
+ fields.push_back(new (mem_root) Item_empty_string(thd, "sql_mode", sql_mode.length));
{
/*
@@ -2585,7 +2586,7 @@ sp_head::show_create_routine(THD *thd, int type)
*/
Item_empty_string *stmt_fld=
- new Item_empty_string(thd, col3_caption,
+ new (mem_root) Item_empty_string(thd, col3_caption,
MY_MAX(m_defstr.length, 1024));
stmt_fld->maybe_null= TRUE;
@@ -2593,13 +2594,13 @@ sp_head::show_create_routine(THD *thd, int type)
fields.push_back(stmt_fld);
}
- fields.push_back(new Item_empty_string(thd, "character_set_client",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "character_set_client",
MY_CS_NAME_SIZE));
- fields.push_back(new Item_empty_string(thd, "collation_connection",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "collation_connection",
MY_CS_NAME_SIZE));
- fields.push_back(new Item_empty_string(thd, "Database Collation",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "Database Collation",
MY_CS_NAME_SIZE));
if (protocol->send_result_set_metadata(&fields,
@@ -2783,10 +2784,11 @@ sp_head::show_routine_code(THD *thd)
if (check_show_routine_access(thd, this, &full_access) || !full_access)
DBUG_RETURN(1);
- field_list.push_back(new Item_uint(thd, "Pos", 9));
+ field_list.push_back(new (thd->mem_root) Item_uint(thd, "Pos", 9));
// 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string(thd, "Instruction",
- MY_MAX(buffer.length(), 1024)));
+ field_list.push_back(new (thd->mem_root)
+ Item_empty_string(thd, "Instruction",
+ MY_MAX(buffer.length(), 1024)));
if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF))
DBUG_RETURN(1);
@@ -3895,7 +3897,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
initialized. Set to NULL so we can continue.
*/
- Item *null_item= new Item_null(thd);
+ Item *null_item= new (thd->mem_root) Item_null(thd);
if (!null_item ||
thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item))
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 3a5bc044253..b38f4a3ddad 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -137,7 +137,7 @@ bool sp_rcontext::init_var_items(THD *thd)
for (uint idx = 0; idx < num_vars; ++idx)
{
- if (!(m_var_items[idx]= new Item_field(thd, m_var_table->field[idx])))
+ if (!(m_var_items[idx]= new (thd->mem_root) Item_field(thd, m_var_table->field[idx])))
return true;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 457a6d3b0e8..374bf3b8dbe 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -7788,7 +7788,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
}
DBUG_ASSERT(rolename || username);
- Item_string *field=new Item_string_ascii(thd, "", 0);
+ Item_string *field=new (thd->mem_root) Item_string_ascii(thd, "", 0);
List<Item> field_list;
field->name=buff;
field->max_length=1024;
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 4f78b1785a5..f8f5809d9c2 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -326,14 +326,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
DBUG_ENTER("mysql_admin_table");
DBUG_PRINT("enter", ("extra_open_options: %u", extra_open_options));
- field_list.push_back(item = new Item_empty_string(thd, "Table",
+ field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Table",
NAME_CHAR_LEN * 2));
item->maybe_null = 1;
- field_list.push_back(item = new Item_empty_string(thd, "Op", 10));
+ field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Op", 10));
item->maybe_null = 1;
- field_list.push_back(item = new Item_empty_string(thd, "Msg_type", 10));
+ field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Msg_type", 10));
item->maybe_null = 1;
- field_list.push_back(item = new Item_empty_string(thd, "Msg_text",
+ field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Msg_text",
SQL_ADMIN_MSG_TEXT_SIZE));
item->maybe_null = 1;
if (protocol->send_result_set_metadata(&field_list,
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index e9f43a50fce..fe0834e4d47 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -1168,22 +1168,24 @@ int collect_ulonglong(ulonglong *element,
bool analyse::change_columns(THD *thd, List<Item> &field_list)
{
+ MEM_ROOT *mem_root= thd->mem_root;
field_list.empty();
- func_items[0] = new Item_proc_string(thd, "Field_name", 255);
- func_items[1] = new Item_proc_string(thd, "Min_value", 255);
+ func_items[0]= new (mem_root) Item_proc_string(thd, "Field_name", 255);
+ func_items[1]= new (mem_root) Item_proc_string(thd, "Min_value", 255);
func_items[1]->maybe_null = 1;
- func_items[2] = new Item_proc_string(thd, "Max_value", 255);
+ func_items[2]= new (mem_root) Item_proc_string(thd, "Max_value", 255);
func_items[2]->maybe_null = 1;
- func_items[3] = new Item_proc_int(thd, "Min_length");
- func_items[4] = new Item_proc_int(thd, "Max_length");
- func_items[5] = new Item_proc_int(thd, "Empties_or_zeros");
- func_items[6] = new Item_proc_int(thd, "Nulls");
- func_items[7] = new Item_proc_string(thd, "Avg_value_or_avg_length", 255);
- func_items[8] = new Item_proc_string(thd, "Std", 255);
+ func_items[3]= new (mem_root) Item_proc_int(thd, "Min_length");
+ func_items[4]= new (mem_root) Item_proc_int(thd, "Max_length");
+ func_items[5]= new (mem_root) Item_proc_int(thd, "Empties_or_zeros");
+ func_items[6]= new (mem_root) Item_proc_int(thd, "Nulls");
+ func_items[7]= new (mem_root) Item_proc_string(thd, "Avg_value_or_avg_length", 255);
+ func_items[8]= new (mem_root) Item_proc_string(thd, "Std", 255);
func_items[8]->maybe_null = 1;
- func_items[9] = new Item_proc_string(thd, "Optimal_fieldtype",
- MY_MAX(64, output_str_length));
+ func_items[9]= new (mem_root) Item_proc_string(thd, "Optimal_fieldtype",
+ MY_MAX(64,
+ output_str_length));
for (uint i = 0; i < array_elements(func_items); i++)
field_list.push_back(func_items[i]);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index c6d96ee74f6..7afe167738b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7304,7 +7304,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
set_new_item_local_context(thd, item_ident_2, nj_col_2->table_ref))
goto err;
- if (!(eq_cond= new Item_func_eq(thd, item_ident_1, item_ident_2)))
+ if (!(eq_cond= new (thd->mem_root) Item_func_eq(thd, item_ident_1, item_ident_2)))
goto err; /* Out of memory. */
if (field_1 && field_1->vcol_info)
@@ -7651,7 +7651,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
/* Add a TRUE condition to outer joins that have no common columns. */
if (table_ref_2->outer_join &&
!table_ref_1->on_expr && !table_ref_2->on_expr)
- table_ref_2->on_expr= new Item_int(thd, (longlong) 1, 1); // Always true.
+ table_ref_2->on_expr= new (thd->mem_root) Item_int(thd, (longlong) 1, 1); // Always true.
/* Change this table reference to become a leaf for name resolution. */
if (left_neighbor)
@@ -7816,7 +7816,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
Item_int do not need fix_fields() because it is basic constant.
*/
- it.replace(new Item_int(thd, "Not_used", (longlong) 1,
+ it.replace(new (thd->mem_root) Item_int(thd, "Not_used", (longlong) 1,
MY_INT64_NUM_DECIMAL_DIGITS));
}
else if (insert_fields(thd, ((Item_field*) item)->context,
@@ -8510,7 +8510,7 @@ void wrap_ident(THD *thd, Item **conds)
DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM);
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
- if ((wrapper= new Item_direct_ref_to_ident(thd, (Item_ident *) (*conds))))
+ if ((wrapper= new (thd->mem_root) Item_direct_ref_to_ident(thd, (Item_ident *) (*conds))))
(*conds)= (Item*) wrapper;
if (arena)
thd->restore_active_arena(arena, &backup);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 253d1cd67c1..9d3bdf51b8c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2456,10 +2456,10 @@ int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is
void THD::make_explain_json_field_list(List<Item> &field_list, bool is_analyze)
{
- Item *item= new Item_empty_string(this, (is_analyze ?
- "ANALYZE" :
- "EXPLAIN"),
- 78, system_charset_info);
+ Item *item= new (mem_root) Item_empty_string(this, (is_analyze ?
+ "ANALYZE" :
+ "EXPLAIN"),
+ 78, system_charset_info);
field_list.push_back(item);
}
@@ -2477,59 +2477,70 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
{
Item *item;
CHARSET_INFO *cs= system_charset_info;
- field_list.push_back(item= new Item_return_int(this, "id", 3,
- MYSQL_TYPE_LONGLONG));
+ field_list.push_back(item= new (mem_root)
+ Item_return_int(this, "id", 3,
+ MYSQL_TYPE_LONGLONG));
item->maybe_null= 1;
- field_list.push_back(new Item_empty_string(this, "select_type", 19, cs));
- field_list.push_back(item= new Item_empty_string(this, "table", NAME_CHAR_LEN,
- cs));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(this, "select_type", 19, cs));
+ field_list.push_back(item= new (mem_root)
+ Item_empty_string(this, "table", NAME_CHAR_LEN, cs));
item->maybe_null= 1;
if (explain_flags & DESCRIBE_PARTITIONS)
{
/* Maximum length of string that make_used_partitions_str() can produce */
- item= new Item_empty_string(this, "partitions",
- MAX_PARTITIONS * (1 + FN_LEN), cs);
+ item= new (mem_root) Item_empty_string(this, "partitions",
+ MAX_PARTITIONS * (1 + FN_LEN), cs);
field_list.push_back(item);
item->maybe_null= 1;
}
- field_list.push_back(item= new Item_empty_string(this, "type", 10, cs));
+ field_list.push_back(item= new (mem_root)
+ Item_empty_string(this, "type", 10, cs));
item->maybe_null= 1;
- field_list.push_back(item=new Item_empty_string(this, "possible_keys",
- NAME_CHAR_LEN*MAX_KEY, cs));
+ field_list.push_back(item= new (mem_root)
+ Item_empty_string(this, "possible_keys",
+ NAME_CHAR_LEN*MAX_KEY, cs));
item->maybe_null=1;
- field_list.push_back(item=new Item_empty_string(this, "key", NAME_CHAR_LEN,
- cs));
+ field_list.push_back(item=new (mem_root)
+ Item_empty_string(this, "key", NAME_CHAR_LEN, cs));
item->maybe_null=1;
- field_list.push_back(item=new Item_empty_string(this, "key_len",
- NAME_CHAR_LEN*MAX_KEY));
+ field_list.push_back(item=new (mem_root)
+ Item_empty_string(this, "key_len",
+ NAME_CHAR_LEN*MAX_KEY));
item->maybe_null=1;
- field_list.push_back(item=new Item_empty_string(this, "ref",
- NAME_CHAR_LEN*MAX_REF_PARTS,
- cs));
+ field_list.push_back(item=new (mem_root)
+ Item_empty_string(this, "ref",
+ NAME_CHAR_LEN*MAX_REF_PARTS,
+ cs));
item->maybe_null=1;
- field_list.push_back(item= new Item_return_int(this, "rows", 10,
- MYSQL_TYPE_LONGLONG));
+ field_list.push_back(item= new (mem_root)
+ Item_return_int(this, "rows", 10,
+ MYSQL_TYPE_LONGLONG));
if (is_analyze)
{
- field_list.push_back(item= new Item_float(this, "r_rows", 0.1234, 10, 4));
+ field_list.push_back(item= new (mem_root)
+ Item_float(this, "r_rows", 0.1234, 10, 4));
item->maybe_null=1;
}
if (is_analyze || (explain_flags & DESCRIBE_EXTENDED))
{
- field_list.push_back(item= new Item_float(this, "filtered", 0.1234, 2, 4));
+ field_list.push_back(item= new (mem_root)
+ Item_float(this, "filtered", 0.1234, 2, 4));
item->maybe_null=1;
}
if (is_analyze)
{
- field_list.push_back(item= new Item_float(this, "r_filtered", 0.1234, 2,
- 4));
+ field_list.push_back(item= new (mem_root)
+ Item_float(this, "r_filtered", 0.1234, 2,
+ 4));
item->maybe_null=1;
}
item->maybe_null= 1;
- field_list.push_back(new Item_empty_string(this, "Extra", 255, cs));
+ field_list.push_back(new (mem_root)
+ Item_empty_string(this, "Extra", 255, cs));
}
@@ -3807,7 +3818,7 @@ Statement_map::~Statement_map()
bool my_var_user::set(THD *thd, Item *item)
{
- Item_func_set_user_var *suv= new Item_func_set_user_var(thd, name, item);
+ Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, name, item);
suv->save_item_result(item);
return suv->fix_fields(thd, 0) || suv->update();
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 23e146c6750..09cdbceebed 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5334,6 +5334,13 @@ inline bool add_group_to_list(THD *thd, Item *item, bool asc)
return thd->lex->current_select->add_group_to_list(thd, item, asc);
}
+inline Item *and_conds(THD *thd, Item *a, Item *b)
+{
+ if (!b) return a;
+ if (!a) return b;
+ return new (thd->mem_root) Item_cond_and(thd, a, b);
+}
+
/* inline handler methods that need to know TABLE and THD structures */
inline void handler::increment_statistics(ulong SSV::*offset) const
{
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index e0776a661bc..f7eb6dd6a1f 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -814,13 +814,15 @@ const LEX_STRING warning_level_names[]=
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
{
List<Item> field_list;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_warnings");
DBUG_ASSERT(thd->get_stmt_da()->is_warning_info_read_only());
- field_list.push_back(new Item_empty_string(thd, "Level", 7));
- field_list.push_back(new Item_return_int(thd, "Code", 4, MYSQL_TYPE_LONG));
- field_list.push_back(new Item_empty_string(thd, "Message",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Level", 7));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Code", 4,
+ MYSQL_TYPE_LONG));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Message",
MYSQL_ERRMSG_SIZE));
if (thd->protocol->send_result_set_metadata(&field_list,
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 64af808301c..a983f2598e9 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -227,8 +227,8 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy
CHARSET_INFO *cs= system_charset_info;
List<Item> item_list;
String *buf= &writer.output;
- item_list.push_back(new Item_string(output->thd, buf->ptr(), buf->length(),
- cs));
+ item_list.push_back(new (thd->mem_root)
+ Item_string(thd, buf->ptr(), buf->length(), cs));
output->send_data(item_list);
}
@@ -260,13 +260,13 @@ bool Explain_query::print_explain_str(THD *thd, String *out_str,
static void push_str(THD *thd, List<Item> *item_list, const char *str)
{
- item_list->push_back(new Item_string_sys(thd, str));
+ item_list->push_back(new (thd->mem_root) Item_string_sys(thd, str));
}
static void push_string(THD *thd, List<Item> *item_list, String *str)
{
- item_list->push_back(new Item_string_sys(thd, str->ptr(), str->length()));
+ item_list->push_back(new (thd->mem_root) Item_string_sys(thd, str->ptr(), str->length()));
}
static void push_string_list(THD *thd, List<Item> *item_list,
@@ -318,25 +318,26 @@ int print_explain_row(select_result_sink *result,
const char *extra)
{
THD *thd= result->thd;
- Item *item_null= new Item_null(thd);
+ Item *item_null= new (thd->mem_root) Item_null(thd);
List<Item> item_list;
Item *item;
+ MEM_ROOT *mem_root= thd->mem_root;
- item_list.push_back(new Item_int(thd, (int32) select_number));
- item_list.push_back(new Item_string_sys(thd, select_type));
- item_list.push_back(new Item_string_sys(thd, table_name));
+ item_list.push_back(new (mem_root) Item_int(thd, (int32) select_number));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, select_type));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, table_name));
if (options & DESCRIBE_PARTITIONS)
{
if (partitions)
{
- item_list.push_back(new Item_string_sys(thd, partitions));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, partitions));
}
else
item_list.push_back(item_null);
}
const char *jtype_str= join_type_str[jtype];
- item_list.push_back(new Item_string_sys(thd, jtype_str));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, jtype_str));
/* 'possible_keys' */
if (possible_keys && !possible_keys->is_empty())
@@ -348,21 +349,21 @@ int print_explain_row(select_result_sink *result,
item_list.push_back(item_null);
/* 'index */
- item= index ? new Item_string_sys(thd, index) : item_null;
+ item= index ? new (mem_root) Item_string_sys(thd, index) : item_null;
item_list.push_back(item);
/* 'key_len */
- item= key_len ? new Item_string_sys(thd, key_len) : item_null;
+ item= key_len ? new (mem_root) Item_string_sys(thd, key_len) : item_null;
item_list.push_back(item);
/* 'ref' */
- item= ref ? new Item_string_sys(thd, ref) : item_null;
+ item= ref ? new (mem_root) Item_string_sys(thd, ref) : item_null;
item_list.push_back(item);
/* 'rows' */
if (rows)
{
- item_list.push_back(new Item_int(thd, *rows,
+ item_list.push_back(new (mem_root) Item_int(thd, *rows,
MY_INT64_NUM_DECIMAL_DIGITS));
}
else
@@ -372,7 +373,7 @@ int print_explain_row(select_result_sink *result,
if (is_analyze)
{
if (r_rows)
- item_list.push_back(new Item_float(thd, *r_rows, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, *r_rows, 2));
else
item_list.push_back(item_null);
}
@@ -380,15 +381,15 @@ int print_explain_row(select_result_sink *result,
/* 'filtered' */
const double filtered=100.0;
if (options & DESCRIBE_EXTENDED || is_analyze)
- item_list.push_back(new Item_float(thd, filtered, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, filtered, 2));
/* 'r_filtered' */
if (is_analyze)
- item_list.push_back(new Item_float(thd, r_filtered, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, r_filtered, 2));
/* 'Extra' */
if (extra)
- item_list.push_back(new Item_string_sys(thd, extra));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, extra));
else
item_list.push_back(item_null);
@@ -436,6 +437,7 @@ int Explain_union::print_explain(Explain_query *query,
THD *thd= output->thd;
//CHARSET_INFO *cs= system_charset_info;
char table_name_buffer[SAFE_NAME_LEN];
+ MEM_ROOT *mem_root= thd->mem_root;
/* print all UNION children, in order */
for (int i= 0; i < (int) union_members.elements(); i++)
@@ -449,7 +451,7 @@ int Explain_union::print_explain(Explain_query *query,
/* Print a line with "UNION RESULT" */
List<Item> item_list;
- Item *item_null= new Item_null(thd);
+ Item *item_null= new (mem_root) Item_null(thd);
/* `id` column */
item_list.push_back(item_null);
@@ -459,7 +461,7 @@ int Explain_union::print_explain(Explain_query *query,
/* `table` column: something like "<union1,2>" */
uint len= make_union_table_name(table_name_buffer);
- item_list.push_back(new Item_string_sys(thd, table_name_buffer, len));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, table_name_buffer, len));
/* `partitions` column */
if (explain_flags & DESCRIBE_PARTITIONS)
@@ -487,7 +489,7 @@ int Explain_union::print_explain(Explain_query *query,
if (is_analyze)
{
double avg_rows= fake_select_lex_tracker.get_avg_rows();
- item_list.push_back(new Item_float(thd, avg_rows, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2));
}
/* `filtered` */
@@ -504,7 +506,7 @@ int Explain_union::print_explain(Explain_query *query,
{
extra_buf.append(STRING_WITH_LEN("Using filesort"));
}
- item_list.push_back(new Item_string_sys(thd, extra_buf.ptr(),
+ item_list.push_back(new (mem_root) Item_string_sys(thd, extra_buf.ptr(),
extra_buf.length()));
//output->unit.offset_limit_cnt= 0;
@@ -701,13 +703,15 @@ int Explain_select::print_explain(Explain_query *query,
uint8 explain_flags, bool is_analyze)
{
THD *thd= output->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
+
if (message)
{
List<Item> item_list;
- Item *item_null= new Item_null(thd);
+ Item *item_null= new (mem_root) Item_null(thd);
- item_list.push_back(new Item_int(thd, (int32) select_id));
- item_list.push_back(new Item_string_sys(thd, select_type));
+ item_list.push_back(new (mem_root) Item_int(thd, (int32) select_id));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, select_type));
for (uint i=0 ; i < 7; i++)
item_list.push_back(item_null);
if (explain_flags & DESCRIBE_PARTITIONS)
@@ -724,7 +728,7 @@ int Explain_select::print_explain(Explain_query *query,
item_list.push_back(item_null);
}
- item_list.push_back(new Item_string_sys(thd, message));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, message));
if (output->send_data(item_list))
return 1;
@@ -1112,13 +1116,13 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
bool using_temporary, bool using_filesort)
{
THD *thd= output->thd;
- //CHARSET_INFO *cs= system_charset_info;
+ MEM_ROOT *mem_root= thd->mem_root;
List<Item> item_list;
- Item *item_null= new Item_null(thd);
+ Item *item_null= new (mem_root) Item_null(thd);
/* `id` column */
- item_list.push_back(new Item_int(thd, (int32) select_id));
+ item_list.push_back(new (mem_root) Item_int(thd, (int32) select_id));
/* `select_type` column */
push_str(thd, &item_list, select_type);
@@ -1183,7 +1187,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
/* `rows` */
if (rows_set)
{
- item_list.push_back(new Item_int(thd, (longlong) (ulonglong) rows,
+ item_list.push_back(new (mem_root) Item_int(thd, (longlong) (ulonglong) rows,
MY_INT64_NUM_DECIMAL_DIGITS));
}
else
@@ -1199,7 +1203,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
else
{
double avg_rows= tracker.get_avg_rows();
- item_list.push_back(new Item_float(thd, avg_rows, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2));
}
}
@@ -1208,7 +1212,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
{
if (filtered_set)
{
- item_list.push_back(new Item_float(thd, filtered, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, filtered, 2));
}
else
item_list.push_back(item_null);
@@ -1226,7 +1230,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
double r_filtered= tracker.get_filtered_after_where();
if (bka_type.is_using_jbuf())
r_filtered *= jbuf_tracker.get_filtered_after_where();
- item_list.push_back(new Item_float(thd, r_filtered * 100.0, 2));
+ item_list.push_back(new (mem_root) Item_float(thd, r_filtered * 100.0, 2));
}
}
@@ -1260,7 +1264,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
extra_buf.append(STRING_WITH_LEN("Using filesort"));
}
- item_list.push_back(new Item_string_sys(thd, extra_buf.ptr(),
+ item_list.push_back(new (mem_root) Item_string_sys(thd, extra_buf.ptr(),
extra_buf.length()));
if (output->send_data(item_list))
diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc
index f9d2f599804..3ed33d97094 100644
--- a/sql/sql_expression_cache.cc
+++ b/sql/sql_expression_cache.cc
@@ -161,7 +161,8 @@ void Expression_cache_tmptable::init()
goto error;
}
- if (!(cached_result= new Item_field(table_thd, cache_table->field[0])))
+ if (!(cached_result= new (table_thd->mem_root)
+ Item_field(table_thd, cache_table->field[0])))
{
DBUG_PRINT("error", ("Creating Item_field failed"));
goto error;
diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc
index b6c215d29b1..1713cb04ebc 100644
--- a/sql/sql_get_diagnostics.cc
+++ b/sql/sql_get_diagnostics.cc
@@ -270,7 +270,7 @@ Condition_information_item::make_utf8_string_item(THD *thd, const String *str)
String tmp(str->ptr(), str->length(), from_cs);
/* If necessary, convert the string (ignoring errors), then copy it over. */
uint conv_errors;
- return new Item_string(thd, &tmp, to_cs, &conv_errors,
+ return new (thd->mem_root) Item_string(thd, &tmp, to_cs, &conv_errors,
DERIVATION_COERCIBLE, MY_REPERTOIRE_UNICODE30);
}
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 0c74f3385eb..eb0e260c3f4 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -93,7 +93,7 @@ static bool init_fields(THD *thd, TABLE_LIST *tables,
for (; count-- ; find_fields++)
{
/* We have to use 'new' here as field will be re_linked on free */
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
"mysql", find_fields->table_name,
find_fields->field_name);
if (!(find_fields->field= find_field_in_tables(thd, field, tables, NULL,
@@ -450,11 +450,13 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
{
THD *thd= protocol->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_answer_1");
+
List<Item> field_list;
- field_list.push_back(new Item_empty_string(thd, "name", 64));
- field_list.push_back(new Item_empty_string(thd, "description", 1000));
- field_list.push_back(new Item_empty_string(thd, "example", 1000));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "description", 1000));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "example", 1000));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -494,13 +496,14 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
int send_header_2(Protocol *protocol, bool for_category)
{
THD *thd= protocol->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_header_2");
List<Item> field_list;
if (for_category)
- field_list.push_back(new Item_empty_string(thd, "source_category_name",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "source_category_name",
64));
- field_list.push_back(new Item_empty_string(thd, "name", 64));
- field_list.push_back(new Item_empty_string(thd, "is_it_category", 1));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "is_it_category", 1));
DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF));
}
@@ -628,11 +631,15 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
TABLE_LIST *tables, TABLE *table,
Field *pfname, int *error)
{
- Item *cond= new Item_func_like(thd, new Item_field(thd, pfname),
- new Item_string(thd, mask, mlen,
- pfname->charset()),
- new Item_string_ascii(thd, "\\"),
- FALSE);
+ MEM_ROOT *mem_root= thd->mem_root;
+ Item *cond= new (mem_root)
+ Item_func_like(thd,
+ new (mem_root)
+ Item_field(thd, pfname),
+ new (mem_root) Item_string(thd, mask, mlen,
+ pfname->charset()),
+ new (mem_root) Item_string_ascii(thd, "\\"),
+ FALSE);
if (thd->is_fatal_error)
return 0; // OOM
return prepare_simple_select(thd, cond, table, error);
@@ -767,11 +774,17 @@ bool mysqld_help(THD *thd, const char *mask)
{
Field *topic_cat_id= used_fields[help_topic_help_category_id].field;
Item *cond_topic_by_cat=
- new Item_func_equal(thd, new Item_field(thd, topic_cat_id),
- new Item_int(thd, (int32) category_id));
+ new (mem_root)
+ Item_func_equal(thd,
+ new (mem_root)
+ Item_field(thd, topic_cat_id),
+ new (mem_root)
+ Item_int(thd, (int32) category_id));
Item *cond_cat_by_cat=
- new Item_func_equal(thd, new Item_field(thd, cat_cat_id),
- new Item_int(thd, (int32) category_id));
+ new (mem_root)
+ Item_func_equal(thd,
+ new (mem_root) Item_field(thd, cat_cat_id),
+ new (mem_root) Item_int(thd, (int32) category_id));
if (!(select= prepare_simple_select(thd, cond_topic_by_cat,
tables[0].table, &error)))
goto error;
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 23357ac871d..46ef66bfd1b 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -318,7 +318,7 @@ void JOIN_CACHE::collect_info_on_key_args()
The allocated arrays are adjacent.
NOTES
- The memory is allocated in join->thd->memroot
+ The memory is allocated in join->thd->mem_root
RETURN VALUE
pointer to the first array
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a86465f73b0..b890bba0d24 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2672,6 +2672,7 @@ mysql_execute_command(THD *thd)
if (lex->set_arena_for_set_stmt(&backup))
goto error;
+ MEM_ROOT *mem_root= thd->mem_root;
while ((var= it++))
{
DBUG_ASSERT(var->is_system());
@@ -2699,8 +2700,8 @@ mysql_execute_command(THD *thd)
longlong val= v->var->val_int(&null_value, thd, v->type, &v->base);
o= new set_var(thd, v->type, v->var, &v->base,
(null_value ?
- (Item *) new Item_null(thd) :
- (Item *) new Item_int(thd, val)));
+ (Item *) new (mem_root) Item_null(thd) :
+ (Item *) new (mem_root) Item_int(thd, val)));
}
break;
case GET_UINT:
@@ -2711,8 +2712,8 @@ mysql_execute_command(THD *thd)
ulonglong val= v->var->val_int(&null_value, thd, v->type, &v->base);
o= new set_var(thd, v->type, v->var, &v->base,
(null_value ?
- (Item *) new Item_null(thd) :
- (Item *) new Item_uint(thd, val)));
+ (Item *) new (mem_root) Item_null(thd) :
+ (Item *) new (mem_root) Item_uint(thd, val)));
}
break;
case GET_DOUBLE:
@@ -2721,8 +2722,8 @@ mysql_execute_command(THD *thd)
double val= v->var->val_real(&null_value, thd, v->type, &v->base);
o= new set_var(thd, v->type, v->var, &v->base,
(null_value ?
- (Item *) new Item_null(thd) :
- (Item *) new Item_float(thd, val, 1)));
+ (Item *) new (mem_root) Item_null(thd) :
+ (Item *) new (mem_root) Item_float(thd, val, 1)));
}
break;
default:
@@ -2741,13 +2742,13 @@ mysql_execute_command(THD *thd)
val= v->var->val_str(&tmp, thd, v->type, &v->base);
if (val)
{
- Item_string *str= new Item_string(thd, v->var->charset(thd),
+ Item_string *str= new (mem_root) Item_string(thd, v->var->charset(thd),
val->ptr(), val->length());
o= new set_var(thd, v->type, v->var, &v->base, str);
}
else
o= new set_var(thd, v->type, v->var, &v->base,
- new Item_null(thd));
+ new (mem_root) Item_null(thd));
}
break;
}
@@ -3003,7 +3004,7 @@ mysql_execute_command(THD *thd)
my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE");
goto error;
}
- it= new Item_func_unix_timestamp(thd, it);
+ it= new (thd->mem_root) Item_func_unix_timestamp(thd, it);
it->fix_fields(thd, &it);
res = purge_master_logs_before_date(thd, (ulong)it->val_int());
break;
@@ -4088,7 +4089,7 @@ end_with_restore_list:
/* condition will be TRUE on SP re-excuting */
if (select_lex->item_list.elements != 0)
select_lex->item_list.empty();
- if (add_item_to_list(thd, new Item_null(thd)))
+ if (add_item_to_list(thd, new (thd->mem_root) Item_null(thd)))
goto error;
THD_STAGE_INFO(thd, stage_init);
@@ -7876,7 +7877,7 @@ Item *normalize_cond(THD *thd, Item *cond)
Item::Type type= cond->type();
if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
{
- cond= new Item_func_ne(thd, cond, new Item_int(thd, 0));
+ cond= new (thd->mem_root) Item_func_ne(thd, cond, new (thd->mem_root) Item_int(thd, 0));
}
}
return cond;
@@ -7911,7 +7912,7 @@ void add_join_on(THD *thd, TABLE_LIST *b, Item *expr)
right and left join. If called later, it happens if we add more
than one condition to the ON clause.
*/
- b->on_expr= new Item_cond_and(thd, b->on_expr,expr);
+ b->on_expr= new (thd->mem_root) Item_cond_and(thd, b->on_expr,expr);
}
b->on_expr->top_level_item();
}
@@ -8819,12 +8820,12 @@ Item *negate_expression(THD *thd, Item *expr)
if it is not boolean function then we have to emulate value of
not(not(a)), it will be a != 0
*/
- return new Item_func_ne(thd, arg, new Item_int(thd, (char*) "0", 0, 1));
+ return new (thd->mem_root) Item_func_ne(thd, arg, new (thd->mem_root) Item_int(thd, (char*) "0", 0, 1));
}
if ((negated= expr->neg_transformer(thd)) != 0)
return negated;
- return new Item_func_not(thd, expr);
+ return new (thd->mem_root) Item_func_not(thd, expr);
}
/**
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 57a8582644d..2b37cb172aa 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1897,14 +1897,17 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt,
static bool mysql_test_multidelete(Prepared_statement *stmt,
TABLE_LIST *tables)
{
- stmt->thd->lex->current_select= &stmt->thd->lex->select_lex;
- if (add_item_to_list(stmt->thd, new Item_null(stmt->thd)))
+ THD *thd= stmt->thd;
+
+ thd->lex->current_select= &thd->lex->select_lex;
+ if (add_item_to_list(thd, new (thd->mem_root)
+ Item_null(thd)))
{
my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 0);
goto error;
}
- if (multi_delete_precheck(stmt->thd, tables) ||
+ if (multi_delete_precheck(thd, tables) ||
select_like_stmt_test_with_open(stmt, tables,
&mysql_multi_delete_prepare,
OPTION_SETUP_TABLES_DONE))
@@ -3369,7 +3372,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
DBUG_RETURN(TRUE);
/*
- alloc_query() uses thd->memroot && thd->query, so we should call
+ alloc_query() uses thd->mem_root && thd->query, so we should call
both of backup_statement() and backup_query_arena() here.
*/
thd->set_n_backup_statement(this, &stmt_backup);
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 0f29add7079..28ceccc695a 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -121,7 +121,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
continue;
field_info= &schema_table->fields_info[i];
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
@@ -389,13 +389,14 @@ bool PROFILING::show_profiles()
DBUG_ENTER("PROFILING::show_profiles");
QUERY_PROFILE *prof;
List<Item> field_list;
+ MEM_ROOT *mem_root= thd->mem_root;
- field_list.push_back(new Item_return_int(thd, "Query_ID", 10,
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Query_ID", 10,
MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int(thd, "Duration",
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Duration",
TIME_FLOAT_DIGITS - 1,
MYSQL_TYPE_DOUBLE));
- field_list.push_back(new Item_empty_string(thd, "Query", 40));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Query", 40));
if (thd->protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 263a982db30..ce19bf0846b 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -4000,13 +4000,15 @@ err:
bool show_binlog_info(THD* thd)
{
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("show_binlog_info");
+
List<Item> field_list;
- field_list.push_back(new Item_empty_string(thd, "File", FN_REFLEN));
- field_list.push_back(new Item_return_int(thd, "Position", 20,
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "File", FN_REFLEN));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "Position", 20,
MYSQL_TYPE_LONGLONG));
- field_list.push_back(new Item_empty_string(thd, "Binlog_Do_DB", 255));
- field_list.push_back(new Item_empty_string(thd, "Binlog_Ignore_DB", 255));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Binlog_Do_DB", 255));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Binlog_Ignore_DB", 255));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -4049,6 +4051,7 @@ bool show_binlogs(THD* thd)
uint length;
int cur_dir_len;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("show_binlogs");
if (!mysql_bin_log.is_open())
@@ -4057,9 +4060,9 @@ bool show_binlogs(THD* thd)
DBUG_RETURN(TRUE);
}
- field_list.push_back(new Item_empty_string(thd, "Log_name", 255));
- field_list.push_back(new Item_return_int(thd, "File_size", 20,
- MYSQL_TYPE_LONGLONG));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Log_name", 255));
+ field_list.push_back(new (mem_root) Item_return_int(thd, "File_size", 20,
+ MYSQL_TYPE_LONGLONG));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c887e67bdf6..5429893d58a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -512,9 +512,9 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
direct_ref= TRUE;
new_ref= direct_ref ?
- new Item_direct_ref(thd, ref->context, item_ref, ref->table_name,
+ new (thd->mem_root) Item_direct_ref(thd, ref->context, item_ref, ref->table_name,
ref->field_name, ref->alias_name_used) :
- new Item_ref(thd, ref->context, item_ref, ref->table_name,
+ new (thd->mem_root) Item_ref(thd, ref->context, item_ref, ref->table_name,
ref->field_name, ref->alias_name_used);
if (!new_ref)
return TRUE;
@@ -892,7 +892,7 @@ JOIN::prepare(Item ***rref_pointer_array,
if ((*ord->item)->type() == Item::FIELD_ITEM &&
(*ord->item)->field_type() == MYSQL_TYPE_BIT)
{
- Item_field *field= new Item_field(thd, *(Item_field**)ord->item);
+ Item_field *field= new (thd->mem_root) Item_field(thd, *(Item_field**)ord->item);
int el= all_fields.elements;
ref_pointer_array[el]= field;
all_fields.push_front(field);
@@ -1150,7 +1150,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S
conds= having;
having= 0;
}
- else if ((conds=new Item_cond_and(conds,having)))
+ else if ((conds=new (thd->mem_root) Item_cond_and(conds,having)))
{
/*
Item_cond_and can't be fixed after creation, so we do not check
@@ -1408,7 +1408,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S
if (!conds && outer_join)
{
/* Handle the case where we have an OUTER JOIN without a WHERE */
- conds= new Item_int(thd, (longlong) 1,1); // Always true
+ conds= new (thd->mem_root) Item_int(thd, (longlong) 1,1); // Always true
}
if (impossible_where)
@@ -1544,7 +1544,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S
if (conds && const_table_map != found_const_table_map &&
(select_options & SELECT_DESCRIBE))
{
- conds=new Item_int(thd, (longlong) 0, 1); // Always false
+ conds=new (thd->mem_root) Item_int(thd, (longlong) 0, 1); // Always false
}
/* Cache constant expressions in WHERE, HAVING, ON clauses. */
@@ -2976,7 +2976,7 @@ void JOIN::exec_inner()
else
{
if (!(curr_table->select->cond=
- new Item_cond_and(thd, curr_table->select->cond,
+ new (thd->mem_root) Item_cond_and(thd, curr_table->select->cond,
sort_table_cond)))
DBUG_VOID_RETURN;
}
@@ -2985,7 +2985,7 @@ void JOIN::exec_inner()
if (sort_table_cond->type() == Item::COND_ITEM)
sort_table_cond= sort_table_cond->copy_andor_structure(thd);
if (!(curr_table->pre_idx_push_select_cond=
- new Item_cond_and(thd, curr_table->pre_idx_push_select_cond,
+ new (thd->mem_root) Item_cond_and(thd, curr_table->pre_idx_push_select_cond,
sort_table_cond)))
DBUG_VOID_RETURN;
}
@@ -3888,7 +3888,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
if (join->cond_value == Item::COND_FALSE)
{
join->impossible_where= true;
- conds= new Item_int(join->thd, (longlong) 0, 1);
+ conds= new (join->thd->mem_root) Item_int(join->thd, (longlong) 0, 1);
}
join->cond_equal= NULL;
@@ -4838,7 +4838,7 @@ Item_func_null_predicate::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
/* column_name IS [NOT] NULL */
if (is_local_field(args[0]) && !(used_tables() & OUTER_REF_TABLE_BIT))
{
- Item *tmp= new Item_null(join->thd);
+ Item *tmp= new (join->thd->mem_root) Item_null(join->thd);
if (unlikely(!tmp)) // Should never be true
return;
add_key_equal_fields(join, key_fields, *and_level, this,
@@ -9156,7 +9156,7 @@ inline void add_cond_and_fix(THD *thd, Item **e1, Item *e2)
if (!e2)
return;
Item *res;
- if ((res= new Item_cond_and(thd, *e1, e2)))
+ if ((res= new (thd->mem_root) Item_cond_and(thd, *e1, e2)))
{
res->fix_fields(thd, 0);
res->update_used_tables();
@@ -9257,7 +9257,8 @@ static void add_not_null_conds(JOIN *join)
*/
if (!referred_tab)
continue;
- if (!(notnull= new Item_func_isnotnull(join->thd, not_null_item)))
+ if (!(notnull= new (join->thd->mem_root)
+ Item_func_isnotnull(join->thd, not_null_item)))
DBUG_VOID_RETURN;
/*
We need to do full fix_fields() call here in order to have correct
@@ -9321,7 +9322,7 @@ add_found_match_trig_cond(THD *thd, JOIN_TAB *tab, COND *cond,
if (tab == root_tab)
return cond;
if ((tmp= add_found_match_trig_cond(thd, tab->first_upper, cond, root_tab)))
- tmp= new Item_func_trig_cond(thd, tmp, &tab->found);
+ tmp= new (thd->mem_root) Item_func_trig_cond(thd, tmp, &tab->found);
if (tmp)
{
tmp->quick_fix_field();
@@ -9673,7 +9674,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
below to check if we should use 'quick' instead.
*/
DBUG_PRINT("info", ("Item_int"));
- tmp= new Item_int(thd, (longlong) 1, 1); // Always true
+ tmp= new (thd->mem_root) Item_int(thd, (longlong) 1, 1); // Always true
}
}
@@ -9906,13 +9907,13 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
(table_map) 0, -1, FALSE, FALSE);
if (!tmp_cond)
continue;
- tmp_cond= new Item_func_trig_cond(thd, tmp_cond,
+ tmp_cond= new (thd->mem_root) Item_func_trig_cond(thd, tmp_cond,
&cond_tab->not_null_compl);
if (!tmp_cond)
DBUG_RETURN(1);
tmp_cond->quick_fix_field();
cond_tab->select_cond= !cond_tab->select_cond ? tmp_cond :
- new Item_cond_and(thd, cond_tab->select_cond,
+ new (thd->mem_root) Item_cond_and(thd, cond_tab->select_cond,
tmp_cond);
if (!cond_tab->select_cond)
DBUG_RETURN(1);
@@ -10013,7 +10014,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
the null complemented row.
*/
DBUG_PRINT("info", ("Item_func_trig_cond"));
- tmp_cond= new Item_func_trig_cond(thd, tmp_cond,
+ tmp_cond= new (thd->mem_root) Item_func_trig_cond(thd, tmp_cond,
&first_inner_tab->
not_null_compl);
DBUG_PRINT("info", ("Item_func_trig_cond 0x%lx",
@@ -10024,7 +10025,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
DBUG_PRINT("info", ("Item_cond_and"));
*sel_cond_ref= !(*sel_cond_ref) ?
tmp_cond :
- new Item_cond_and(thd, *sel_cond_ref, tmp_cond);
+ new (thd->mem_root) Item_cond_and(thd, *sel_cond_ref, tmp_cond);
DBUG_PRINT("info", ("Item_cond_and 0x%lx",
(ulong)(*sel_cond_ref)));
if (!(*sel_cond_ref))
@@ -11012,7 +11013,8 @@ void JOIN_TAB::remove_redundant_bnl_scan_conds()
{
List_iterator<Item> pushed_cond_li(*((Item_cond*) select_cond)->argument_list());
Item *pushed_item;
- Item_cond_and *reduced_select_cond= new Item_cond_and(join->thd);
+ Item_cond_and *reduced_select_cond= new (join->thd->mem_root)
+ Item_cond_and(join->thd);
if (is_cond_and(cache_select->cond))
{
@@ -12739,7 +12741,7 @@ static bool check_row_equality(THD *thd, Item *left_row, Item_row *right_row,
if (!is_converted)
{
Item_func_eq *eq_item;
- if (!(eq_item= new Item_func_eq(thd, left_item, right_item)) ||
+ if (!(eq_item= new (thd->mem_root) Item_func_eq(thd, left_item, right_item)) ||
eq_item->set_cmp_func_and_arg_cmp_context())
return FALSE;
eq_item->quick_fix_field();
@@ -13039,7 +13041,7 @@ COND *Item_func_eq::build_equal_items(THD *thd,
Here a new AND level must be created. It can happen only
when a row equality is processed as a standalone predicate.
*/
- Item_cond_and *and_cond= new Item_cond_and(thd, eq_list);
+ Item_cond_and *and_cond= new (thd->mem_root) Item_cond_and(thd, eq_list);
and_cond->quick_fix_field();
List<Item> *cond_args= and_cond->argument_list();
List_iterator_fast<Item_equal> it(cond_equal.current_level);
@@ -13398,7 +13400,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
List<Item> eq_list;
Item_func_eq *eq_item= 0;
if (((Item *) item_equal)->const_item() && !item_equal->val_int())
- return new Item_int(thd, (longlong) 0, 1);
+ return new (thd->mem_root) Item_int(thd, (longlong) 0, 1);
Item *item_const= item_equal->get_const();
Item_equal_fields_iterator it(*item_equal);
Item *head;
@@ -13463,7 +13465,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
Upper item also has "field_item=const".
Don't produce equality if const is equal to item_const.
*/
- Item_func_eq *func= new Item_func_eq(thd, item_const, upper_const);
+ Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, item_const, upper_const);
func->set_cmp_func();
func->quick_fix_field();
if (func->val_int())
@@ -13512,7 +13514,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
if (head_real_item->type() == Item::FIELD_ITEM)
head_item= head_real_item;
- eq_item= new Item_func_eq(thd, field_item->real_item(), head_item);
+ eq_item= new (thd->mem_root) Item_func_eq(thd, field_item->real_item(), head_item);
if (!eq_item || eq_item->set_cmp_func())
return 0;
@@ -13545,7 +13547,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
switch (eq_list.elements)
{
case 0:
- res= cond ? cond : new Item_int(thd, (longlong) 1, 1);
+ res= cond ? cond : new (thd->mem_root) Item_int(thd, (longlong) 1, 1);
break;
case 1:
if (!cond || cond->type() == Item::INT_ITEM)
@@ -13568,7 +13570,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels,
}
}
if (!res)
- res= new Item_cond_and(thd, eq_list);
+ res= new (thd->mem_root) Item_cond_and(thd, eq_list);
if (res)
{
res->quick_fix_field();
@@ -15405,8 +15407,8 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
query_cache_abort(&thd->query_cache_tls);
#endif
COND *new_cond, *cond= this;
- if ((new_cond= new Item_func_eq(thd, args[0],
- new Item_int(thd, "last_insert_id()",
+ if ((new_cond= new (thd->mem_root) Item_func_eq(thd, args[0],
+ new (thd->mem_root) Item_int(thd, "last_insert_id()",
thd->read_first_successful_insert_id_in_prev_stmt(),
MY_INT64_NUM_DECIMAL_DIGITS))))
{
@@ -16265,7 +16267,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
string_total_length+= new_field->pack_length();
}
thd->mem_root= mem_root_save;
- arg= sum_item->set_arg(i, thd, new Item_field(thd, new_field));
+ arg= sum_item->set_arg(i, thd, new (thd->mem_root) Item_field(thd, new_field));
thd->mem_root= &table->mem_root;
if (param->force_not_null_cols)
{
@@ -19849,7 +19851,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
/* Create new top level AND item */
- Item_cond_and *new_cond=new Item_cond_and(thd);
+ Item_cond_and *new_cond=new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -19884,7 +19886,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
}
else
{ // Or list
- Item_cond_or *new_cond=new Item_cond_or(thd);
+ Item_cond_or *new_cond=new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -19979,7 +19981,7 @@ make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables,
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
/* Create new top level AND item */
- Item_cond_and *new_cond= new Item_cond_and(thd);
+ Item_cond_and *new_cond= new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -20010,7 +20012,7 @@ make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables,
}
else
{ // Or list
- Item_cond_or *new_cond= new Item_cond_or(thd);
+ Item_cond_or *new_cond= new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -22035,7 +22037,7 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
converted to a LONG field. Original field will remain of the
BIT type and will be returned to a client.
*/
- Item_field *new_item= new Item_field(thd, (Item_field*)item);
+ Item_field *new_item= new (thd->mem_root) Item_field(thd, (Item_field*)item);
int el= all_fields.elements;
orig_ref_pointer_array[el]= new_item;
all_fields.push_front(new_item);
@@ -22445,7 +22447,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
((Item_ref *)pos)->ref_type() == Item_ref::AGGREGATE_REF))
{
Item_field *item;
- if (!(item= new Item_field(thd, ((Item_field*) real_pos))))
+ if (!(item= new (thd->mem_root) Item_field(thd, ((Item_field*) real_pos))))
goto err;
if (pos->type() == Item::REF_ITEM)
{
@@ -22458,7 +22460,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
pos= item;
if (item->field->flags & BLOB_FLAG)
{
- if (!(pos= new Item_copy_string(thd, pos)))
+ if (!(pos= new (thd->mem_root) Item_copy_string(thd, pos)))
goto err;
/*
Item_copy_string::copy for function can call
@@ -22513,7 +22515,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
on how the value is to be used: In some cases this may be an
argument in a group function, like: IF(ISNULL(col),0,COUNT(*))
*/
- if (!(pos=new Item_copy_string(thd, pos)))
+ if (!(pos=new (thd->mem_root) Item_copy_string(thd, pos)))
goto err;
if (i < border) // HAVING, ORDER and GROUP BY
{
@@ -22726,8 +22728,8 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
would access already-unlocked tables.
*/
Item_func_set_user_var* suv=
- new Item_func_set_user_var(thd, (Item_func_set_user_var*) item);
- Item_field *new_field= new Item_field(thd, field);
+ new (thd->mem_root) Item_func_set_user_var(thd, (Item_func_set_user_var*) item);
+ Item_field *new_field= new (thd->mem_root) Item_field(thd, field);
if (!suv || !new_field)
DBUG_RETURN(true); // Fatal error
/*
@@ -22750,7 +22752,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
item_field= ((Item_sum*) item)->result_item(thd, field);
else
- item_field= (Item *) new Item_field(thd, field);
+ item_field= (Item *) new (thd->mem_root) Item_field(thd, field);
if (!item_field)
DBUG_RETURN(true); // Fatal error
@@ -22990,7 +22992,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
if (!join_tab->ref.key_parts)
DBUG_RETURN(FALSE);
- Item_cond_and *cond= new Item_cond_and(thd);
+ Item_cond_and *cond= new (thd->mem_root) Item_cond_and(thd);
TABLE *table=join_tab->table;
int error= 0;
if (!cond)
@@ -23001,7 +23003,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
Field *field=table->field[table->key_info[join_tab->ref.key].key_part[i].
fieldnr-1];
Item *value=join_tab->ref.items[i];
- cond->add(new Item_func_equal(thd, new Item_field(thd, field), value));
+ cond->add(new (thd->mem_root) Item_func_equal(thd, new (thd->mem_root) Item_field(thd, field), value));
}
if (thd->is_fatal_error)
DBUG_RETURN(TRUE);
@@ -23118,7 +23120,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
if (item->eq(*group_tmp->item,0))
{
Item *new_item;
- if (!(new_item= new Item_ref(thd, context, group_tmp->item, 0,
+ if (!(new_item= new (thd->mem_root) Item_ref(thd, context, group_tmp->item, 0,
item->name)))
return 1; // fatal_error is set
thd->change_item_tree(arg, new_item);
@@ -23256,7 +23258,7 @@ bool JOIN::rollup_process_const_fields()
{
if (*group_tmp->item == item)
{
- Item* new_item= new Item_func_rollup_const(thd, item);
+ Item* new_item= new (thd->mem_root) Item_func_rollup_const(thd, item);
if (!new_item)
return 1;
new_item->fix_fields(thd, (Item **) 0);
@@ -23535,11 +23537,12 @@ int print_explain_message_line(select_result_sink *result,
const char *message)
{
THD *thd= result->thd;
- Item *item_null= new Item_null(thd);
+ MEM_ROOT *mem_root= thd->mem_root;
+ Item *item_null= new (mem_root) Item_null(thd);
List<Item> item_list;
- item_list.push_back(new Item_int(thd, (int32) select_number));
- item_list.push_back(new Item_string_sys(thd, select_type));
+ item_list.push_back(new (mem_root) Item_int(thd, (int32) select_number));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, select_type));
/* `table` */
item_list.push_back(item_null);
@@ -23554,7 +23557,7 @@ int print_explain_message_line(select_result_sink *result,
/* `rows` */
if (rows)
{
- item_list.push_back(new Item_int(thd, *rows,
+ item_list.push_back(new (mem_root) Item_int(thd, *rows,
MY_INT64_NUM_DECIMAL_DIGITS));
}
else
@@ -23574,7 +23577,7 @@ int print_explain_message_line(select_result_sink *result,
/* `Extra` */
if (message)
- item_list.push_back(new Item_string_sys(thd, message));
+ item_list.push_back(new (mem_root) Item_string_sys(thd, message));
else
item_list.push_back(item_null);
@@ -23629,11 +23632,13 @@ void JOIN_TAB::update_explain_data(uint idx)
join->select_lex->select_number != INT_MAX &&
join->select_lex->select_number != UINT_MAX)
{
- Explain_table_access *eta= new (join->thd->mem_root) Explain_table_access(join->thd->mem_root);
+ Explain_table_access *eta= new (join->thd->mem_root)
+ Explain_table_access(join->thd->mem_root);
save_explain_data(eta, join->const_table_map, join->select_distinct,
join->first_breadth_first_optimization_tab());
- Explain_select *sel= join->thd->lex->explain->get_select(join->select_lex->select_number);
+ Explain_select *sel= join->thd->lex->explain->
+ get_select(join->select_lex->select_number);
idx -= my_count_bits(join->eliminated_tables);
sel->replace_table(idx, eta);
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 71233af9845..ca69c0c23eb 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1852,7 +1852,7 @@ int join_read_record_no_init(JOIN_TAB *tab);
void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key);
inline Item * and_items(THD *thd, Item* cond, Item *item)
{
- return (cond ? (new Item_cond_and(thd, cond, item)) : item);
+ return (cond ? (new (thd->mem_root) Item_cond_and(thd, cond, item)) : item);
}
bool choose_plan(JOIN *join, table_map join_tables);
void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 53535a7a017..d38fb3a0f19 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -451,11 +451,12 @@ bool mysqld_show_authors(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_authors");
- field_list.push_back(new Item_empty_string(thd, "Name", 40));
- field_list.push_back(new Item_empty_string(thd, "Location", 40));
- field_list.push_back(new Item_empty_string(thd, "Comment", 512));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Name", 40));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Location", 40));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", 512));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -485,11 +486,12 @@ bool mysqld_show_contributors(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_contributors");
- field_list.push_back(new Item_empty_string(thd, "Name", 40));
- field_list.push_back(new Item_empty_string(thd, "Location", 40));
- field_list.push_back(new Item_empty_string(thd, "Comment", 512));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Name", 40));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Location", 40));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", 512));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -562,11 +564,12 @@ bool mysqld_show_privileges(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_privileges");
- field_list.push_back(new Item_empty_string(thd, "Privilege", 10));
- field_list.push_back(new Item_empty_string(thd, "Context", 15));
- field_list.push_back(new Item_empty_string(thd, "Comment", NAME_CHAR_LEN));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Privilege", 10));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Context", 15));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", NAME_CHAR_LEN));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -1092,6 +1095,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
String buffer(buff, sizeof(buff), system_charset_info);
List<Item> field_list;
bool error= TRUE;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_create");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->table_name));
@@ -1144,19 +1148,19 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (table_list->view)
{
- field_list.push_back(new Item_empty_string(thd, "View", NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string(thd, "Create View",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "View", NAME_CHAR_LEN));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Create View",
MY_MAX(buffer.length(),1024)));
- field_list.push_back(new Item_empty_string(thd, "character_set_client",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "character_set_client",
MY_CS_NAME_SIZE));
- field_list.push_back(new Item_empty_string(thd, "collation_connection",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "collation_connection",
MY_CS_NAME_SIZE));
}
else
{
- field_list.push_back(new Item_empty_string(thd, "Table", NAME_CHAR_LEN));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Table", NAME_CHAR_LEN));
// 1024 is for not to confuse old clients
- field_list.push_back(new Item_empty_string(thd, "Create Table",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Create Table",
MY_MAX(buffer.length(),1024)));
}
@@ -1215,6 +1219,7 @@ bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname,
#endif
Schema_specification_st create;
Protocol *protocol=thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysql_show_create_db");
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -1249,8 +1254,8 @@ bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname,
load_db_opt_by_name(thd, dbname->str, &create);
}
List<Item> field_list;
- field_list.push_back(new Item_empty_string(thd, "Database", NAME_CHAR_LEN));
- field_list.push_back(new Item_empty_string(thd, "Create Database", 1024));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Database", NAME_CHAR_LEN));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Create Database", 1024));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -1295,6 +1300,7 @@ void
mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
{
TABLE *table;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_list_fields");
DBUG_PRINT("enter",("table: %s",table_list->table_name));
@@ -1313,11 +1319,11 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
!wild_case_compare(system_charset_info, field->field_name,wild))
{
if (table_list->view)
- field_list.push_back(new Item_ident_for_show(thd, field,
+ field_list.push_back(new (mem_root) Item_ident_for_show(thd, field,
table_list->view_db.str,
table_list->view_name.str));
else
- field_list.push_back(new Item_field(thd, field));
+ field_list.push_back(new (mem_root) Item_field(thd, field));
}
}
restore_record(table, s->default_values); // Get empty record
@@ -2341,28 +2347,29 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
ulong max_query_length= (verbose ? thd->variables.max_allowed_packet :
PROCESS_LIST_WIDTH);
Protocol *protocol= thd->protocol;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_list_processes");
- field_list.push_back(new Item_int(thd, "Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
- field_list.push_back(new Item_empty_string(thd, "User",
+ field_list.push_back(new (mem_root) Item_int(thd, "Id", 0, MY_INT32_NUM_DECIMAL_DIGITS));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "User",
USERNAME_CHAR_LENGTH));
- field_list.push_back(new Item_empty_string(thd, "Host",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Host",
LIST_PROCESS_HOST_LEN));
- field_list.push_back(field=new Item_empty_string(thd, "db", NAME_CHAR_LEN));
+ field_list.push_back(field=new (mem_root) Item_empty_string(thd, "db", NAME_CHAR_LEN));
field->maybe_null=1;
- field_list.push_back(new Item_empty_string(thd, "Command", 16));
- field_list.push_back(field= new Item_return_int(thd, "Time", 7,
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "Command", 16));
+ field_list.push_back(field= new (mem_root) Item_return_int(thd, "Time", 7,
MYSQL_TYPE_LONG));
field->unsigned_flag= 0;
- field_list.push_back(field=new Item_empty_string(thd, "State", 30));
+ field_list.push_back(field=new (mem_root) Item_empty_string(thd, "State", 30));
field->maybe_null=1;
- field_list.push_back(field=new Item_empty_string(thd, "Info",
+ field_list.push_back(field=new (mem_root) Item_empty_string(thd, "Info",
max_query_length));
field->maybe_null=1;
if (!thd->variables.old_mode &&
!(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO))
{
- field_list.push_back(field= new Item_float(thd, "Progress", 0.0, 3, 7));
+ field_list.push_back(field= new (mem_root) Item_float(thd, "Progress", 0.0, 3, 7));
field->maybe_null= 0;
}
if (protocol->send_result_set_metadata(&field_list,
@@ -3541,7 +3548,7 @@ COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table)
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
/* Create new top level AND item */
- Item_cond_and *new_cond=new Item_cond_and(thd);
+ Item_cond_and *new_cond=new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -3564,7 +3571,7 @@ COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table)
}
else
{ // Or list
- Item_cond_or *new_cond= new Item_cond_or(thd);
+ Item_cond_or *new_cond= new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
@@ -7317,6 +7324,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
ST_FIELD_INFO *fields_info= schema_table->fields_info;
CHARSET_INFO *cs= system_charset_info;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("create_schema_table");
for (; fields_info->field_name; fields_info++)
@@ -7327,44 +7335,50 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_INT24:
- if (!(item= new Item_return_int(thd, fields_info->field_name,
- fields_info->field_length,
- fields_info->field_type,
- fields_info->value)))
+ if (!(item= new (mem_root)
+ Item_return_int(thd, fields_info->field_name,
+ fields_info->field_length,
+ fields_info->field_type,
+ fields_info->value)))
{
DBUG_RETURN(0);
}
item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
break;
case MYSQL_TYPE_DATE:
- if (!(item=new Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
- fields_info->field_type)))
+ if (!(item=new (mem_root)
+ Item_return_date_time(thd, fields_info->field_name,
+ strlen(fields_info->field_name),
+ fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_TIME:
- if (!(item=new Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
- fields_info->field_type)))
+ if (!(item=new (mem_root)
+ Item_return_date_time(thd, fields_info->field_name,
+ strlen(fields_info->field_name),
+ fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
- if (!(item=new Item_return_date_time(thd, fields_info->field_name,
- strlen(fields_info->field_name),
- fields_info->field_type)))
+ if (!(item=new (mem_root)
+ Item_return_date_time(thd, fields_info->field_name,
+ strlen(fields_info->field_name),
+ fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
- if ((item= new Item_float(thd, fields_info->field_name, 0.0,
- NOT_FIXED_DEC,
- fields_info->field_length)) == NULL)
+ if ((item= new (mem_root)
+ Item_float(thd, fields_info->field_name, 0.0,
+ NOT_FIXED_DEC,
+ fields_info->field_length)) == NULL)
DBUG_RETURN(NULL);
break;
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
- if (!(item= new Item_decimal(thd, (longlong) fields_info->value, false)))
+ if (!(item= new (mem_root)
+ Item_decimal(thd, (longlong) fields_info->value, false)))
{
DBUG_RETURN(0);
}
@@ -7372,7 +7386,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
Create a type holder, as we want the type of the item to defined
the type of the object, not the value
*/
- if (!(item= new Item_type_holder(thd, item)))
+ if (!(item= new (mem_root) Item_type_holder(thd, item)))
DBUG_RETURN(0);
item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED);
item->decimals= fields_info->field_length%10;
@@ -7388,8 +7402,9 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
- if (!(item= new Item_blob(thd, fields_info->field_name,
- fields_info->field_length)))
+ if (!(item= new (mem_root)
+ Item_blob(thd, fields_info->field_name,
+ fields_info->field_length)))
{
DBUG_RETURN(0);
}
@@ -7398,7 +7413,8 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
/* Don't let unimplemented types pass through. Could be a grave error. */
DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING);
- if (!(item= new Item_empty_string(thd, "", fields_info->field_length, cs)))
+ if (!(item= new (mem_root)
+ Item_empty_string(thd, "", fields_info->field_length, cs)))
{
DBUG_RETURN(0);
}
@@ -7457,8 +7473,8 @@ static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
if (field_info->old_name)
{
- Item_field *field= new Item_field(thd, context,
- NullS, NullS, field_info->field_name);
+ Item_field *field= new (thd->mem_root)
+ Item_field(thd, context, NullS, NullS, field_info->field_name);
if (field)
{
field->set_name(field_info->old_name,
@@ -7484,7 +7500,7 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
String buffer(tmp,sizeof(tmp), system_charset_info);
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (!field || add_item_to_list(thd, field))
return 1;
@@ -7519,7 +7535,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
buffer.append(lex->wild->ptr());
buffer.append(')');
}
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
@@ -7528,7 +7544,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
field_info= &schema_table->fields_info[3];
- field= new Item_field(thd, context, NullS, NullS, field_info->field_name);
+ field= new (thd->mem_root) Item_field(thd, context, NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
field->set_name(field_info->old_name, strlen(field_info->old_name),
@@ -7552,7 +7568,7 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
*field_num == 18 ||
*field_num == 19))
continue;
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
@@ -7577,7 +7593,7 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
@@ -7602,7 +7618,7 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
@@ -9113,10 +9129,8 @@ static bool show_create_trigger_impl(THD *thd,
int trigger_idx)
{
int ret_code;
-
Protocol *p= thd->protocol;
List<Item> fields;
-
LEX_STRING trg_name;
ulonglong trg_sql_mode;
LEX_STRING trg_sql_mode_str;
@@ -9124,8 +9138,8 @@ static bool show_create_trigger_impl(THD *thd,
LEX_STRING trg_client_cs_name;
LEX_STRING trg_connection_cl_name;
LEX_STRING trg_db_cl_name;
-
CHARSET_INFO *trg_client_cs;
+ MEM_ROOT *mem_root= thd->mem_root;
/*
TODO: Check privileges here. This functionality will be added by
@@ -9157,8 +9171,8 @@ static bool show_create_trigger_impl(THD *thd,
/* Send header. */
- fields.push_back(new Item_empty_string(thd, "Trigger", NAME_LEN));
- fields.push_back(new Item_empty_string(thd, "sql_mode",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "Trigger", NAME_LEN));
+ fields.push_back(new (mem_root) Item_empty_string(thd, "sql_mode",
trg_sql_mode_str.length));
{
@@ -9168,7 +9182,7 @@ static bool show_create_trigger_impl(THD *thd,
*/
Item_empty_string *stmt_fld=
- new Item_empty_string(thd, "SQL Original Statement",
+ new (mem_root) Item_empty_string(thd, "SQL Original Statement",
MY_MAX(trg_sql_original_stmt.length, 1024));
stmt_fld->maybe_null= TRUE;
@@ -9176,13 +9190,13 @@ static bool show_create_trigger_impl(THD *thd,
fields.push_back(stmt_fld);
}
- fields.push_back(new Item_empty_string(thd, "character_set_client",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "character_set_client",
MY_CS_NAME_SIZE));
- fields.push_back(new Item_empty_string(thd, "collation_connection",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "collation_connection",
MY_CS_NAME_SIZE));
- fields.push_back(new Item_empty_string(thd, "Database Collation",
+ fields.push_back(new (mem_root) Item_empty_string(thd, "Database Collation",
MY_CS_NAME_SIZE));
if (p->send_result_set_metadata(&fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 453239e3bf9..0bf42a862f3 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9626,9 +9626,9 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
*/
DBUG_ASSERT(! thd->in_sub_stmt);
- field_list.push_back(item = new Item_empty_string(thd, "Table", NAME_LEN*2));
+ field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Table", NAME_LEN*2));
item->maybe_null= 1;
- field_list.push_back(item= new Item_int(thd, "Checksum",
+ field_list.push_back(item= new (thd->mem_root) Item_int(thd, "Checksum",
(longlong) 1,
MY_INT64_NUM_DECIMAL_DIGITS));
item->maybe_null= 1;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 80c576bb993..356f68693bd 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -342,6 +342,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
bool is_union_select;
bool instantiate_tmp_table= false;
DBUG_ENTER("st_select_lex_unit::prepare");
+ DBUG_ASSERT(thd == thd_arg && thd == current_thd);
describe= MY_TEST(additional_options & SELECT_DESCRIBE);
@@ -484,7 +485,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
while ((item_tmp= it++))
{
/* Error's in 'new' will be detected after loop */
- types.push_back(new Item_type_holder(thd_arg, item_tmp));
+ types.push_back(new (thd_arg->mem_root)
+ Item_type_holder(thd_arg, item_tmp));
}
if (thd_arg->is_fatal_error)
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index ce211eca0e6..4f6371cc48f 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -148,7 +148,7 @@ static bool check_fields(THD *thd, List<Item> &items)
we make temporary copy of Item_field, to avoid influence of changing
result_field on Item_ref which refer on this field
*/
- thd->change_item_tree(it.ref(), new Item_field(thd, field));
+ thd->change_item_tree(it.ref(), new (thd->mem_root) Item_field(thd, field));
}
return FALSE;
}
@@ -1978,7 +1978,7 @@ loop_end:
table to be updated was created by mysql 4.1. Deny this.
*/
field->can_alter_field_type= 0;
- Item_field *ifield= new Item_field(join->thd, (Field *) field);
+ Item_field *ifield= new (thd->mem_root) Item_field(join->thd, (Field *) field);
if (!ifield)
DBUG_RETURN(1);
ifield->maybe_null= 0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c006a5fbdf0..b9850f7da91 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -284,8 +284,9 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
if (parsing_ctx->push_case_expr_id(case_expr_id))
return 1;
- i= new sp_instr_set_case_expr(sp->instructions(),
- parsing_ctx, case_expr_id, expr, lex);
+ i= new (lex->thd->mem_root)
+ sp_instr_set_case_expr(sp->instructions(), parsing_ctx, case_expr_id, expr,
+ lex);
sp->add_cont_backpatch(i);
return sp->add_instr(i);
@@ -307,10 +308,12 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple)
sp_instr_jump_if_not *i;
Item_case_expr *var;
Item *expr;
+ THD *thd= lex->thd;
if (simple)
{
- var= new Item_case_expr(lex->thd, ctx->get_current_case_expr_id());
+ var= new (thd->mem_root)
+ Item_case_expr(thd, ctx->get_current_case_expr_id());
#ifndef DBUG_OFF
if (var)
@@ -319,11 +322,11 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple)
}
#endif
- expr= new Item_func_eq(lex->thd, var, when);
- i= new sp_instr_jump_if_not(ip, ctx, expr, lex);
+ expr= new (thd->mem_root) Item_func_eq(thd, var, when);
+ i= new (thd->mem_root) sp_instr_jump_if_not(ip, ctx, expr, lex);
}
else
- i= new sp_instr_jump_if_not(ip, ctx, when, lex);
+ i= new (thd->mem_root) sp_instr_jump_if_not(ip, ctx, when, lex);
/*
BACKPATCH: Registering forward jump from
@@ -332,7 +335,7 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple)
*/
return !MY_TEST(i) ||
- sp->push_backpatch(i, ctx->push_label(lex->thd, empty_lex_str, 0)) ||
+ sp->push_backpatch(i, ctx->push_label(thd, empty_lex_str, 0)) ||
sp->add_cont_backpatch(i) ||
sp->add_instr(i);
}
@@ -348,7 +351,7 @@ int case_stmt_action_then(LEX *lex)
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
uint ip= sp->instructions();
- sp_instr_jump *i = new sp_instr_jump(ip, ctx);
+ sp_instr_jump *i= new (lex->thd->mem_root) sp_instr_jump(ip, ctx);
if (!MY_TEST(i) || sp->add_instr(i))
return 1;
@@ -411,7 +414,8 @@ set_system_variable(THD *thd, struct sys_var_with_base *tmp,
return TRUE;
}
- if (! (var= new set_var(thd, var_type, tmp->var, &tmp->base_name, val)))
+ if (! (var= new (thd->mem_root)
+ set_var(thd, var_type, tmp->var, &tmp->base_name, val)))
return TRUE;
return lex->var_list.push_back(var);
@@ -447,8 +451,9 @@ set_local_variable(THD *thd, sp_variable *spv, Item *val)
return TRUE;
}
- sp_set= new sp_instr_set(lex->sphead->instructions(), lex->spcont,
- spv->offset, it, spv->type, lex, TRUE);
+ sp_set= new (thd->mem_root)
+ sp_instr_set(lex->sphead->instructions(), lex->spcont,
+ spv->offset, it, spv->type, lex, TRUE);
return (sp_set == NULL || lex->sphead->add_instr(sp_set));
}
@@ -474,7 +479,7 @@ set_trigger_new_row(THD *thd, LEX_STRING *name, Item *val)
/* QQ: Shouldn't this be field's default value ? */
if (! val)
- val= new Item_null(thd);
+ val= new (thd->mem_root) Item_null(thd);
DBUG_ASSERT(lex->trg_chistics.action_time == TRG_ACTION_BEFORE &&
(lex->trg_chistics.event == TRG_EVENT_INSERT ||
@@ -488,8 +493,10 @@ set_trigger_new_row(THD *thd, LEX_STRING *name, Item *val)
if (trg_fld == NULL)
return TRUE;
- sp_fld= new sp_instr_set_trigger_field(lex->sphead->instructions(),
- lex->spcont, trg_fld, val, lex);
+ sp_fld= new (thd->mem_root)
+ sp_instr_set_trigger_field(lex->sphead->instructions(),
+ lex->spcont, trg_fld, val,
+ lex);
if (sp_fld == NULL)
return TRUE;
@@ -814,8 +821,8 @@ static bool sp_create_assignment_instr(THD *thd, bool no_lookahead)
sp_instr_stmt *i;
Lex_input_stream *lip= &thd->m_parser_state->m_lip;
- if (!(i= new sp_instr_stmt(sp->instructions(), lex->spcont,
- lex)))
+ if (!(i= new (thd->mem_root)
+ sp_instr_stmt(sp->instructions(), lex->spcont, lex)))
return true;
/*
@@ -2796,7 +2803,7 @@ sp_name:
{
MYSQL_YYABORT;
}
- $$= new sp_name($1, $3, true);
+ $$= new (thd->mem_root) sp_name($1, $3, true);
if ($$ == NULL)
MYSQL_YYABORT;
$$->init_qname(thd);
@@ -2811,7 +2818,7 @@ sp_name:
}
if (lex->copy_db_to(&db.str, &db.length))
MYSQL_YYABORT;
- $$= new sp_name(db, $1, false);
+ $$= new (lex->thd->mem_root) sp_name(db, $1, false);
if ($$ == NULL)
MYSQL_YYABORT;
$$->init_qname(thd);
@@ -3066,13 +3073,14 @@ sp_decl:
/* The last instruction is responsible for freeing LEX. */
- sp_instr_set *is= new sp_instr_set(lex->sphead->instructions(),
- pctx,
- var_idx,
- dflt_value_item,
- var_type,
- lex,
- last);
+ sp_instr_set *is= (new (lex->thd->mem_root)
+ sp_instr_set(lex->sphead->instructions(),
+ pctx,
+ var_idx,
+ dflt_value_item,
+ var_type,
+ lex,
+ last));
if (is == NULL ||
lex->sphead->add_instr(is))
MYSQL_YYABORT;
@@ -3112,7 +3120,8 @@ sp_decl:
sp_pcontext *ctx= lex->spcont;
sp_instr_hpush_jump *i=
- new sp_instr_hpush_jump(sp->instructions(), ctx, h);
+ new (lex->thd->mem_root) sp_instr_hpush_jump(sp->instructions(),
+ ctx, h);
if (i == NULL || sp->add_instr(i))
MYSQL_YYABORT;
@@ -3135,14 +3144,16 @@ sp_decl:
if ($2 == sp_handler::CONTINUE)
{
- i= new sp_instr_hreturn(sp->instructions(), ctx);
+ i= new (lex->thd->mem_root)
+ sp_instr_hreturn(sp->instructions(), ctx);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
}
else
{ /* EXIT or UNDO handler, just jump to the end of the block */
- i= new sp_instr_hreturn(sp->instructions(), ctx);
+ i= new (lex->thd->mem_root)
+ sp_instr_hreturn(sp->instructions(), ctx);
if (i == NULL ||
sp->add_instr(i) ||
sp->push_backpatch(i, lex->spcont->last_label())) /* Block end */
@@ -3169,8 +3180,9 @@ sp_decl:
delete $5;
MYSQL_YYABORT;
}
- i= new sp_instr_cpush(sp->instructions(), ctx, $5,
- ctx->current_cursor_count());
+ i= new (lex->thd->mem_root)
+ sp_instr_cpush(sp->instructions(), ctx, $5,
+ ctx->current_cursor_count());
if (i == NULL ||
sp->add_instr(i) ||
ctx->add_cursor($2))
@@ -3712,8 +3724,8 @@ sp_proc_stmt_statement:
lex->var_list.is_empty());
if (lex->sql_command != SQLCOM_SET_OPTION)
{
- sp_instr_stmt *i=new sp_instr_stmt(sp->instructions(),
- lex->spcont, lex);
+ sp_instr_stmt *i=new (lex->thd->mem_root)
+ sp_instr_stmt(sp->instructions(), lex->spcont, lex);
if (i == NULL)
MYSQL_YYABORT;
@@ -3754,8 +3766,9 @@ sp_proc_stmt_return:
{
sp_instr_freturn *i;
- i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
- sp->m_return_field_def.sql_type, lex);
+ i= new (lex->thd->mem_root)
+ sp_instr_freturn(sp->instructions(), lex->spcont, $3,
+ sp->m_return_field_def.sql_type, lex);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3811,7 +3824,8 @@ sp_proc_stmt_leave:
n= ctx->diff_handlers(lab->ctx, exclusive);
if (n)
{
- sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
+ sp_instr_hpop *hpop= new (lex->thd->mem_root)
+ sp_instr_hpop(ip++, ctx, n);
if (hpop == NULL)
MYSQL_YYABORT;
sp->add_instr(hpop);
@@ -3819,12 +3833,13 @@ sp_proc_stmt_leave:
n= ctx->diff_cursors(lab->ctx, exclusive);
if (n)
{
- sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
+ sp_instr_cpop *cpop= new (lex->thd->mem_root)
+ sp_instr_cpop(ip++, ctx, n);
if (cpop == NULL)
MYSQL_YYABORT;
sp->add_instr(cpop);
}
- i= new sp_instr_jump(ip, ctx);
+ i= new (lex->thd->mem_root) sp_instr_jump(ip, ctx);
if (i == NULL)
MYSQL_YYABORT;
sp->push_backpatch(i, lab); /* Jumping forward */
@@ -3855,7 +3870,8 @@ sp_proc_stmt_iterate:
n= ctx->diff_handlers(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
{
- sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
+ sp_instr_hpop *hpop= new (lex->thd->mem_root)
+ sp_instr_hpop(ip++, ctx, n);
if (hpop == NULL ||
sp->add_instr(hpop))
MYSQL_YYABORT;
@@ -3863,12 +3879,14 @@ sp_proc_stmt_iterate:
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
{
- sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
+ sp_instr_cpop *cpop= new (lex->thd->mem_root)
+ sp_instr_cpop(ip++, ctx, n);
if (cpop == NULL ||
sp->add_instr(cpop))
MYSQL_YYABORT;
}
- i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
+ i= new (lex->thd->mem_root)
+ sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3889,7 +3907,8 @@ sp_proc_stmt_open:
my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str);
MYSQL_YYABORT;
}
- i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
+ i= new (lex->thd->mem_root)
+ sp_instr_copen(sp->instructions(), lex->spcont, offset);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3909,7 +3928,8 @@ sp_proc_stmt_fetch:
my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $3.str);
MYSQL_YYABORT;
}
- i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
+ i= new (lex->thd->mem_root)
+ sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3931,7 +3951,8 @@ sp_proc_stmt_close:
my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str);
MYSQL_YYABORT;
}
- i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
+ i= new (lex->thd->mem_root)
+ sp_instr_cclose(sp->instructions(), lex->spcont, offset);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -3995,8 +4016,8 @@ sp_if:
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
uint ip= sp->instructions();
- sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
- $2, lex);
+ sp_instr_jump_if_not *i= new (lex->thd->mem_root)
+ sp_instr_jump_if_not(ip, ctx, $2, lex);
if (i == NULL ||
sp->push_backpatch(i, ctx->push_label(thd, empty_lex_str, 0)) ||
sp->add_cont_backpatch(i) ||
@@ -4010,7 +4031,7 @@ sp_if:
sp_head *sp= Lex->sphead;
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
- sp_instr_jump *i = new sp_instr_jump(ip, ctx);
+ sp_instr_jump *i= new (thd->mem_root) sp_instr_jump(ip, ctx);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -4181,8 +4202,8 @@ else_clause_opt:
LEX *lex= Lex;
sp_head *sp= lex->sphead;
uint ip= sp->instructions();
- sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
- ER_SP_CASE_NOT_FOUND);
+ sp_instr_error *i= new (thd->mem_root)
+ sp_instr_error(ip, lex->spcont, ER_SP_CASE_NOT_FOUND);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -4298,14 +4319,16 @@ sp_block_content:
sp->backpatch(ctx->last_label()); /* We always have a label */
if ($2.hndlrs)
{
- i= new sp_instr_hpop(sp->instructions(), ctx, $2.hndlrs);
+ i= new (thd->mem_root)
+ sp_instr_hpop(sp->instructions(), ctx, $2.hndlrs);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
}
if ($2.curs)
{
- i= new sp_instr_cpop(sp->instructions(), ctx, $2.curs);
+ i= new (lex->thd->mem_root)
+ sp_instr_cpop(sp->instructions(), ctx, $2.curs);
if (i == NULL ||
sp->add_instr(i))
MYSQL_YYABORT;
@@ -4322,7 +4345,8 @@ sp_control_content:
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
sp_label *lab= lex->spcont->last_label(); /* Jumping back */
- sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
+ sp_instr_jump *i= new (lex->thd->mem_root)
+ sp_instr_jump(ip, lex->spcont, lab->ip);
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
@@ -4334,8 +4358,8 @@ sp_control_content:
LEX *lex= Lex;
sp_head *sp= lex->sphead;
uint ip= sp->instructions();
- sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
- $3, lex);
+ sp_instr_jump_if_not *i= new (lex->thd->mem_root)
+ sp_instr_jump_if_not(ip, lex->spcont, $3, lex);
if (i == NULL ||
/* Jumping forward */
sp->push_backpatch(i, lex->spcont->last_label()) ||
@@ -4350,7 +4374,8 @@ sp_control_content:
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
sp_label *lab= lex->spcont->last_label(); /* Jumping back */
- sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
+ sp_instr_jump *i= new (lex->thd->mem_root)
+ sp_instr_jump(ip, lex->spcont, lab->ip);
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
@@ -4363,9 +4388,8 @@ sp_control_content:
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
sp_label *lab= lex->spcont->last_label(); /* Jumping back */
- sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
- $5, lab->ip,
- lex);
+ sp_instr_jump_if_not *i= new (lex->thd->mem_root)
+ sp_instr_jump_if_not(ip, lex->spcont, $5, lab->ip, lex);
if (i == NULL ||
lex->sphead->add_instr(i))
MYSQL_YYABORT;
@@ -8684,7 +8708,7 @@ expr:
else
{
/* X OR Y */
- $$ = new (thd->mem_root) Item_cond_or(thd, $1, $3);
+ $$= new (thd->mem_root) Item_cond_or(thd, $1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -8692,7 +8716,7 @@ expr:
| expr XOR expr %prec XOR
{
/* XOR is a proprietary extension */
- $$ = new (thd->mem_root) Item_func_xor(thd, $1, $3);
+ $$= new (thd->mem_root) Item_func_xor(thd, $1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -8734,7 +8758,7 @@ expr:
else
{
/* X AND Y */
- $$ = new (thd->mem_root) Item_cond_and(thd, $1, $3);
+ $$= new (thd->mem_root) Item_cond_and(thd, $1, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -8858,7 +8882,7 @@ predicate:
{
$7->push_front($5);
$7->push_front($1);
- Item_func_in *item = new (thd->mem_root) Item_func_in(thd, *$7);
+ Item_func_in *item= new (thd->mem_root) Item_func_in(thd, *$7);
if (item == NULL)
MYSQL_YYABORT;
item->negate();
@@ -9625,7 +9649,7 @@ function_call_nonkeyword:
}
| POSITION_SYM '(' bit_expr IN_SYM expr ')'
{
- $$ = new (thd->mem_root) Item_func_locate(thd, $5, $3);
+ $$= new (thd->mem_root) Item_func_locate(thd, $5, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -9826,7 +9850,7 @@ function_call_conflict:
}
| MOD_SYM '(' expr ',' expr ')'
{
- $$ = new (thd->mem_root) Item_func_mod(thd, $3, $5);
+ $$= new (thd->mem_root) Item_func_mod(thd, $3, $5);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -9847,7 +9871,7 @@ function_call_conflict:
}
| QUARTER_SYM '(' expr ')'
{
- $$ = new (thd->mem_root) Item_func_quarter(thd, $3);
+ $$= new (thd->mem_root) Item_func_quarter(thd, $3);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -11802,7 +11826,7 @@ drop:
MYSQL_YYABORT;
}
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new sp_name($4, $6, true);
+ spname= new (lex->thd->mem_root) sp_name($4, $6, true);
if (spname == NULL)
MYSQL_YYABORT;
spname->init_qname(thd);
@@ -11821,7 +11845,7 @@ drop:
if (thd->db && lex->copy_db_to(&db.str, &db.length))
MYSQL_YYABORT;
lex->set_command(SQLCOM_DROP_FUNCTION, $3);
- spname= new sp_name(db, $4, false);
+ spname= new (lex->thd->mem_root) sp_name(db, $4, false);
if (spname == NULL)
MYSQL_YYABORT;
spname->init_qname(thd);
@@ -12050,7 +12074,7 @@ insert_field_spec:
| SET
{
LEX *lex=Lex;
- if (!(lex->insert_list = new List_item) ||
+ if (!(lex->insert_list= new List_item) ||
lex->many_values.push_back(lex->insert_list))
MYSQL_YYABORT;
}
@@ -12106,7 +12130,7 @@ opt_equal:
no_braces:
'('
{
- if (!(Lex->insert_list = new List_item))
+ if (!(Lex->insert_list= new List_item))
MYSQL_YYABORT;
}
opt_values ')'
@@ -13511,7 +13535,7 @@ literal:
TOK_GENERIC_VALUE := NULL_SYM
*/
YYLIP->reduce_digest_token(TOK_GENERIC_VALUE, NULL_SYM);
- $$ = new (thd->mem_root) Item_null(thd);
+ $$= new (thd->mem_root) Item_null(thd);
if ($$ == NULL)
MYSQL_YYABORT;
YYLIP->next_state= MY_LEX_OPERATOR_OR_IDENT;
@@ -13530,13 +13554,13 @@ literal:
}
| HEX_NUM
{
- $$ = new (thd->mem_root) Item_hex_hybrid(thd, $1.str, $1.length);
+ $$= new (thd->mem_root) Item_hex_hybrid(thd, $1.str, $1.length);
if ($$ == NULL)
MYSQL_YYABORT;
}
| HEX_STRING
{
- $$ = new (thd->mem_root) Item_hex_string(thd, $1.str, $1.length);
+ $$= new (thd->mem_root) Item_hex_string(thd, $1.str, $1.length);
if ($$ == NULL)
MYSQL_YYABORT;
}
@@ -15172,7 +15196,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 List_item))
MYSQL_YYABORT;
}
'(' values ')'
@@ -15609,7 +15633,7 @@ column_list:
column_list_id:
ident
{
- String *new_str = new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info);
+ String *new_str= new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info);
if (new_str == NULL)
MYSQL_YYABORT;
List_iterator <LEX_COLUMN> iter(Lex->columns);
diff --git a/sql/table.cc b/sql/table.cc
index 9beada2667f..f768cf93061 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -4142,7 +4142,7 @@ bool TABLE::fill_item_list(List<Item> *item_list) const
*/
for (Field **ptr= field; *ptr; ptr++)
{
- Item_field *item= new Item_field(in_use, *ptr);
+ Item_field *item= new (in_use->mem_root) Item_field(in_use, *ptr);
if (!item || item_list->push_back(item))
return TRUE;
}
@@ -5297,7 +5297,7 @@ Item *Field_iterator_table::create_item(THD *thd)
{
SELECT_LEX *select= thd->lex->current_select;
- Item_field *item= new Item_field(thd, &select->context, *ptr);
+ Item_field *item= new (thd->mem_root) Item_field(thd, &select->context, *ptr);
if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
{
@@ -5354,7 +5354,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
{
DBUG_RETURN(field);
}
- Item *item= new Item_direct_view_ref(thd, &view->view->select_lex.context,
+ Item *item= new (thd->mem_root) Item_direct_view_ref(thd, &view->view->select_lex.context,
field_ref, view->alias,
name, view);
/*
@@ -5559,7 +5559,7 @@ Field_iterator_table_ref::get_or_create_column_ref(THD *thd, TABLE_LIST *parent_
/* The field belongs to a stored table. */
Field *tmp_field= table_field_it.field();
Item_field *tmp_item=
- new Item_field(thd, &thd->lex->current_select->context, tmp_field);
+ new (thd->mem_root) Item_field(thd, &thd->lex->current_select->context, tmp_field);
if (!tmp_item)
return NULL;
nj_col= new Natural_join_column(tmp_item, table_ref);
@@ -7328,7 +7328,7 @@ bool TABLE_LIST::change_refs_to_fields()
DBUG_ASSERT(!field_it.end_of_fields());
if (!materialized_items[idx])
{
- materialized_items[idx]= new Item_field(thd, table->field[idx]);
+ materialized_items[idx]= new (thd->mem_root) Item_field(thd, table->field[idx]);
if (!materialized_items[idx])
return TRUE;
}
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 25cedf3547b..568d3695781 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -2335,10 +2335,11 @@ int ha_sphinx::write_row ( byte * )
} else
{
+ THD *thd= ha_thd();
if ( (*ppField)->type()==MYSQL_TYPE_TIMESTAMP )
{
- Item_field * pWrap = new Item_field ( ha_thd(), *ppField ); // autofreed by query arena, I assume
- Item_func_unix_timestamp * pConv = new Item_func_unix_timestamp ( ha_thd(), pWrap );
+ Item_field * pWrap = new (thd->mem_root) Item_field(thd, *ppField); // autofreed by query arena, I assume
+ Item_func_unix_timestamp * pConv = new (thd->mem_root) Item_func_unix_timestamp(thd, pWrap);
pConv->quick_fix_field();
unsigned int uTs = (unsigned int) pConv->val_int();
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index 7b996383f95..15d0c43a176 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -2390,7 +2390,7 @@ TABLE *spider_mk_sys_tmp_table(
goto error_alloc_field;
field->init(table);
- if (!(i_field = new Item_field(thd, (Field *) field)))
+ if (!(i_field = new (thd->mem_root) Item_field(thd, (Field *) field)))
goto error_alloc_item_field;
if (i_list.push_back(i_field))
@@ -2443,29 +2443,29 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto error_alloc_field1;
field1->init(table);
- if (!(i_field1 = new Item_field(thd, (Field *) field1)))
+ if (!(i_field1 = new (thd->mem_root) Item_field(thd, (Field *) field1)))
goto error_alloc_item_field1;
if (i_list.push_back(i_field1))
goto error_push_item1;
- if (!(field2 = new Field_blob(
+ if (!(field2 = new (thd->mem_root) Field_blob(
4294967295U, FALSE, field_name2, cs, TRUE)))
goto error_alloc_field2;
field2->init(table);
- if (!(i_field2 = new Item_field(thd, (Field *) field2)))
+ if (!(i_field2 = new (thd->mem_root) Item_field(thd, (Field *) field2)))
goto error_alloc_item_field2;
if (i_list.push_back(i_field2))
goto error_push_item2;
- if (!(field3 = new Field_blob(
+ if (!(field3 = new (thd->mem_root) Field_blob(
4294967295U, FALSE, field_name3, cs, TRUE)))
goto error_alloc_field3;
field3->init(table);
- if (!(i_field3 = new Item_field(thd, (Field *) field3)))
+ if (!(i_field3 = new (thd->mem_root) Item_field(thd, (Field *) field3)))
goto error_alloc_item_field3;
if (i_list.push_back(i_field3))