diff options
50 files changed, 1103 insertions, 753 deletions
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc index a762522136e..053d68eb66d 100644 --- a/plugin/feedback/feedback.cc +++ b/plugin/feedback/feedback.cc @@ -120,7 +120,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter) if (!like) return OOM; - res->add(like); + res->add(like, thd->mem_root); } if (res->fix_fields(thd, (Item**)&res)) diff --git a/sql/events.cc b/sql/events.cc index a346d02fc39..2bb112867bf 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -640,35 +640,37 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol) DBUG_RETURN(TRUE); field_list.push_back(new (mem_root) - Item_empty_string(thd, "Event", NAME_CHAR_LEN)); + Item_empty_string(thd, "Event", NAME_CHAR_LEN), + mem_root); if (sql_mode_string_representation(thd, et->sql_mode, &sql_mode)) DBUG_RETURN(TRUE); field_list.push_back(new (mem_root) Item_empty_string(thd, "sql_mode", - (uint) sql_mode.length)); + (uint) sql_mode.length), mem_root); tz_name= et->time_zone->get_name(); field_list.push_back(new (mem_root) - Item_empty_string(thd, "time_zone", tz_name->length())); + Item_empty_string(thd, "time_zone", tz_name->length()), + mem_root); field_list.push_back(new (mem_root) Item_empty_string(thd, "Create Event", - show_str.length())); + show_str.length()), mem_root); field_list.push_back(new (mem_root) Item_empty_string(thd, "character_set_client", - MY_CS_NAME_SIZE)); + MY_CS_NAME_SIZE), mem_root); field_list.push_back(new (mem_root) Item_empty_string(thd, "collation_connection", - MY_CS_NAME_SIZE)); + MY_CS_NAME_SIZE), mem_root); field_list.push_back(new (mem_root) Item_empty_string(thd, "Database Collation", - MY_CS_NAME_SIZE)); + MY_CS_NAME_SIZE), mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index eedf9458485..ffe35392989 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1810,7 +1810,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (p_share_refs->init(num_subparts)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); - if (m_new_partitions_share_refs.push_back(p_share_refs)) + if (m_new_partitions_share_refs.push_back(p_share_refs, thd->mem_root)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); do { diff --git a/sql/handler.cc b/sql/handler.cc index eec6e5c1212..1d1dae75164 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1986,16 +1986,16 @@ bool mysql_xa_recover(THD *thd) field_list.push_back(new (mem_root) Item_int(thd, "formatID", 0, - MY_INT32_NUM_DECIMAL_DIGITS)); + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); field_list.push_back(new (mem_root) Item_int(thd, "gtrid_length", 0, - MY_INT32_NUM_DECIMAL_DIGITS)); + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); field_list.push_back(new (mem_root) Item_int(thd, "bqual_length", 0, - MY_INT32_NUM_DECIMAL_DIGITS)); + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); field_list.push_back(new (mem_root) Item_empty_string(thd, "data", - XIDDATASIZE)); + XIDDATASIZE), mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -5533,9 +5533,13 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) MEM_ROOT *mem_root= thd->mem_root; bool result; - 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)); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Type", 10), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Name", FN_REFLEN), mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Status", 10), + mem_root); 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 32cb824668e..6e3707726d0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4785,7 +4785,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) non aggregated fields of the outer select. */ marker= select->cur_pos_in_select_list; - select->non_agg_fields.push_back(this); + select->non_agg_fields.push_back(this, thd->mem_root); } if (*from_field != view_ref_found) { @@ -4810,7 +4810,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) 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); + select->inner_refs_list.push_back(rf, thd->mem_root); rf->in_sum_func= thd->lex->in_sum_func; } /* @@ -4930,7 +4930,8 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) if (place != IN_HAVING && select->group_list.elements) { - outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf); + outer_context->select_lex->inner_refs_list.push_back((Item_outer_ref*)rf, + thd->mem_root); ((Item_outer_ref*)rf)->in_sum_func= thd->lex->in_sum_func; } thd->change_item_tree(reference, rf); @@ -5205,7 +5206,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) !outer_fixed && !thd->lex->in_sum_func && thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS) { - thd->lex->current_select->non_agg_fields.push_back(this); + thd->lex->current_select->non_agg_fields.push_back(this, thd->mem_root); marker= thd->lex->current_select->cur_pos_in_select_list; } mark_non_agg_field: @@ -5241,7 +5242,7 @@ mark_non_agg_field: else { if (outer_fixed) - thd->lex->in_sum_func->outer_fields.push_back(this); + thd->lex->in_sum_func->outer_fields.push_back(this, thd->mem_root); else if (thd->lex->in_sum_func->nest_level != thd->lex->current_select->nest_level) select_lex->set_non_agg_field_used(true); @@ -6731,9 +6732,10 @@ Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg) Item_ref *ref; ref_pointer_array[el]= (Item*)this; - all_fields->push_front((Item*)this); - ref= new (thd->mem_root) Item_ref(thd, &select->context, ref_pointer_array + el, - table_name, field_name); + all_fields->push_front((Item*)this, thd->mem_root); + ref= new (thd->mem_root) + Item_ref(thd, &select->context, ref_pointer_array + el, + table_name, field_name); return ref; } return this; @@ -7165,7 +7167,7 @@ void Item_ref::cleanup() Item* Item_ref::transform(THD *thd, Item_transformer transformer, uchar *arg) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); DBUG_ASSERT((*ref) != NULL); /* Transform the object we are referencing. */ diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 78f0c21edbe..bc36b121b73 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2774,6 +2774,26 @@ Item_func_nullif::is_null() } +Item_func_case::Item_func_case(THD *thd, List<Item> &list, + Item *first_expr_arg, Item *else_expr_arg): + Item_func_hybrid_field_type(thd), first_expr_num(-1), else_expr_num(-1), + left_result_type(INT_RESULT), case_item(0) +{ + ncases= list.elements; + if (first_expr_arg) + { + first_expr_num= list.elements; + list.push_back(first_expr_arg, thd->mem_root); + } + if (else_expr_arg) + { + else_expr_num= list.elements; + list.push_back(else_expr_arg, thd->mem_root); + } + set_arguments(list); + bzero(&cmp_items, sizeof(cmp_items)); +} + /** Find and return matching items for CASE or ELSE item if all compares are failed or NULL if ELSE item isn't defined. @@ -4252,6 +4272,14 @@ Item_cond::Item_cond(THD *thd, Item_cond *item) } +Item_cond::Item_cond(THD *thd, Item *i1, Item *i2): + Item_bool_func(thd), abort_on_null(0) +{ + list.push_back(i1, thd->mem_root); + list.push_back(i2, thd->mem_root); +} + + Item *Item_cond_and::copy_andor_structure(THD *thd) { Item_cond_and *item; @@ -4265,7 +4293,7 @@ void Item_cond::copy_andor_arguments(THD *thd, Item_cond *item) { List_iterator_fast<Item> li(item->list); while (Item *it= li++) - list.push_back(it->copy_andor_structure(thd)); + list.push_back(it->copy_andor_structure(thd), thd->mem_root); } @@ -4788,7 +4816,7 @@ Item *and_expressions(THD *thd, Item *a, Item *b, Item **org_item) } return res; } - if (((Item_cond_and*) a)->add((Item*) b)) + if (((Item_cond_and*) a)->add((Item*) b, thd->mem_root)) return 0; ((Item_cond_and*) a)->used_tables_cache|= b->used_tables(); ((Item_cond_and*) a)->not_null_tables_cache|= b->not_null_tables(); @@ -5836,7 +5864,7 @@ void Item_equal::add_const(THD *thd, Item *c, Item *f) with_const= TRUE; if (f) compare_as_dates= f->cmp_type() == TIME_RESULT; - equal_items.push_front(c); + equal_items.push_front(c, thd->mem_root); return; } Item *const_item= get_const(); @@ -5991,7 +6019,7 @@ bool Item_equal::merge_with_check(THD *thd, Item_equal *item, bool save_merged) while ((item= fi++)) { if (!contains(fi.get_curr_field())) - add(item); + add(item, thd->mem_root); } } } @@ -6041,7 +6069,7 @@ void Item_equal::merge_into_list(THD *thd, List<Item_equal> *list, } } if (!only_intersected && !merge_into) - list->push_back(this); + list->push_back(this, thd->mem_root); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 78afacece7e..ebb51d2ae30 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1302,24 +1302,7 @@ class Item_func_case :public Item_func_hybrid_field_type cmp_item *case_item; public: Item_func_case(THD *thd, List<Item> &list, Item *first_expr_arg, - Item *else_expr_arg): - Item_func_hybrid_field_type(thd), first_expr_num(-1), else_expr_num(-1), - left_result_type(INT_RESULT), case_item(0) - { - ncases= list.elements; - if (first_expr_arg) - { - first_expr_num= list.elements; - list.push_back(first_expr_arg); - } - if (else_expr_arg) - { - else_expr_num= list.elements; - list.push_back(else_expr_arg); - } - set_arguments(list); - bzero(&cmp_items, sizeof(cmp_items)); - } + Item *else_expr_arg); double real_op(); longlong int_op(); String *str_op(String *); @@ -1789,24 +1772,19 @@ public: /* Item_cond() is only used to create top level items */ Item_cond(THD *thd): Item_bool_func(thd), abort_on_null(1) { const_item_cache=0; } - Item_cond(THD *thd, Item *i1, Item *i2): - Item_bool_func(thd), abort_on_null(0) - { - list.push_back(i1); - list.push_back(i2); - } + Item_cond(THD *thd, Item *i1, Item *i2); Item_cond(THD *thd, Item_cond *item); Item_cond(THD *thd, List<Item> &nlist): Item_bool_func(thd), list(nlist), abort_on_null(0) {} - bool add(Item *item) + bool add(Item *item, MEM_ROOT *root) { DBUG_ASSERT(item); - return list.push_back(item); + return list.push_back(item, root); } - bool add_at_head(Item *item) + bool add_at_head(Item *item, MEM_ROOT *root) { DBUG_ASSERT(item); - return list.push_front(item); + return list.push_front(item, root); } void add_at_head(List<Item> *nlist) { @@ -2004,7 +1982,7 @@ public: inline Item* get_const() { return with_const ? equal_items.head() : NULL; } void add_const(THD *thd, Item *c, Item *f = NULL); /** Add a non-constant item to the multiple equality */ - void add(Item *f) { equal_items.push_back(f); } + void add(Item *f, MEM_ROOT *root) { equal_items.push_back(f, root); } bool contains(Field *field); Item* get_first(struct st_join_table *context, Item *field); /** Get number of field items / references to field items in this object */ diff --git a/sql/item_create.cc b/sql/item_create.cc index 8c6d02623c6..3d7c4eede93 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -6349,8 +6349,8 @@ static List<Item> *create_func_dyncol_prepare(THD *thd, for (uint i= 0; (def= li++) ;) { dfs[0][i++]= *def; - args->push_back(def->key); - args->push_back(def->value); + args->push_back(def->key, thd->mem_root); + args->push_back(def->value, thd->mem_root); } return args; } @@ -6374,7 +6374,7 @@ Item *create_func_dyncol_add(THD *thd, Item *str, if (!(args= create_func_dyncol_prepare(thd, &dfs, list))) return NULL; - args->push_back(str); + args->push_back(str, thd->mem_root); return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs); } @@ -6399,11 +6399,11 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums) dfs[i].key= key; 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); + args->push_back(dfs[i].key, thd->mem_root); + args->push_back(dfs[i].value, thd->mem_root); } - args->push_back(str); + args->push_back(str, thd->mem_root); return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs); } diff --git a/sql/item_func.cc b/sql/item_func.cc index fd63fa86224..504f2c1dec5 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5552,7 +5552,8 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command, 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)))); + new (thd->mem_root) Item_null(thd))), + thd->mem_root); /* Create the variable */ if (sql_set_variables(thd, &tmp_var_list, false)) { @@ -6131,7 +6132,9 @@ void Item_func_match::init_search(THD *thd, bool no_order) if (key == NO_SUCH_KEY) { List<Item> fields; - fields.push_back(new (thd->mem_root) Item_string(thd, " ", 1, cmp_collation.collation)); + fields.push_back(new (thd->mem_root) + Item_string(thd, " ", 1, cmp_collation.collation), + thd->mem_root); for (uint i= 1; i < arg_count; i++) fields.push_back(args[i]); concat_ws= new (thd->mem_root) Item_func_concat_ws(thd, fields); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index a93b17b826a..a2ae5308e29 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2563,7 +2563,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) Item_equal *elem; while ((elem= li++)) { - and_args->push_back(elem); + and_args->push_back(elem, thd->mem_root); } } } @@ -2580,7 +2580,8 @@ 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 (thd->mem_root) Item_int(thd, (int32) 1)); + new (thd->mem_root) + Item_int(thd, (int32) 1)); unit->select_limit_cnt= 1; DBUG_RETURN(false); @@ -2820,7 +2821,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) it.replace(local_field); else { - first_select->item_list.push_back(local_field); + first_select->item_list.push_back(local_field, thd->mem_root); first_select->join->all_fields.elements++; } first_select->ref_pointer_array[i]= (Item *)local_field; @@ -2846,7 +2847,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) } outer_exp->fix_after_pullout(unit->outer_select(), &outer_exp); outer_exp->update_used_tables(); - outer.push_back(outer_exp); + outer.push_back(outer_exp, thd->mem_root); } } @@ -2998,12 +2999,13 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) &unit->outer_select()->context, optimizer->arguments()[0]->addr(i), (char *)"<no matter>", - (char *)exists_outer_expr_name))); + (char *)exists_outer_expr_name)), + thd->mem_root); } } if (and_list->elements > 0) { - and_list->push_front(optimizer); + and_list->push_front(optimizer, thd->mem_root); exp= new (thd->mem_root) Item_cond_and(thd, *and_list); } else @@ -3308,7 +3310,8 @@ bool Item_in_subselect::init_left_expr_cache() Cached_item *cur_item_cache= new_Cached_item(thd, left_expr->element_index(i), FALSE); - if (!cur_item_cache || left_expr_cache->push_front(cur_item_cache)) + if (!cur_item_cache || left_expr_cache->push_front(cur_item_cache, + thd->mem_root)) return TRUE; } return FALSE; @@ -4931,14 +4934,17 @@ bool subselect_hash_sj_engine::make_semi_join_conds() for (uint i= 0; i < item_in->left_expr->cols(); i++) { - Item_func_eq *eq_cond; /* New equi-join condition for the current column. */ + /* New equi-join condition for the current column. */ + Item_func_eq *eq_cond; /* Item for the corresponding field from the materialized temp table. */ Item_field *right_col_item; - 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))) + 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, thd->mem_root))) { delete semi_join_conds; semi_join_conds= NULL; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e20b47c67d6..0eff2b6cec9 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -272,7 +272,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) Let upper function decide whether this field is a non aggregated one. */ - in_sum_func->outer_fields.push_back(field); + in_sum_func->outer_fields.push_back(field, thd->mem_root); } else sel->set_non_agg_field_used(true); @@ -777,7 +777,7 @@ bool Aggregator_distinct::setup(THD *thd) for (uint i=0; i < item_sum->get_arg_count() ; i++) { Item *item=item_sum->get_arg(i); - if (list.push_back(item)) + if (list.push_back(item, thd->mem_root)) return TRUE; // End of memory if (item->const_item() && item->is_null()) always_null= true; @@ -898,7 +898,7 @@ bool Aggregator_distinct::setup(THD *thd) PS/SP. Hence all further allocations are performed in the runtime mem_root. */ - if (field_list.push_back(&field_def)) + if (field_list.push_back(&field_def, thd->mem_root)) DBUG_RETURN(TRUE); item_sum->null_value= item_sum->maybe_null= 1; @@ -3505,7 +3505,7 @@ bool Item_func_group_concat::setup(THD *thd) for (uint i= 0; i < arg_count_field; i++) { Item *item= args[i]; - if (list.push_back(item)) + if (list.push_back(item, thd->mem_root)) DBUG_RETURN(TRUE); if (item->const_item()) { diff --git a/sql/log_event.cc b/sql/log_event.cc index 9459eb974ef..cb5b2c5cbbd 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1037,17 +1037,28 @@ 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) { 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 (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 (mem_root) Item_return_int(thd, "End_log_pos", - MY_INT32_NUM_DECIMAL_DIGITS, - MYSQL_TYPE_LONGLONG)); - field_list->push_back(new (mem_root) Item_empty_string(thd, "Info", 20)); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "Log_name", 20), + mem_root); + field_list->push_back(new (mem_root) + Item_return_int(thd, "Pos", + MY_INT32_NUM_DECIMAL_DIGITS, + MYSQL_TYPE_LONGLONG), + mem_root); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "Event_type", 20), + mem_root); + field_list->push_back(new (mem_root) + Item_return_int(thd, "Server_id", 10, + MYSQL_TYPE_LONG), + mem_root); + field_list->push_back(new (mem_root) + Item_return_int(thd, "End_log_pos", + MY_INT32_NUM_DECIMAL_DIGITS, + MYSQL_TYPE_LONGLONG), + mem_root); + field_list->push_back(new (mem_root) Item_empty_string(thd, "Info", 20), + mem_root); } /** @@ -5726,8 +5737,10 @@ 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 (thd->mem_root) Item_field(thd, context, - affected_db, table_name, field)); + field_list.push_back(new (thd->mem_root) + Item_field(thd, context, affected_db, table_name, + field), + thd->mem_root); field+= field_lens[i] + 1; } } diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index 848549c3b2d..a6707d458df 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -202,7 +202,7 @@ static Item *make_cond_for_index(THD *thd, Item *cond, TABLE *table, uint keyno, Item *fix= make_cond_for_index(thd, item, table, keyno, other_tbls_ok); if (fix) { - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); used_tables|= fix->used_tables(); } if (MY_TEST(item->marker == ICP_COND_USES_INDEX_ONLY)) @@ -237,7 +237,7 @@ static Item *make_cond_for_index(THD *thd, Item *cond, TABLE *table, uint keyno, Item *fix= make_cond_for_index(thd, item, table, keyno, other_tbls_ok); if (!fix) return (COND*) 0; - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); if (MY_TEST(item->marker == ICP_COND_USES_INDEX_ONLY)) { n_marked++; @@ -280,7 +280,7 @@ static Item *make_cond_remainder(THD *thd, Item *cond, TABLE *table, uint keyno, other_tbls_ok, exclude_index); if (fix) { - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); tbl_map |= fix->used_tables(); } } @@ -308,7 +308,7 @@ static Item *make_cond_remainder(THD *thd, Item *cond, TABLE *table, uint keyno, other_tbls_ok, FALSE); if (!fix) return (COND*) 0; - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); tbl_map |= fix->used_tables(); } new_cond->quick_fix_field(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0522e0f21a0..e17d19ff9f8 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -792,6 +792,8 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, bool without_merges, { keys_map= arg->keys_map; type= arg->type; + MEM_ROOT *mem_root; + for (uint idx= 0; idx < param->keys; idx++) { if ((keys[idx]= arg->keys[idx])) @@ -801,16 +803,17 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, bool without_merges, if (without_merges) return; + mem_root= current_thd->mem_root; List_iterator<SEL_IMERGE> it(arg->merges); for (SEL_IMERGE *el= it++; el; el= it++) { - SEL_IMERGE *merge= new SEL_IMERGE(el, 0, param); + SEL_IMERGE *merge= new (mem_root) SEL_IMERGE(el, 0, param); if (!merge || merge->trees == merge->trees_next) { merges.empty(); return; } - merges.push_back (merge); + merges.push_back(merge, mem_root); } } @@ -937,11 +940,12 @@ int imerge_list_or_list(RANGE_OPT_PARAM *param, uint rc; bool is_last_check_pass= FALSE; - SEL_IMERGE *imerge= im1->head(); uint elems= imerge->trees_next-imerge->trees; + MEM_ROOT *mem_root= current_thd->mem_root; + im1->empty(); - im1->push_back(imerge); + im1->push_back(imerge, mem_root); rc= imerge->or_sel_imerge_with_checks(param, elems, im2->head(), TRUE, &is_last_check_pass); @@ -957,14 +961,14 @@ int imerge_list_or_list(RANGE_OPT_PARAM *param, if (!is_last_check_pass) { - SEL_IMERGE* new_imerge= new SEL_IMERGE(imerge, elems, param); + SEL_IMERGE* new_imerge= new (mem_root) SEL_IMERGE(imerge, elems, param); if (new_imerge) { is_last_check_pass= TRUE; rc= new_imerge->or_sel_imerge_with_checks(param, elems, im2->head(), FALSE, &is_last_check_pass); if (!rc) - im1->push_back(new_imerge); + im1->push_back(new_imerge, mem_root); } } return rc; @@ -1024,17 +1028,17 @@ int imerge_list_or_tree(RANGE_OPT_PARAM *param, List<SEL_IMERGE> *merges, SEL_TREE *tree) { - SEL_IMERGE *imerge; List<SEL_IMERGE> additional_merges; List_iterator<SEL_IMERGE> it(*merges); + MEM_ROOT *mem_root= current_thd->mem_root; while ((imerge= it++)) { bool is_last_check_pass; int rc= 0; int rc1= 0; - SEL_TREE *or_tree= new SEL_TREE (tree, FALSE, param); + SEL_TREE *or_tree= new (mem_root) SEL_TREE (tree, FALSE, param); if (or_tree) { uint elems= imerge->trees_next-imerge->trees; @@ -1042,13 +1046,14 @@ int imerge_list_or_tree(RANGE_OPT_PARAM *param, TRUE, &is_last_check_pass); if (!is_last_check_pass) { - SEL_IMERGE *new_imerge= new SEL_IMERGE(imerge, elems, param); + SEL_IMERGE *new_imerge= new (mem_root) SEL_IMERGE(imerge, elems, + param); if (new_imerge) { rc1= new_imerge->or_sel_tree_with_checks(param, elems, or_tree, FALSE, &is_last_check_pass); if (!rc1) - additional_merges.push_back(new_imerge); + additional_merges.push_back(new_imerge, mem_root); } } } @@ -1110,11 +1115,12 @@ int imerge_list_and_tree(RANGE_OPT_PARAM *param, SEL_IMERGE *new_imerge= NULL; List<SEL_IMERGE> new_merges; List_iterator<SEL_IMERGE> it(*merges); + MEM_ROOT *mem_root= current_thd->mem_root; while ((imerge= it++)) { if (!new_imerge) - new_imerge= new SEL_IMERGE(); + new_imerge= new (mem_root) SEL_IMERGE(); if (imerge->have_common_keys(param, tree) && new_imerge && !imerge->and_sel_tree(param, tree, new_imerge)) { @@ -1125,7 +1131,7 @@ int imerge_list_and_tree(RANGE_OPT_PARAM *param, if (replace) it.replace(new_imerge); else - new_merges.push_back(new_imerge); + new_merges.push_back(new_imerge, mem_root); new_imerge= NULL; } } @@ -1371,7 +1377,7 @@ QUICK_INDEX_SORT_SELECT::push_quick_back(QUICK_RANGE_SELECT *quick_sel_range) pk_quick_select= quick_sel_range; DBUG_RETURN(0); } - DBUG_RETURN(quick_selects.push_back(quick_sel_range)); + DBUG_RETURN(quick_selects.push_back(quick_sel_range, thd->mem_root)); } QUICK_INDEX_SORT_SELECT::~QUICK_INDEX_SORT_SELECT() diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index a7449b1c995..dac607195f0 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -691,7 +691,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join) { Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup); - select_lex->outer_select()->sj_subselects.push_back(in_subs); + select_lex->outer_select()->sj_subselects.push_back(in_subs, + thd->mem_root); if (arena) thd->restore_active_arena(arena, &backup); in_subs->is_registered_semijoin= TRUE; @@ -728,7 +729,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join) { Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup); - select_lex->outer_select()->sj_subselects.push_back(in_subs); + select_lex->outer_select()->sj_subselects.push_back(in_subs, + thd->mem_root); if (arena) thd->restore_active_arena(arena, &backup); in_subs->is_registered_semijoin= TRUE; @@ -1425,7 +1427,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) A3: changes in the TABLE_LIST::outer_join will make everything work automatically. */ - if (!(wrap_nest= alloc_join_nest(parent_join->thd))) + if (!(wrap_nest= alloc_join_nest(thd))) { DBUG_RETURN(TRUE); } @@ -1434,7 +1436,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) wrap_nest->alias= (char*) "(sj-wrap)"; wrap_nest->nested_join->join_list.empty(); - wrap_nest->nested_join->join_list.push_back(outer_tbl); + wrap_nest->nested_join->join_list.push_back(outer_tbl, thd->mem_root); outer_tbl->embedding= wrap_nest; outer_tbl->join_list= &wrap_nest->nested_join->join_list; @@ -1470,7 +1472,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) TABLE_LIST *sj_nest; NESTED_JOIN *nested_join; - if (!(sj_nest= alloc_join_nest(parent_join->thd))) + if (!(sj_nest= alloc_join_nest(thd))) { DBUG_RETURN(TRUE); } @@ -1484,7 +1486,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) subq_pred->left_expr->used_tables(); /* Nests do not participate in those 'chains', so: */ /* sj_nest->next_leaf= sj_nest->next_local= sj_nest->next_global == NULL*/ - emb_join_list->push_back(sj_nest); + emb_join_list->push_back(sj_nest, thd->mem_root); /* nested_join->used_tables and nested_join->not_null_tables are @@ -1503,7 +1505,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) { tl->embedding= sj_nest; tl->join_list= &nested_join->join_list; - nested_join->join_list.push_back(tl); + nested_join->join_list.push_back(tl, thd->mem_root); } /* @@ -1593,10 +1595,11 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) if (subq_pred->left_expr->cols() == 1) { - nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr); + nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr, + thd->mem_root); Item_func_eq *item_eq= new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr, - subq_lex->ref_pointer_array[0]); + 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); } @@ -1605,10 +1608,12 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) for (uint i= 0; i < subq_pred->left_expr->cols(); i++) { nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr-> - element_index(i)); + element_index(i), + thd->mem_root); Item_func_eq *item_eq= - new (thd->mem_root) Item_func_eq(thd, subq_pred->left_expr->element_index(i), - subq_lex->ref_pointer_array[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); } @@ -1623,7 +1628,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) we have in here). */ if (!sj_nest->sj_on_expr->fixed && - sj_nest->sj_on_expr->fix_fields(parent_join->thd, &sj_nest->sj_on_expr)) + sj_nest->sj_on_expr->fix_fields(thd, &sj_nest->sj_on_expr)) { DBUG_RETURN(TRUE); } @@ -1649,7 +1654,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) sj_nest->sj_on_expr); emb_tbl_nest->on_expr->top_level_item(); if (!emb_tbl_nest->on_expr->fixed && - emb_tbl_nest->on_expr->fix_fields(parent_join->thd, + emb_tbl_nest->on_expr->fix_fields(thd, &emb_tbl_nest->on_expr)) { DBUG_RETURN(TRUE); @@ -1667,7 +1672,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) save_lex= thd->lex->current_select; thd->lex->current_select=parent_join->select_lex; if (!parent_join->conds->fixed && - parent_join->conds->fix_fields(parent_join->thd, + parent_join->conds->fix_fields(thd, &parent_join->conds)) { DBUG_RETURN(1); @@ -1681,7 +1686,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) Item_func_match *ifm; List_iterator_fast<Item_func_match> li(*(subq_lex->ftfunc_list)); while ((ifm= li++)) - parent_lex->ftfunc_list->push_front(ifm); + parent_lex->ftfunc_list->push_front(ifm, thd->mem_root); } parent_lex->have_merged_subqueries= TRUE; @@ -1723,16 +1728,16 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, List<TABLE_LIST> *emb_join_list= &parent_lex->top_join_list; TABLE_LIST *emb_tbl_nest= NULL; // will change when we learn to handle outer joins TABLE_LIST *tl; - DBUG_ENTER("convert_subq_to_jtbm"); bool optimization_delayed= TRUE; - subq_pred->set_strategy(SUBS_MATERIALIZATION); + TABLE_LIST *jtbm; + char *tbl_alias; + DBUG_ENTER("convert_subq_to_jtbm"); + subq_pred->set_strategy(SUBS_MATERIALIZATION); subq_pred->is_jtbm_merged= TRUE; *remove_item= TRUE; - TABLE_LIST *jtbm; - char *tbl_alias; if (!(tbl_alias= (char*)parent_join->thd->calloc(SUBQERY_TEMPTABLE_NAME_MAX_LEN)) || !(jtbm= alloc_join_nest(parent_join->thd))) //todo: this is not a join nest! { @@ -1746,13 +1751,13 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, /* Nests do not participate in those 'chains', so: */ /* jtbm->next_leaf= jtbm->next_local= jtbm->next_global == NULL*/ - emb_join_list->push_back(jtbm); + emb_join_list->push_back(jtbm, parent_join->thd->mem_root); /* Inject the jtbm table into TABLE_LIST::next_leaf list, so that make_join_statistics() and co. can find it. */ - parent_lex->leaf_tables.push_back(jtbm); + parent_lex->leaf_tables.push_back(jtbm, parent_join->thd->mem_root); if (subq_pred->unit->first_select()->options & OPTION_SCHEMA_TABLE) parent_lex->options |= OPTION_SCHEMA_TABLE; @@ -2073,7 +2078,7 @@ int pull_out_semijoin_tables(JOIN *join) */ child_li.remove(); sj_nest->nested_join->used_tables &= ~tbl->table->map; - upper_join_list->push_back(tbl); + upper_join_list->push_back(tbl, join->thd->mem_root); tbl->join_list= upper_join_list; tbl->embedding= sj_nest->embedding; } @@ -3512,16 +3517,19 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join) bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) { - DBUG_ENTER("setup_sj_materialization"); JOIN_TAB *tab= sjm_tab->bush_children->start; TABLE_LIST *emb_sj_nest= tab->table->pos_in_table_list->embedding; + SJ_MATERIALIZATION_INFO *sjm; + THD *thd; + + DBUG_ENTER("setup_sj_materialization"); /* Walk out of outer join nests until we reach the semi-join nest we're in */ while (!emb_sj_nest->sj_mat_info) emb_sj_nest= emb_sj_nest->embedding; - SJ_MATERIALIZATION_INFO *sjm= emb_sj_nest->sj_mat_info; - THD *thd= tab->join->thd; + sjm= emb_sj_nest->sj_mat_info; + thd= tab->join->thd; /* First the calls come to the materialization function */ //List<Item> &item_list= emb_sj_nest->sj_subq_pred->unit->first_select()->item_list; @@ -3537,8 +3545,8 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) Item **p_end= p_item + subq_select->item_list.elements; //while((right_expr= it++)) for(;p_item != p_end; p_item++) - sjm->sjm_table_cols.push_back(*p_item); - + sjm->sjm_table_cols.push_back(*p_item, thd->mem_root); + sjm->sjm_table_param.field_count= subq_select->item_list.elements; sjm->sjm_table_param.force_not_null_cols= TRUE; @@ -3554,8 +3562,8 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) sjm->table->file->extra(HA_EXTRA_WRITE_CACHE); sjm->table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - tab->join->sj_tmp_tables.push_back(sjm->table); - tab->join->sjm_info_list.push_back(sjm); + tab->join->sj_tmp_tables.push_back(sjm->table, thd->mem_root); + tab->join->sjm_info_list.push_back(sjm, thd->mem_root); sjm->materialized= FALSE; sjm_tab->table= sjm->table; @@ -4338,7 +4346,7 @@ int init_dups_weedout(JOIN *join, uint first_table, int first_fanout_table, uint sjtbl->null_bytes= (jt_null_bits + 7)/8; if (sjtbl->create_sj_weedout_tmp_table(thd)) DBUG_RETURN(TRUE); - join->sj_tmp_tables.push_back(sjtbl->tmp_table); + join->sj_tmp_tables.push_back(sjtbl->tmp_table, thd->mem_root); } else { @@ -5103,12 +5111,13 @@ TABLE *create_dummy_tmp_table(THD *thd) sjm_table_param.field_count= 1; List<Item> sjm_table_cols; Item *column_item= new (thd->mem_root) Item_int(thd, 1); - sjm_table_cols.push_back(column_item); + sjm_table_cols.push_back(column_item, thd->mem_root); if (!(table= create_tmp_table(thd, &sjm_table_param, sjm_table_cols, (ORDER*) 0, TRUE /* distinct */, 1, /*save_sum_fields*/ - thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS, + thd->variables.option_bits | + TMP_TABLE_ALL_COLUMNS, HA_POS_ERROR /*rows_limit */, (char*)"dummy", TRUE /* Do not open */))) { diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 75aced382f2..912ef4a7df7 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -1018,6 +1018,7 @@ public: bool Dep_analysis_context::setup_equality_modules_deps(List<Dep_module> *bound_modules) { + THD *thd= current_thd; DBUG_ENTER("setup_equality_modules_deps"); /* @@ -1042,7 +1043,7 @@ bool Dep_analysis_context::setup_equality_modules_deps(List<Dep_module> } void *buf; - if (!(buf= current_thd->alloc(bitmap_buffer_size(offset))) || + if (!(buf= thd->alloc(bitmap_buffer_size(offset))) || my_bitmap_init(&expr_deps, (my_bitmap_map*)buf, offset, FALSE)) { DBUG_RETURN(TRUE); /* purecov: inspected */ @@ -1084,7 +1085,7 @@ bool Dep_analysis_context::setup_equality_modules_deps(List<Dep_module> } if (!eq_mod->unbound_args) - bound_modules->push_back(eq_mod); + bound_modules->push_back(eq_mod, thd->mem_root); } DBUG_RETURN(FALSE); @@ -1255,7 +1256,7 @@ void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *ctx, { Dep_value_field *field_val; if ((field_val= ctx->get_field_value(equal_field))) - fvl->push_back(field_val); + fvl->push_back(field_val, thd->mem_root); } else { diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 0524dab7139..f3dab4f7b2f 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -667,7 +667,8 @@ parse_quoted_escaped_string(const char *ptr, const char *end, @param[in] mem_root MEM_ROOT for parameters allocation */ -bool get_file_options_ulllist(const char *&ptr, const char *end, const char *line, +bool get_file_options_ulllist(const char *&ptr, const char *end, + const char *line, uchar* base, File_option *parameter, MEM_ROOT *mem_root) { diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 9ba0c5d60cd..5bd2471d757 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -34,14 +34,16 @@ #include "ha_partition.h" -partition_info *partition_info::get_clone() +partition_info *partition_info::get_clone(THD *thd) { + MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("partition_info::get_clone"); + if (!this) DBUG_RETURN(NULL); List_iterator<partition_element> part_it(partitions); partition_element *part; - partition_info *clone= new partition_info(); + partition_info *clone= new (mem_root) partition_info(); if (!clone) { mem_alloc_error(sizeof(partition_info)); @@ -57,7 +59,7 @@ partition_info *partition_info::get_clone() { List_iterator<partition_element> subpart_it(part->subpartitions); partition_element *subpart; - partition_element *part_clone= new partition_element(); + partition_element *part_clone= new (mem_root) partition_element(); if (!part_clone) { mem_alloc_error(sizeof(partition_element)); @@ -74,9 +76,9 @@ partition_info *partition_info::get_clone() DBUG_RETURN(NULL); } memcpy(subpart_clone, subpart, sizeof(partition_element)); - part_clone->subpartitions.push_back(subpart_clone); + part_clone->subpartitions.push_back(subpart_clone, mem_root); } - clone->partitions.push_back(part_clone); + clone->partitions.push_back(part_clone, mem_root); } DBUG_RETURN(clone); } @@ -2236,12 +2238,12 @@ bool partition_info::is_full_part_expr_in_fields(List<Item> &fields) FALSE Success */ -int partition_info::add_max_value() +int partition_info::add_max_value(THD *thd) { DBUG_ENTER("partition_info::add_max_value"); part_column_list_val *col_val; - if (!(col_val= add_column_value())) + if (!(col_val= add_column_value(thd))) { DBUG_RETURN(TRUE); } @@ -2261,7 +2263,7 @@ int partition_info::add_max_value() 0 Memory allocation failure */ -part_column_list_val *partition_info::add_column_value() +part_column_list_val *partition_info::add_column_value(THD *thd) { uint max_val= num_columns ? num_columns : MAX_REF_PARTS; DBUG_ENTER("add_column_value"); @@ -2283,9 +2285,9 @@ part_column_list_val *partition_info::add_column_value() into the structure used for 1 column. After this we call ourselves recursively which should always succeed. */ - if (!reorganize_into_single_field_col_val()) + if (!reorganize_into_single_field_col_val(thd)) { - DBUG_RETURN(add_column_value()); + DBUG_RETURN(add_column_value(thd)); } DBUG_RETURN(NULL); } @@ -2366,7 +2368,7 @@ bool partition_info::add_column_list_value(THD *thd, Item *item) if (part_type == LIST_PARTITION && num_columns == 1U) { - if (init_column_part()) + if (init_column_part(thd)) { DBUG_RETURN(TRUE); } @@ -2395,7 +2397,7 @@ bool partition_info::add_column_list_value(THD *thd, Item *item) } thd->where= save_where; - if (!(col_val= add_column_value())) + if (!(col_val= add_column_value(thd))) { DBUG_RETURN(TRUE); } @@ -2416,7 +2418,7 @@ bool partition_info::add_column_list_value(THD *thd, Item *item) TRUE Failure FALSE Success */ -bool partition_info::init_column_part() +bool partition_info::init_column_part(THD *thd) { partition_element *p_elem= curr_part_elem; part_column_list_val *col_val_array; @@ -2425,8 +2427,8 @@ bool partition_info::init_column_part() DBUG_ENTER("partition_info::init_column_part"); if (!(list_val= - (part_elem_value*)sql_calloc(sizeof(part_elem_value))) || - p_elem->list_val_list.push_back(list_val)) + (part_elem_value*) thd->calloc(sizeof(part_elem_value))) || + p_elem->list_val_list.push_back(list_val, thd->mem_root)) { mem_alloc_error(sizeof(part_elem_value)); DBUG_RETURN(TRUE); @@ -2436,8 +2438,8 @@ bool partition_info::init_column_part() else loc_num_columns= MAX_REF_PARTS; if (!(col_val_array= - (part_column_list_val*)sql_calloc(loc_num_columns * - sizeof(part_column_list_val)))) + (part_column_list_val*) thd->calloc(loc_num_columns * + sizeof(part_column_list_val)))) { mem_alloc_error(loc_num_columns * sizeof(part_elem_value)); DBUG_RETURN(TRUE); @@ -2470,7 +2472,8 @@ bool partition_info::init_column_part() TRUE Failure FALSE Success */ -int partition_info::reorganize_into_single_field_col_val() + +int partition_info::reorganize_into_single_field_col_val(THD *thd) { part_column_list_val *col_val, *new_col_val; part_elem_value *val= curr_list_val; @@ -2486,11 +2489,11 @@ int partition_info::reorganize_into_single_field_col_val() { col_val= &val->col_val_array[i]; DBUG_ASSERT(part_type == LIST_PARTITION); - if (init_column_part()) + if (init_column_part(thd)) { DBUG_RETURN(TRUE); } - if (!(new_col_val= add_column_value())) + if (!(new_col_val= add_column_value(thd))) { DBUG_RETURN(TRUE); } @@ -3103,7 +3106,7 @@ void partition_info::print_debug(const char *str, uint *value) remove code parts using ifdef, but the code parts cannot be called so we simply need to add empty functions to make the linker happy. */ -part_column_list_val *partition_info::add_column_value() +part_column_list_val *partition_info::add_column_value(THD *thd) { return NULL; } @@ -3118,12 +3121,12 @@ bool partition_info::set_part_expr(char *start_token, Item *item_ptr, return FALSE; } -int partition_info::reorganize_into_single_field_col_val() +int partition_info::reorganize_into_single_field_col_val(THD *thd) { return 0; } -bool partition_info::init_column_part() +bool partition_info::init_column_part(THD *thd) { return FALSE; } @@ -3132,7 +3135,7 @@ bool partition_info::add_column_list_value(THD *thd, Item *item) { return FALSE; } -int partition_info::add_max_value() +int partition_info::add_max_value(THD *thd) { return 0; } diff --git a/sql/partition_info.h b/sql/partition_info.h index 8ad7b1fd1fd..8d423f6997a 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -292,7 +292,7 @@ public: } ~partition_info() {} - partition_info *get_clone(); + partition_info *get_clone(THD *thd); bool set_named_partition_bitmap(const char *part_name, uint length); bool set_partition_bitmaps(TABLE_LIST *table_list); /* Answers the question if subpartitioning is used for a certain table */ @@ -328,16 +328,16 @@ public: part_elem_value *val, uint part_id); bool fix_parser_data(THD *thd); - int add_max_value(); + int add_max_value(THD *thd); void init_col_val(part_column_list_val *col_val, Item *item); - int reorganize_into_single_field_col_val(); - part_column_list_val *add_column_value(); + int reorganize_into_single_field_col_val(THD *thd); + part_column_list_val *add_column_value(THD *thd); bool set_part_expr(char *start_token, Item *item_ptr, char *end_token, bool is_subpart); static int compare_column_values(const void *a, const void *b); bool set_up_charset_field_preps(); bool check_partition_field_length(); - bool init_column_part(); + bool init_column_part(THD *thd); bool add_column_list_value(THD *thd, Item *item); void set_show_version_string(String *packet); partition_element *get_part_elem(const char *partition_name, diff --git a/sql/protocol.cc b/sql/protocol.cc index ed962f3bdd1..249dd73e2df 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1520,7 +1520,7 @@ bool Protocol_binary::send_out_parameters(List<Item_param> *sp_params) if (!item_param->get_out_param_info()) continue; // It's an IN-parameter. - if (out_param_lst.push_back(item_param)) + if (out_param_lst.push_back(item_param, thd->mem_root)) return TRUE; } } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 4860935e9bf..4cf7df5227f 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -233,17 +233,26 @@ bool show_slave_hosts(THD* thd) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("show_slave_hosts"); - field_list.push_back(new (mem_root) Item_return_int(thd, "Server_id", 10, - MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Host", 20)); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Server_id", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Host", 20), + thd->mem_root); if (opt_show_slave_auth_info) { - 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 (mem_root) Item_empty_string(thd, "User", 20), + thd->mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Password", 20), + thd->mem_root); } - 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)); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Port", 7, MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Master_id", 10, MYSQL_TYPE_LONG), + thd->mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 9672c883b76..dadd9de748c 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -950,7 +950,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi, { Create_field *field_def= (Create_field*) alloc_root(thd->mem_root, sizeof(Create_field)); - if (field_list.push_back(field_def)) + if (field_list.push_back(field_def, thd->mem_root)) DBUG_RETURN(NULL); uint decimals= 0; diff --git a/sql/slave.cc b/sql/slave.cc index b254496ed41..3f9a7fb6ee1 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2520,110 +2520,207 @@ static bool send_show_master_info_header(THD *thd, bool full, if (full) { - field_list.push_back(new (mem_root) Item_empty_string(thd, "Connection_name", - MAX_CONNECTION_NAME)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_SQL_State", - 30)); - } - - field_list.push_back(new (mem_root) Item_empty_string(thd, "Slave_IO_State", - 30)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_Host", - sizeof(mi->host))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_User", - sizeof(mi->user))); - field_list.push_back(new (mem_root) Item_return_int(thd, "Master_Port", 7, - MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Connect_Retry", 10, - MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_Log_File", - FN_REFLEN)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Read_Master_Log_Pos", 10, - MYSQL_TYPE_LONGLONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Relay_Log_File", - FN_REFLEN)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Relay_Log_Pos", 10, - MYSQL_TYPE_LONGLONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Relay_Master_Log_File", - FN_REFLEN)); - 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 (mem_root) Item_empty_string(thd, "Replicate_Wild_Do_Table", - 24)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Replicate_Wild_Ignore_Table", - 28)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Last_Errno", 4, - MYSQL_TYPE_LONG)); - 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 (mem_root) Item_return_int(thd, "Exec_Master_Log_Pos", 10, - MYSQL_TYPE_LONGLONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Relay_Log_Space", 10, - MYSQL_TYPE_LONGLONG)); - 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 (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 (mem_root) Item_empty_string(thd, "Master_SSL_CA_Path", - sizeof(mi->ssl_capath))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Cert", - sizeof(mi->ssl_cert))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Cipher", - sizeof(mi->ssl_cipher))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Key", - sizeof(mi->ssl_key))); - field_list.push_back(new (mem_root) Item_return_int(thd, "Seconds_Behind_Master", 10, - MYSQL_TYPE_LONGLONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, - "Master_SSL_Verify_Server_Cert", - 3)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Last_IO_Errno", 4, - MYSQL_TYPE_LONG)); - 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 (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 (mem_root) Item_return_int(thd, "Master_Server_Id", - sizeof(ulong), - MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Crl", - sizeof(mi->ssl_crl))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Master_SSL_Crlpath", - sizeof(mi->ssl_crlpath))); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Using_Gtid", - sizeof("Current_Pos")-1)); - 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 (mem_root) Item_empty_string(thd, "Replicate_Ignore_Domain_Ids", - FN_REFLEN)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Parallel_Mode", - sizeof("conservative")-1)); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Connection_name", + MAX_CONNECTION_NAME), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Slave_SQL_State", 30), + thd->mem_root); + } + + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Slave_IO_State", 30), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_Host", sizeof(mi->host)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_User", sizeof(mi->user)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Master_Port", 7, MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Connect_Retry", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_Log_File", FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Read_Master_Log_Pos", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Relay_Log_File", FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Relay_Log_Pos", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Relay_Master_Log_File", + FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Slave_IO_Running", 3), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Slave_SQL_Running", 3), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Do_DB", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Ignore_DB", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Do_Table", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Ignore_Table", 23), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Wild_Do_Table", 24), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Wild_Ignore_Table", + 28), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Last_Errno", 4, MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Last_Error", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Skip_Counter", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Exec_Master_Log_Pos", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Relay_Log_Space", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Until_Condition", 6), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Until_Log_File", FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Until_Log_Pos", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Allowed", 7), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_CA_File", + sizeof(mi->ssl_ca)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_CA_Path", + sizeof(mi->ssl_capath)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Cert", + sizeof(mi->ssl_cert)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Cipher", + sizeof(mi->ssl_cipher)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Key", + sizeof(mi->ssl_key)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Seconds_Behind_Master", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Verify_Server_Cert", + 3), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Last_IO_Errno", 4, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Last_IO_Error", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Last_SQL_Errno", 4, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Last_SQL_Error", 20), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Ignore_Server_Ids", + FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Master_Server_Id", sizeof(ulong), + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Crl", + sizeof(mi->ssl_crl)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Master_SSL_Crlpath", + sizeof(mi->ssl_crlpath)), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Using_Gtid", + sizeof("Current_Pos")-1), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Gtid_IO_Pos", 30), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Do_Domain_Ids", + FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Replicate_Ignore_Domain_Ids", + FN_REFLEN), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Parallel_Mode", + sizeof("conservative")-1), + thd->mem_root); if (full) { - field_list.push_back(new (mem_root) Item_return_int(thd, "Retried_transactions", - 10, MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Max_relay_log_size", - 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Executed_log_entries", - 10, MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Slave_received_heartbeats", - 10, MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_float(thd, "Slave_heartbeat_period", - 0.0, 3, 10)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Gtid_Slave_Pos", - gtid_pos_length)); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Retried_transactions", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Max_relay_log_size", 10, + MYSQL_TYPE_LONGLONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Executed_log_entries", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Slave_received_heartbeats", 10, + MYSQL_TYPE_LONG), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_float(thd, "Slave_heartbeat_period", 0.0, 3, 10), + thd->mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Gtid_Slave_Pos", + gtid_pos_length), + thd->mem_root); } if (protocol->send_result_set_metadata(&field_list, diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1b525a9593b..d165cb8d883 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2574,8 +2574,12 @@ sp_head::show_create_routine(THD *thd, int type) /* Send header. */ - 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)); + fields.push_back(new (mem_root) + Item_empty_string(thd, col1_caption, NAME_CHAR_LEN), + thd->mem_root); + fields.push_back(new (mem_root) + Item_empty_string(thd, "sql_mode", sql_mode.length), + thd->mem_root); { /* @@ -2589,17 +2593,23 @@ sp_head::show_create_routine(THD *thd, int type) stmt_fld->maybe_null= TRUE; - fields.push_back(stmt_fld); + fields.push_back(stmt_fld, thd->mem_root); } - fields.push_back(new (mem_root) Item_empty_string(thd, "character_set_client", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "character_set_client", + MY_CS_NAME_SIZE), + thd->mem_root); - fields.push_back(new (mem_root) Item_empty_string(thd, "collation_connection", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "collation_connection", + MY_CS_NAME_SIZE), + thd->mem_root); - fields.push_back(new (mem_root) Item_empty_string(thd, "Database Collation", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "Database Collation", + MY_CS_NAME_SIZE), + thd->mem_root); if (protocol->send_result_set_metadata(&fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -2782,11 +2792,13 @@ 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 (thd->mem_root) Item_uint(thd, "Pos", 9)); + field_list.push_back(new (thd->mem_root) Item_uint(thd, "Pos", 9), + thd->mem_root); // 1024 is for not to confuse old clients field_list.push_back(new (thd->mem_root) Item_empty_string(thd, "Instruction", - MY_MAX(buffer.length(), 1024))); + MY_MAX(buffer.length(), 1024)), + thd->mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(1); diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 6afca24231b..faf5a2de891 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -205,7 +205,7 @@ sp_label *sp_pcontext::push_label(THD *thd, LEX_STRING name, uint ip) if (!label) return NULL; - m_labels.push_front(label); + m_labels.push_front(label, thd->mem_root); return label; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 374bf3b8dbe..bcb2a36280d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7796,9 +7796,10 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) strxmov(buff,"Grants for ",rolename, NullS); else strxmov(buff,"Grants for ",username,"@",hostname, NullS); - field_list.push_back(field); + field_list.push_back(field, thd->mem_root); if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) { mysql_mutex_unlock(&acl_cache->lock); mysql_rwlock_unlock(&LOCK_grant); @@ -10158,7 +10159,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, combo->auth= au->auth_string; } - if (user_list.push_back(combo)) + if (user_list.push_back(combo, thd->mem_root)) DBUG_RETURN(TRUE); thd->lex->ssl_type= SSL_TYPE_NOT_SPECIFIED; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index f8f5809d9c2..0787aa9e92f 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -326,15 +326,20 @@ 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 (thd->mem_root) Item_empty_string(thd, "Table", - NAME_CHAR_LEN * 2)); + field_list.push_back(item= new (thd->mem_root) + Item_empty_string(thd, "Table", + NAME_CHAR_LEN * 2), thd->mem_root); item->maybe_null = 1; - field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Op", 10)); + field_list.push_back(item= new (thd->mem_root) + Item_empty_string(thd, "Op", 10), thd->mem_root); item->maybe_null = 1; - field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Msg_type", 10)); + field_list.push_back(item= new (thd->mem_root) + Item_empty_string(thd, "Msg_type", 10), thd->mem_root); item->maybe_null = 1; - field_list.push_back(item= new (thd->mem_root) Item_empty_string(thd, "Msg_text", - SQL_ADMIN_MSG_TEXT_SIZE)); + field_list.push_back(item= new (thd->mem_root) + Item_empty_string(thd, "Msg_text", + SQL_ADMIN_MSG_TEXT_SIZE), + thd->mem_root); item->maybe_null = 1; if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index fe0834e4d47..1f801a33dcd 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -1188,7 +1188,7 @@ bool analyse::change_columns(THD *thd, List<Item> &field_list) output_str_length)); for (uint i = 0; i < array_elements(func_items); i++) - field_list.push_back(func_items[i]); + field_list.push_back(func_items[i], thd->mem_root); result_fields = field_list; return 0; } // analyse::change_columns diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7afe167738b..a97827bae88 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7442,12 +7442,12 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join, nj_col_1= it_1.get_natural_column_ref(); if (nj_col_1->is_common) { - natural_using_join->join_columns->push_back(nj_col_1); + natural_using_join->join_columns->push_back(nj_col_1, thd->mem_root); /* Reset the common columns for the next call to mark_common_columns. */ nj_col_1->is_common= FALSE; } else - non_join_columns->push_back(nj_col_1); + non_join_columns->push_back(nj_col_1, thd->mem_root); } /* @@ -7487,7 +7487,7 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join, { nj_col_2= it_2.get_natural_column_ref(); if (!nj_col_2->is_common) - non_join_columns->push_back(nj_col_2); + non_join_columns->push_back(nj_col_2, thd->mem_root); else { /* Reset the common columns for the next call to mark_common_columns. */ @@ -8054,7 +8054,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context, { List_iterator_fast <TABLE_LIST> ti(select_lex->leaf_tables_prep); while ((table_list= ti++)) - leaves.push_back(table_list); + leaves.push_back(table_list, thd->mem_root); } while ((table_list= ti++)) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9d3bdf51b8c..e77aa0d3d39 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2459,8 +2459,8 @@ void THD::make_explain_json_field_list(List<Item> &field_list, bool is_analyze) Item *item= new (mem_root) Item_empty_string(this, (is_analyze ? "ANALYZE" : "EXPLAIN"), - 78, system_charset_info); - field_list.push_back(item); + 78, system_charset_info); + field_list.push_back(item, mem_root); } @@ -2479,68 +2479,77 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags, CHARSET_INFO *cs= system_charset_info; field_list.push_back(item= new (mem_root) Item_return_int(this, "id", 3, - MYSQL_TYPE_LONGLONG)); + MYSQL_TYPE_LONGLONG), mem_root); item->maybe_null= 1; field_list.push_back(new (mem_root) - Item_empty_string(this, "select_type", 19, cs)); + Item_empty_string(this, "select_type", 19, cs), + mem_root); field_list.push_back(item= new (mem_root) - Item_empty_string(this, "table", NAME_CHAR_LEN, cs)); + Item_empty_string(this, "table", NAME_CHAR_LEN, cs), + mem_root); item->maybe_null= 1; if (explain_flags & DESCRIBE_PARTITIONS) { /* Maximum length of string that make_used_partitions_str() can produce */ item= new (mem_root) Item_empty_string(this, "partitions", MAX_PARTITIONS * (1 + FN_LEN), cs); - field_list.push_back(item); + field_list.push_back(item, mem_root); item->maybe_null= 1; } field_list.push_back(item= new (mem_root) - Item_empty_string(this, "type", 10, cs)); + Item_empty_string(this, "type", 10, cs), + mem_root); item->maybe_null= 1; field_list.push_back(item= new (mem_root) Item_empty_string(this, "possible_keys", - NAME_CHAR_LEN*MAX_KEY, cs)); + NAME_CHAR_LEN*MAX_KEY, cs), + mem_root); item->maybe_null=1; field_list.push_back(item=new (mem_root) - Item_empty_string(this, "key", NAME_CHAR_LEN, cs)); + Item_empty_string(this, "key", NAME_CHAR_LEN, cs), + mem_root); item->maybe_null=1; field_list.push_back(item=new (mem_root) Item_empty_string(this, "key_len", - NAME_CHAR_LEN*MAX_KEY)); + NAME_CHAR_LEN*MAX_KEY), + mem_root); item->maybe_null=1; field_list.push_back(item=new (mem_root) Item_empty_string(this, "ref", - NAME_CHAR_LEN*MAX_REF_PARTS, - cs)); + NAME_CHAR_LEN*MAX_REF_PARTS, cs), + mem_root); item->maybe_null=1; field_list.push_back(item= new (mem_root) - Item_return_int(this, "rows", 10, - MYSQL_TYPE_LONGLONG)); + Item_return_int(this, "rows", 10, MYSQL_TYPE_LONGLONG), + mem_root); if (is_analyze) { field_list.push_back(item= new (mem_root) - Item_float(this, "r_rows", 0.1234, 10, 4)); + Item_float(this, "r_rows", 0.1234, 10, 4), + mem_root); item->maybe_null=1; } if (is_analyze || (explain_flags & DESCRIBE_EXTENDED)) { field_list.push_back(item= new (mem_root) - Item_float(this, "filtered", 0.1234, 2, 4)); + Item_float(this, "filtered", 0.1234, 2, 4), + mem_root); item->maybe_null=1; } if (is_analyze) { field_list.push_back(item= new (mem_root) - Item_float(this, "r_filtered", 0.1234, 2, - 4)); + Item_float(this, "r_filtered", 0.1234, 2, 4), + mem_root); item->maybe_null=1; } item->maybe_null= 1; field_list.push_back(new (mem_root) - Item_empty_string(this, "Extra", 255, cs)); + Item_empty_string(this, "Extra", 255, cs), + mem_root); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 09cdbceebed..645862f8183 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5316,7 +5316,7 @@ inline bool add_item_to_list(THD *thd, Item *item) inline bool add_value_to_list(THD *thd, Item *value) { - return thd->lex->value_list.push_back(value); + return thd->lex->value_list.push_back(value, thd->mem_root); } inline bool add_order_to_list(THD *thd, Item *item, bool asc) diff --git a/sql/sql_error.cc b/sql/sql_error.cc index f7eb6dd6a1f..47f24ad9cb8 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -815,25 +815,29 @@ 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 (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, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(TRUE); - const Sql_condition *err; SELECT_LEX *sel= &thd->lex->select_lex; SELECT_LEX_UNIT *unit= &thd->lex->unit; ulonglong idx= 0; Protocol *protocol=thd->protocol; + DBUG_ENTER("mysqld_show_warnings"); + + DBUG_ASSERT(thd->get_stmt_da()->is_warning_info_read_only()); + + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Level", 7), + mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Code", 4, MYSQL_TYPE_LONG), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Message", MYSQL_ERRMSG_SIZE), + mem_root); + + if (protocol->send_result_set_metadata(&field_list, + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) + DBUG_RETURN(TRUE); unit->set_limit(sel); diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index a983f2598e9..15ee67a0318 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -204,7 +204,8 @@ int Explain_query::print_explain(select_result_sink *output, } -void Explain_query::print_explain_json(select_result_sink *output, bool is_analyze) +void Explain_query::print_explain_json(select_result_sink *output, + bool is_analyze) { Json_writer writer; writer.start_object(); @@ -228,7 +229,8 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy List<Item> item_list; String *buf= &writer.output; item_list.push_back(new (thd->mem_root) - Item_string(thd, buf->ptr(), buf->length(), cs)); + Item_string(thd, buf->ptr(), buf->length(), cs), + thd->mem_root); output->send_data(item_list); } @@ -260,13 +262,16 @@ 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 (thd->mem_root) Item_string_sys(thd, str)); + item_list->push_back(new (thd->mem_root) Item_string_sys(thd, str), + thd->mem_root); } static void push_string(THD *thd, List<Item> *item_list, String *str) { - item_list->push_back(new (thd->mem_root) Item_string_sys(thd, str->ptr(), str->length())); + item_list->push_back(new (thd->mem_root) + Item_string_sys(thd, str->ptr(), str->length()), + thd->mem_root); } static void push_string_list(THD *thd, List<Item> *item_list, @@ -318,26 +323,31 @@ int print_explain_row(select_result_sink *result, const char *extra) { THD *thd= result->thd; - Item *item_null= new (thd->mem_root) Item_null(thd); + MEM_ROOT *mem_root= thd->mem_root; + Item *item_null= new (mem_root) Item_null(thd); List<Item> item_list; Item *item; - MEM_ROOT *mem_root= thd->mem_root; - 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)); + item_list.push_back(new (mem_root) Item_int(thd, (int32) select_number), + mem_root); + item_list.push_back(new (mem_root) Item_string_sys(thd, select_type), + mem_root); + item_list.push_back(new (mem_root) Item_string_sys(thd, table_name), + mem_root); if (options & DESCRIBE_PARTITIONS) { if (partitions) { - item_list.push_back(new (mem_root) Item_string_sys(thd, partitions)); + item_list.push_back(new (mem_root) Item_string_sys(thd, partitions), + mem_root); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } const char *jtype_str= join_type_str[jtype]; - item_list.push_back(new (mem_root) Item_string_sys(thd, jtype_str)); + item_list.push_back(new (mem_root) Item_string_sys(thd, jtype_str), + mem_root); /* 'possible_keys' */ if (possible_keys && !possible_keys->is_empty()) @@ -346,52 +356,55 @@ int print_explain_row(select_result_sink *result, push_string_list(thd, &item_list, *possible_keys, &possible_keys_buf); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* 'index */ item= index ? new (mem_root) Item_string_sys(thd, index) : item_null; - item_list.push_back(item); + item_list.push_back(item, mem_root); /* 'key_len */ item= key_len ? new (mem_root) Item_string_sys(thd, key_len) : item_null; - item_list.push_back(item); + item_list.push_back(item, mem_root); /* 'ref' */ item= ref ? new (mem_root) Item_string_sys(thd, ref) : item_null; - item_list.push_back(item); + item_list.push_back(item, mem_root); /* 'rows' */ if (rows) { - item_list.push_back(new (mem_root) Item_int(thd, *rows, - MY_INT64_NUM_DECIMAL_DIGITS)); + item_list.push_back(new (mem_root) + Item_int(thd, *rows, MY_INT64_NUM_DECIMAL_DIGITS), + mem_root); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* 'r_rows' */ if (is_analyze) { if (r_rows) - item_list.push_back(new (mem_root) Item_float(thd, *r_rows, 2)); + item_list.push_back(new (mem_root) Item_float(thd, *r_rows, 2), + mem_root); else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } /* 'filtered' */ const double filtered=100.0; if (options & DESCRIBE_EXTENDED || is_analyze) - item_list.push_back(new (mem_root) Item_float(thd, filtered, 2)); + item_list.push_back(new (mem_root) Item_float(thd, filtered, 2), mem_root); /* 'r_filtered' */ if (is_analyze) - item_list.push_back(new (mem_root) Item_float(thd, r_filtered, 2)); + item_list.push_back(new (mem_root) Item_float(thd, r_filtered, 2), + mem_root); /* 'Extra' */ if (extra) - item_list.push_back(new (mem_root) Item_string_sys(thd, extra)); + item_list.push_back(new (mem_root) Item_string_sys(thd, extra), mem_root); else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); if (result->send_data(item_list)) return 1; @@ -435,9 +448,8 @@ int Explain_union::print_explain(Explain_query *query, bool is_analyze) { THD *thd= output->thd; - //CHARSET_INFO *cs= system_charset_info; - char table_name_buffer[SAFE_NAME_LEN]; MEM_ROOT *mem_root= thd->mem_root; + char table_name_buffer[SAFE_NAME_LEN]; /* print all UNION children, in order */ for (int i= 0; i < (int) union_members.elements(); i++) @@ -454,51 +466,53 @@ int Explain_union::print_explain(Explain_query *query, Item *item_null= new (mem_root) Item_null(thd); /* `id` column */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `select_type` column */ push_str(thd, &item_list, fake_select_type); /* `table` column: something like "<union1,2>" */ uint len= make_union_table_name(table_name_buffer); - item_list.push_back(new (mem_root) Item_string_sys(thd, table_name_buffer, len)); + item_list.push_back(new (mem_root) + Item_string_sys(thd, table_name_buffer, len), + mem_root); /* `partitions` column */ if (explain_flags & DESCRIBE_PARTITIONS) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `type` column */ push_str(thd, &item_list, join_type_str[JT_ALL]); /* `possible_keys` column */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `key` */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `key_len` */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `ref` */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `rows` */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `r_rows` */ if (is_analyze) { double avg_rows= fake_select_lex_tracker.get_avg_rows(); - item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2)); + item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2), mem_root); } /* `filtered` */ if (explain_flags & DESCRIBE_EXTENDED || is_analyze) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `r_filtered` */ if (is_analyze) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `Extra` */ StringBuffer<256> extra_buf; @@ -506,8 +520,10 @@ int Explain_union::print_explain(Explain_query *query, { extra_buf.append(STRING_WITH_LEN("Using filesort")); } - item_list.push_back(new (mem_root) Item_string_sys(thd, extra_buf.ptr(), - extra_buf.length())); + item_list.push_back(new (mem_root) + Item_string_sys(thd, extra_buf.ptr(), + extra_buf.length()), + mem_root); //output->unit.offset_limit_cnt= 0; if (output->send_data(item_list)) @@ -710,25 +726,28 @@ int Explain_select::print_explain(Explain_query *query, List<Item> item_list; Item *item_null= new (mem_root) Item_null(thd); - 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)); + item_list.push_back(new (mem_root) Item_int(thd, (int32) select_id), + mem_root); + item_list.push_back(new (mem_root) Item_string_sys(thd, select_type), + mem_root); for (uint i=0 ; i < 7; i++) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); if (explain_flags & DESCRIBE_PARTITIONS) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* filtered */ if (is_analyze || explain_flags & DESCRIBE_EXTENDED) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); if (is_analyze) { /* r_rows, r_filtered */ - item_list.push_back(item_null); - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); + item_list.push_back(item_null, mem_root); } - item_list.push_back(new (mem_root) Item_string_sys(thd, message)); + item_list.push_back(new (mem_root) Item_string_sys(thd, message), + mem_root); if (output->send_data(item_list)) return 1; @@ -1122,7 +1141,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai Item *item_null= new (mem_root) Item_null(thd); /* `id` column */ - item_list.push_back(new (mem_root) Item_int(thd, (int32) select_id)); + item_list.push_back(new (mem_root) Item_int(thd, (int32) select_id), + mem_root); /* `select_type` column */ push_str(thd, &item_list, select_type); @@ -1138,7 +1158,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai push_string(thd, &item_list, &used_partitions); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } /* `type` column */ @@ -1147,7 +1167,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai /* `possible_keys` column */ StringBuffer<64> possible_keys_buf; if (possible_keys.is_empty()) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); else push_string_list(thd, &item_list, possible_keys, &possible_keys_buf); @@ -1158,7 +1178,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai if (key_str.length() > 0) push_string(thd, &item_list, &key_str); else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `key_len` */ StringBuffer<64> key_len_str; @@ -1167,7 +1187,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai if (key_len_str.length() > 0) push_string(thd, &item_list, &key_len_str); else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `ref` */ StringBuffer<64> ref_list_buf; @@ -1179,7 +1199,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai push_str(thd, &item_list, ""); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } else push_string_list(thd, &item_list, ref_list, &ref_list_buf); @@ -1187,23 +1207,26 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai /* `rows` */ if (rows_set) { - item_list.push_back(new (mem_root) Item_int(thd, (longlong) (ulonglong) rows, - MY_INT64_NUM_DECIMAL_DIGITS)); + item_list.push_back(new (mem_root) + Item_int(thd, (longlong) (ulonglong) rows, + MY_INT64_NUM_DECIMAL_DIGITS), + mem_root); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `r_rows` */ if (is_analyze) { if (!tracker.has_scans()) { - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } else { double avg_rows= tracker.get_avg_rows(); - item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2)); + item_list.push_back(new (mem_root) Item_float(thd, avg_rows, 2), + mem_root); } } @@ -1212,10 +1235,11 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai { if (filtered_set) { - item_list.push_back(new (mem_root) Item_float(thd, filtered, 2)); + item_list.push_back(new (mem_root) Item_float(thd, filtered, 2), + mem_root); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } /* `r_filtered` */ @@ -1223,14 +1247,16 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai { if (!tracker.has_scans()) { - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); } else { 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 (mem_root) Item_float(thd, r_filtered * 100.0, 2)); + item_list.push_back(new (mem_root) + Item_float(thd, r_filtered * 100.0, 2), + mem_root); } } @@ -1264,8 +1290,10 @@ 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 (mem_root) Item_string_sys(thd, extra_buf.ptr(), - extra_buf.length())); + item_list.push_back(new (mem_root) + Item_string_sys(thd, extra_buf.ptr(), + extra_buf.length()), + mem_root); if (output->send_data(item_list)) return 1; diff --git a/sql/sql_help.cc b/sql/sql_help.cc index eb0e260c3f4..a0e836da203 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -151,10 +151,10 @@ void memorize_variant_topic(THD *thd, TABLE *topics, int count, else { if (count == 1) - names->push_back(name); + names->push_back(name, thd->mem_root); String *new_name= new (thd->mem_root) String; get_field(mem_root,find_fields[help_topic_name].field,new_name); - names->push_back(new_name); + names->push_back(new_name, thd->mem_root); } DBUG_VOID_RETURN; } @@ -380,7 +380,7 @@ int search_categories(THD *thd, TABLE *categories, get_field(thd->mem_root,pfname,lname); if (++count == 1 && res_id) *res_id= (int16) pcat_id->val_int(); - names->push_back(lname); + names->push_back(lname, thd->mem_root); } end_read_record(&read_record_info); @@ -415,7 +415,7 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname, continue; String *name= new (thd->mem_root) String(); get_field(thd->mem_root,pfname,name); - res->push_back(name); + res->push_back(name, thd->mem_root); } end_read_record(&read_record_info); @@ -454,9 +454,12 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) DBUG_ENTER("send_answer_1"); List<Item> field_list; - 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)); + field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "description", 1000), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "example", 1000), + mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -500,11 +503,17 @@ int send_header_2(Protocol *protocol, bool for_category) DBUG_ENTER("send_header_2"); List<Item> field_list; if (for_category) - field_list.push_back(new (mem_root) Item_empty_string(thd, "source_category_name", - 64)); - 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 | + field_list.push_back(new (mem_root) + Item_empty_string(thd, "source_category_name", 64), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "name", 64), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "is_it_category", 1), + mem_root); + DBUG_RETURN(protocol->send_result_set_metadata(&field_list, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 420a4101c8e..004b9c3cfd9 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3957,7 +3957,7 @@ static TABLE *create_table_from_items(THD *thd, DBUG_RETURN(0); if (item->maybe_null) cr_field->flags &= ~NOT_NULL_FLAG; - alter_info->create_list.push_back(cr_field); + alter_info->create_list.push_back(cr_field, thd->mem_root); } DEBUG_SYNC(thd,"create_table_select_before_create"); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 6c835c4293f..0dce2f4c0ae 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2334,9 +2334,9 @@ bool st_select_lex::add_group_to_list(THD *thd, Item *item, bool asc) } -bool st_select_lex::add_ftfunc_to_list(Item_func_match *func) +bool st_select_lex::add_ftfunc_to_list(THD *thd, Item_func_match *func) { - return !func || ftfunc_list->push_back(func); // end of memory? + return !func || ftfunc_list->push_back(func, thd->mem_root); // end of memory? } @@ -3459,7 +3459,7 @@ void st_select_lex::alloc_index_hints (THD *thd) */ bool st_select_lex::add_index_hint (THD *thd, char *str, uint length) { - return index_hints->push_front (new (thd->mem_root) + return index_hints->push_front(new (thd->mem_root) Index_hint(current_index_hint_type, current_index_hint_clause, str, length), thd->mem_root); @@ -3800,7 +3800,7 @@ bool SELECT_LEX::merge_subquery(THD *thd, TABLE_LIST *derived, Item_in_subselect *in_subq; while ((in_subq= li++)) { - sj_subselects.push_back(in_subq); + sj_subselects.push_back(in_subq, thd->mem_root); if (in_subq->emb_on_expr_nest == NO_JOIN_NEST) in_subq->emb_on_expr_nest= derived; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 09a3d5e2585..da44cb31523 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -926,7 +926,7 @@ public: bool add_item_to_list(THD *thd, Item *item); bool add_group_to_list(THD *thd, Item *item, bool asc); - bool add_ftfunc_to_list(Item_func_match *func); + bool add_ftfunc_to_list(THD *thd, Item_func_match *func); bool add_order_to_list(THD *thd, Item *item, bool asc); bool add_gorder_to_list(THD *thd, Item *item, bool asc); TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table, diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 1c08df22755..7d64f263a4a 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -99,7 +99,7 @@ public: /* load xml */ List<XML_TAG> taglist; int read_value(int delim, String *val); - int read_xml(); + int read_xml(THD *thd); int clear_level(int level); my_off_t file_length() { return cache.end_of_file; } @@ -270,7 +270,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, Item *item; if (!(item= field_iterator.create_item(thd))) DBUG_RETURN(TRUE); - fields_vars.push_back(item->real_item()); + fields_vars.push_back(item->real_item(), thd->mem_root); } bitmap_set_all(table->write_set); /* @@ -1151,7 +1151,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } // read row tag and save values into tag list - if (read_info.read_xml()) + if (read_info.read_xml(thd)) break; List_iterator_fast<XML_TAG> xmlit(read_info.taglist); @@ -1875,7 +1875,7 @@ int READ_INFO::read_value(int delim, String *val) tags and attributes are stored in taglist when tag set in ROWS IDENTIFIED BY is closed, we are ready and return */ -int READ_INFO::read_xml() +int READ_INFO::read_xml(THD *thd) { DBUG_ENTER("READ_INFO::read_xml"); int chr, chr2, chr3; @@ -1973,11 +1973,13 @@ int READ_INFO::read_xml() goto found_eof; /* save value to list */ - if(tag.length() > 0 && value.length() > 0) + if (tag.length() > 0 && value.length() > 0) { DBUG_PRINT("read_xml", ("lev:%i tag:%s val:%s", level,tag.c_ptr_safe(), value.c_ptr_safe())); - taglist.push_front( new XML_TAG(level, tag, value)); + XML_TAG *tmp= new XML_TAG(level, tag, value); + if (!tmp || taglist.push_front(tmp, thd->mem_root)) + DBUG_RETURN(1); // End of memory } tag.length(0); value.length(0); @@ -2037,13 +2039,15 @@ int READ_INFO::read_xml() } chr= read_value(delim, &value); - if(attribute.length() > 0 && value.length() > 0) + if (attribute.length() > 0 && value.length() > 0) { DBUG_PRINT("read_xml", ("lev:%i att:%s val:%s\n", level + 1, attribute.c_ptr_safe(), value.c_ptr_safe())); - taglist.push_front(new XML_TAG(level + 1, attribute, value)); + XML_TAG *tmp= new XML_TAG(level + 1, attribute, value); + if (!tmp || taglist.push_front(tmp, thd->mem_root)) + DBUG_RETURN(1); // End of memory } attribute.length(0); value.length(0); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b890bba0d24..94daad42c39 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2754,7 +2754,7 @@ mysql_execute_command(THD *thd) } } DBUG_ASSERT(o); - lex->old_var_list.push_back(o); + lex->old_var_list.push_back(o, thd->mem_root); } lex->reset_arena_for_set_stmt(&backup); if (lex->old_var_list.is_empty()) @@ -3273,7 +3273,7 @@ mysql_execute_command(THD *thd) #ifdef WITH_PARTITION_STORAGE_ENGINE { partition_info *part_info= thd->lex->part_info; - if (part_info && !(part_info= thd->lex->part_info->get_clone())) + if (part_info && !(part_info= thd->lex->part_info->get_clone(thd))) { res= -1; goto end_with_restore_list; @@ -7551,7 +7551,7 @@ bool st_select_lex::init_nested_join(THD *thd) nested_join= ptr->nested_join= ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); - join_list->push_front(ptr); + join_list->push_front(ptr, thd->mem_root); ptr->embedding= embedding; ptr->join_list= join_list; ptr->alias= (char*) "(nested_join)"; @@ -7593,7 +7593,7 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd) join_list->pop(); embedded->join_list= join_list; embedded->embedding= embedding; - join_list->push_front(embedded); + join_list->push_front(embedded, thd->mem_root); ptr= embedded; embedded->lifted= 1; } @@ -7657,7 +7657,7 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd) ptr->join_using_fields= prev_join_using; } } - join_list->push_front(ptr); + join_list->push_front(ptr, thd->mem_root); nested_join->used_tables= nested_join->not_null_tables= (table_map) 0; DBUG_RETURN(ptr); } @@ -7724,8 +7724,8 @@ TABLE_LIST *st_select_lex::convert_right_join() TABLE_LIST *tab1= join_list->pop(); DBUG_ENTER("convert_right_join"); - join_list->push_front(tab2); - join_list->push_front(tab1); + join_list->push_front(tab2, parent_lex->thd->mem_root); + join_list->push_front(tab1, parent_lex->thd->mem_root); tab1->outer_join|= JOIN_TYPE_RIGHT; DBUG_RETURN(tab1); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 5474d2f1b80..07de64d30bb 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4724,7 +4724,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, thd->work_part_info= thd->lex->part_info; if (thd->work_part_info && - !(thd->work_part_info= thd->lex->part_info->get_clone())) + !(thd->work_part_info= thd->lex->part_info->get_clone(thd))) DBUG_RETURN(TRUE); /* ALTER_ADMIN_PARTITION is handled in mysql_admin_table */ @@ -4804,7 +4804,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, Create copy of partition_info to avoid modifying original TABLE::part_info, to keep it safe for later use. */ - if (!(tab_part_info= tab_part_info->get_clone())) + if (!(tab_part_info= tab_part_info->get_clone(thd))) DBUG_RETURN(TRUE); } @@ -4855,7 +4855,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, we read data from old version of table using this TABLE object while copying them to new version of table. */ - if (!(tab_part_info= tab_part_info->get_clone())) + if (!(tab_part_info= tab_part_info->get_clone(thd))) DBUG_RETURN(TRUE); } DBUG_PRINT("info", ("*fast_alter_table flags: 0x%x", flags)); @@ -5152,7 +5152,7 @@ that are reorganised. partition_element *part_elem= alt_it++; if (*fast_alter_table) part_elem->part_state= PART_TO_BE_ADDED; - if (tab_part_info->partitions.push_back(part_elem)) + if (tab_part_info->partitions.push_back(part_elem, thd->mem_root)) { mem_alloc_error(1); goto err; @@ -5459,7 +5459,8 @@ the generated partition syntax in a correct manner. else tab_max_range= part_elem->range_value; if (*fast_alter_table && - tab_part_info->temp_partitions.push_back(part_elem)) + tab_part_info->temp_partitions.push_back(part_elem, + thd->mem_root)) { mem_alloc_error(1); goto err; @@ -5643,7 +5644,7 @@ the generated partition syntax in a correct manner. Create a copy of TABLE::part_info to be able to modify it freely. */ - if (!(tab_part_info= tab_part_info->get_clone())) + if (!(tab_part_info= tab_part_info->get_clone(thd))) DBUG_RETURN(TRUE); thd->work_part_info= tab_part_info; if (create_info->used_fields & HA_CREATE_USED_ENGINE && @@ -6634,7 +6635,7 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, } } /* Ensure the share is destroyed and reopened. */ - part_info= lpt->part_info->get_clone(); + part_info= lpt->part_info->get_clone(thd); close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); } else @@ -6652,7 +6653,7 @@ err_exclusive_lock: the table cache. */ mysql_lock_remove(thd, thd->lock, table); - part_info= lpt->part_info->get_clone(); + part_info= lpt->part_info->get_clone(thd); close_thread_table(thd, &thd->open_tables); lpt->table_list->table= NULL; } diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 96f67c3302b..99bc161501e 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -805,7 +805,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd) String(partition_name, system_charset_info); if (!str_partition_name) DBUG_RETURN(true); - partition_names_list.push_back(str_partition_name); + partition_names_list.push_back(str_partition_name, thd->mem_root); } first_table->partition_names= &partition_names_list; if (first_table->table->part_info->set_partition_bitmaps(first_table)) diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index 28ceccc695a..bc11f5fdb21 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -386,30 +386,35 @@ void PROFILING::finish_current_query_impl() 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 (mem_root) Item_return_int(thd, "Query_ID", 10, - MYSQL_TYPE_LONG)); - field_list.push_back(new (mem_root) Item_return_int(thd, "Duration", - TIME_FLOAT_DIGITS - 1, - MYSQL_TYPE_DOUBLE)); - 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)) - DBUG_RETURN(TRUE); - SELECT_LEX *sel= &thd->lex->select_lex; SELECT_LEX_UNIT *unit= &thd->lex->unit; ha_rows idx= 0; Protocol *protocol= thd->protocol; + void *iterator; + DBUG_ENTER("PROFILING::show_profiles"); + + field_list.push_back(new (mem_root) + Item_return_int(thd, "Query_ID", 10, + MYSQL_TYPE_LONG), + mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Duration", + TIME_FLOAT_DIGITS - 1, + MYSQL_TYPE_DOUBLE), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Query", 40), + mem_root); + + if (protocol->send_result_set_metadata(&field_list, + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) + DBUG_RETURN(TRUE); unit->set_limit(sel); - void *iterator; for (iterator= history.new_iterator(); iterator != NULL; iterator= history.iterator_next(iterator)) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ce19bf0846b..6d03d23f800 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -4004,11 +4004,19 @@ bool show_binlog_info(THD* thd) DBUG_ENTER("show_binlog_info"); List<Item> field_list; - 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 (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)); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "File", FN_REFLEN), + mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "Position", 20, + MYSQL_TYPE_LONGLONG), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Binlog_Do_DB", 255), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Binlog_Ignore_DB", 255), + mem_root); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -4060,9 +4068,13 @@ bool show_binlogs(THD* thd) DBUG_RETURN(TRUE); } - 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)); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Log_name", 255), + mem_root); + field_list.push_back(new (mem_root) + Item_return_int(thd, "File_size", 20, + MYSQL_TYPE_LONGLONG), + mem_root); 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 daffa8a4cbe..2a573b38f53 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -481,7 +481,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, int el= all_fields.elements; ref_pointer_array[el]= item; /* Add the field item to the select list of the current select. */ - all_fields.push_front(item); + all_fields.push_front(item, thd->mem_root); /* If it's needed reset each Item_ref item that refers this field with a new reference taken from ref_pointer_array. @@ -895,7 +895,7 @@ JOIN::prepare(Item ***rref_pointer_array, 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); + all_fields.push_front(field, thd->mem_root); ord->item= ref_pointer_array + el; } } @@ -3903,7 +3903,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, if (!join->cond_equal) join->cond_equal= new COND_EQUAL; join->cond_equal->current_level.empty(); - join->cond_equal->current_level.push_back((Item_equal*) conds); + join->cond_equal->current_level.push_back((Item_equal*) conds, + join->thd->mem_root); } } @@ -5567,7 +5568,7 @@ is_indexed_agg_distinct(JOIN *join, List<Item_field> *out_args) Item_field* item= static_cast<Item_field*>(expr->real_item()); if (out_args) - out_args->push_back(item); + out_args->push_back(item, join->thd->mem_root); cur_aggdistinct_fields.set_bit(item->field->field_index); result= true; @@ -8569,7 +8570,7 @@ get_best_combination(JOIN *join) DBUG_RETURN(TRUE); jt_range->start= jt; jt_range->end= jt + sjm->tables; - join->join_tab_ranges.push_back(jt_range); + join->join_tab_ranges.push_back(jt_range, join->thd->mem_root); j->bush_children= jt_range; sjm_nest_end= jt + sjm->tables; sjm_nest_root= j; @@ -11033,7 +11034,7 @@ void JOIN_TAB::remove_redundant_bnl_scan_conds() } } if (!found_cond) - reduced_select_cond->add(pushed_item); + reduced_select_cond->add(pushed_item, join->thd->mem_root); } } else @@ -11041,7 +11042,7 @@ void JOIN_TAB::remove_redundant_bnl_scan_conds() while ((pushed_item= pushed_cond_li++)) { if (!pushed_item->eq(cache_select->cond, 0)) - reduced_select_cond->add(pushed_item); + reduced_select_cond->add(pushed_item, join->thd->mem_root); } } @@ -12182,7 +12183,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, Delay the evaluation of constant ORDER and/or GROUP expressions that contain subqueries until the execution phase. */ - join->exec_const_order_group_cond.push_back(order->item[0]); + join->exec_const_order_group_cond.push_back(order->item[0], + join->thd->mem_root); } DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); continue; @@ -12570,21 +12572,21 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, /* left_item_equal of an upper level contains left_item */ left_item_equal= new (thd->mem_root) Item_equal(thd, left_item_equal); left_item_equal->set_context_field(((Item_field*) left_item)); - cond_equal->current_level.push_back(left_item_equal); + cond_equal->current_level.push_back(left_item_equal, thd->mem_root); } if (right_copyfl) { /* right_item_equal of an upper level contains right_item */ right_item_equal= new (thd->mem_root) Item_equal(thd, right_item_equal); right_item_equal->set_context_field(((Item_field*) right_item)); - cond_equal->current_level.push_back(right_item_equal); + cond_equal->current_level.push_back(right_item_equal, thd->mem_root); } if (left_item_equal) { /* left item was found in the current or one of the upper levels */ if (! right_item_equal) - left_item_equal->add(orig_right_item); + left_item_equal->add(orig_right_item, thd->mem_root); else { /* Merge two multiple equalities forming a new one */ @@ -12599,7 +12601,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, { /* left item was not found neither the current nor in upper levels */ if (right_item_equal) - right_item_equal->add(orig_left_item); + right_item_equal->add(orig_left_item, thd->mem_root); else { /* None of the fields was found in multiple equalities */ @@ -12608,7 +12610,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, orig_right_item, FALSE); item_equal->set_context_field((Item_field*)left_item); - cond_equal->current_level.push_back(item_equal); + cond_equal->current_level.push_back(item_equal, thd->mem_root); } } return TRUE; @@ -12664,7 +12666,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, if (copyfl) { item_equal= new (thd->mem_root) Item_equal(thd, item_equal); - cond_equal->current_level.push_back(item_equal); + cond_equal->current_level.push_back(item_equal, thd->mem_root); item_equal->set_context_field(field_item); } if (item_equal) @@ -12746,7 +12748,7 @@ static bool check_row_equality(THD *thd, Item *left_row, Item_row *right_row, eq_item->set_cmp_func_and_arg_cmp_context()) return FALSE; eq_item->quick_fix_field(); - eq_list->push_back(eq_item); + eq_list->push_back(eq_item, thd->mem_root); } } return TRUE; @@ -13493,7 +13495,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, if (produce_equality) { - if (eq_item && eq_list.push_back(eq_item)) + if (eq_item && eq_list.push_back(eq_item, thd->mem_root)) return 0; /* @@ -13538,7 +13540,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, - if we have only one condition to return, we don't create an Item_cond_and */ - if (eq_item && eq_list.push_back(eq_item)) + if (eq_item && eq_list.push_back(eq_item, thd->mem_root)) return 0; COND *res= 0; switch (eq_list.elements) @@ -13562,7 +13564,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, res= cond; ((Item_cond *) res)->add_at_end(&eq_list); } - else if (eq_list.push_front(cond)) + else if (eq_list.push_front(cond, thd->mem_root)) return 0; } } @@ -13715,7 +13717,7 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, { /* Do not add an equality condition if it's always true */ if (eq_cond->type() != Item::INT_ITEM && - cond_list->push_front(eq_cond)) + cond_list->push_front(eq_cond, thd->mem_root)) eq_cond= 0; } } @@ -14332,7 +14334,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, If this is a semi-join that is not contained within another semi-join, leave it intact (otherwise it is flattened) */ - join->select_lex->sj_nests.push_back(table); + join->select_lex->sj_nests.push_back(table, join->thd->mem_root); /* Also, walk through semi-join children and mark those that are now @@ -14357,7 +14359,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, if (!tbl->embedding && !tbl->on_expr && tbl->table) tbl->table->maybe_null= FALSE; tbl->join_list= table->join_list; - repl_list.push_back(tbl); + repl_list.push_back(tbl, join->thd->mem_root); tbl->dep_tables|= table->dep_tables; } li.replace(repl_list); @@ -15146,7 +15148,7 @@ Item_cond::remove_eq_conds(THD *thd, Item::cond_result *cond_value, Item_func::MULT_EQUAL_FUNC) { li.remove(); - new_equalities.push_back((Item_equal *) new_item); + new_equalities.push_back((Item_equal *) new_item, thd->mem_root); } else { @@ -19857,7 +19859,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, exclude_expensive_cond, retain_ref_cond); if (fix) - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } switch (new_cond->argument_list()->elements) { case 0: @@ -19893,7 +19895,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, retain_ref_cond); if (!fix) return (COND*) 0; // Always true - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } /* Call fix_fields to propagate all properties of the children to @@ -19984,7 +19986,7 @@ make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables, Item *fix=make_cond_after_sjm(thd, root_cond, item, tables, sjm_tables, inside_or_clause); if (fix) - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } switch (new_cond->argument_list()->elements) { case 0: @@ -20016,7 +20018,7 @@ make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables, /*inside_or_clause= */TRUE); if (!fix) return (COND*) 0; // Always true - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } /* Item_cond_or do not need fix_fields for execution, its parameters @@ -21773,7 +21775,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, return TRUE; /* Wrong field. */ uint el= all_fields.elements; - all_fields.push_front(order_item); /* Add new field to field list. */ + /* Add new field to field list. */ + all_fields.push_front(order_item, thd->mem_root); ref_pointer_array[el]= order_item; /* If the order_item is a SUM_FUNC_ITEM, when fix_fields is called @@ -21959,7 +21962,7 @@ setup_new_fields(THD *thd, List<Item> &fields, thd->where="procedure list"; if ((*new_field->item)->fix_fields(thd, new_field->item)) DBUG_RETURN(1); /* purecov: inspected */ - all_fields.push_front(*new_field->item); + all_fields.push_front(*new_field->item, thd->mem_root); new_field->item=all_fields.head_ref(); } } @@ -22033,7 +22036,7 @@ create_distinct_group(THD *thd, Item **ref_pointer_array, 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); + all_fields.push_front(new_item, thd->mem_root); ord->item= orig_ref_pointer_array + el; } else @@ -22464,7 +22467,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, copy_funcs (to see full test case look at having.test, BUG #4358) */ - if (param->copy_funcs.push_front(pos)) + if (param->copy_funcs.push_front(pos, thd->mem_root)) goto err; } else @@ -22512,10 +22515,10 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, goto err; if (i < border) // HAVING, ORDER and GROUP BY { - if (extra_funcs.push_back(pos)) + if (extra_funcs.push_back(pos, thd->mem_root)) goto err; } - else if (param->copy_funcs.push_back(pos)) + else if (param->copy_funcs.push_back(pos, thd->mem_root)) goto err; } res_all_fields.push_back(pos, thd->mem_root); @@ -22716,9 +22719,10 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, if (field != NULL) { /* - Replace "@:=<expression>" with "@:=<tmp table column>". Otherwise, we - would re-evaluate <expression>, and if expression were a subquery, this - would access already-unlocked tables. + Replace "@:=<expression>" with "@:=<tmp table + column>". Otherwise, we would re-evaluate <expression>, and + if expression were a subquery, this would access + already-unlocked tables. */ Item_func_set_user_var* suv= new (thd->mem_root) Item_func_set_user_var(thd, (Item_func_set_user_var*) item); @@ -22726,14 +22730,15 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, if (!suv || !new_field) DBUG_RETURN(true); // Fatal error /* - We are replacing the argument of Item_func_set_user_var after its value - has been read. The argument's null_value should be set by now, so we - must set it explicitly for the replacement argument since the null_value - may be read without any preceding call to val_*(). + We are replacing the argument of Item_func_set_user_var + after its value has been read. The argument's null_value + should be set by now, so we must set it explicitly for the + replacement argument since the null_value may be read + without any preceding call to val_*(). */ new_field->update_null_value(); List<Item> list; - list.push_back(new_field); + list.push_back(new_field, thd->mem_root); suv->set_arguments(list); item_field= suv; } @@ -22818,7 +22823,8 @@ change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array, uint i, border= all_fields.elements - elements; for (i= 0; (item= it++); i++) { - res_all_fields.push_back(new_item= item->get_tmp_table_item(thd)); + res_all_fields.push_back(new_item= item->get_tmp_table_item(thd), + thd->mem_root); ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]= new_item; } @@ -22996,7 +23002,10 @@ 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 (thd->mem_root) Item_func_equal(thd, new (thd->mem_root) Item_field(thd, field), value)); + cond->add(new (thd->mem_root) + Item_func_equal(thd, new (thd->mem_root) Item_field(thd, field), + value), + thd->mem_root); } if (thd->is_fatal_error) DBUG_RETURN(TRUE); @@ -23012,7 +23021,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) if (join_tab->select->pre_idx_push_select_cond) cond_copy= cond->copy_andor_structure(thd); if (join_tab->select->cond) - error=(int) cond->add(join_tab->select->cond); + error=(int) cond->add(join_tab->select->cond, thd->mem_root); join_tab->select->cond= cond; if (join_tab->select->pre_idx_push_select_cond) { @@ -23180,7 +23189,7 @@ bool JOIN::rollup_init() for (i= 0 ; i < send_group_parts; i++) { for (j=0 ; j < fields_list.elements ; j++) - rollup.fields[i].push_back(rollup.null_items[i]); + rollup.fields[i].push_back(rollup.null_items[i], thd->mem_root); } List_iterator<Item> it(all_fields); Item *item; @@ -23534,45 +23543,49 @@ int print_explain_message_line(select_result_sink *result, Item *item_null= new (mem_root) Item_null(thd); List<Item> item_list; - 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_int(thd, (int32) select_number), + mem_root); + item_list.push_back(new (mem_root) Item_string_sys(thd, select_type), + mem_root); /* `table` */ - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `partitions` */ if (options & DESCRIBE_PARTITIONS) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* type, possible_keys, key, key_len, ref */ for (uint i=0 ; i < 5; i++) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `rows` */ if (rows) { item_list.push_back(new (mem_root) Item_int(thd, *rows, - MY_INT64_NUM_DECIMAL_DIGITS)); + MY_INT64_NUM_DECIMAL_DIGITS), + mem_root); } else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `r_rows` */ if (is_analyze) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `filtered` */ if (is_analyze || options & DESCRIBE_EXTENDED) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `r_filtered` */ if (is_analyze) - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); /* `Extra` */ if (message) - item_list.push_back(new (mem_root) Item_string_sys(thd, message)); + item_list.push_back(new (mem_root) Item_string_sys(thd, message), + mem_root); else - item_list.push_back(item_null); + item_list.push_back(item_null, mem_root); if (result->send_data(item_list)) return 1; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d38fb3a0f19..f33d8c5778e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -454,12 +454,16 @@ bool mysqld_show_authors(THD *thd) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_show_authors"); - 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)); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Name", 40), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Location", 40), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", 512), + mem_root); if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) DBUG_RETURN(TRUE); show_table_authors_st *authors; @@ -489,12 +493,16 @@ bool mysqld_show_contributors(THD *thd) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_show_contributors"); - 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)); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Name", 40), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Location", 40), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", 512), + mem_root); if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) DBUG_RETURN(TRUE); show_table_contributors_st *contributors; @@ -567,12 +575,17 @@ bool mysqld_show_privileges(THD *thd) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_show_privileges"); - 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)); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Privilege", 10), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Context", 15), + mem_root); + field_list.push_back(new (mem_root) Item_empty_string(thd, "Comment", + NAME_CHAR_LEN), + mem_root); if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) DBUG_RETURN(TRUE); show_privileges_st *privilege= sys_privileges; @@ -1148,24 +1161,37 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (table_list->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 (mem_root) Item_empty_string(thd, "character_set_client", - 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 (mem_root) + Item_empty_string(thd, "View", NAME_CHAR_LEN), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Create View", + MY_MAX(buffer.length(),1024)), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "character_set_client", + MY_CS_NAME_SIZE), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "collation_connection", + MY_CS_NAME_SIZE), + mem_root); } else { - field_list.push_back(new (mem_root) Item_empty_string(thd, "Table", NAME_CHAR_LEN)); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Table", NAME_CHAR_LEN), + mem_root); // 1024 is for not to confuse old clients - field_list.push_back(new (mem_root) Item_empty_string(thd, "Create Table", - MY_MAX(buffer.length(),1024))); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Create Table", + MY_MAX(buffer.length(),1024)), + mem_root); } if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) goto exit; protocol->prepare_for_resend(); @@ -1254,11 +1280,16 @@ 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 (mem_root) Item_empty_string(thd, "Database", NAME_CHAR_LEN)); - field_list.push_back(new (mem_root) Item_empty_string(thd, "Create Database", 1024)); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Database", NAME_CHAR_LEN), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Create Database", 1024), + mem_root); if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) DBUG_RETURN(TRUE); protocol->prepare_for_resend(); @@ -1319,16 +1350,19 @@ 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 (mem_root) Item_ident_for_show(thd, field, - table_list->view_db.str, - table_list->view_name.str)); + field_list.push_back(new (mem_root) + Item_ident_for_show(thd, field, + table_list->view_db.str, + table_list->view_name.str), + mem_root); else - field_list.push_back(new (mem_root) Item_field(thd, field)); + field_list.push_back(new (mem_root) Item_field(thd, field), mem_root); } } restore_record(table, s->default_values); // Get empty record table->use_all_columns(); - if (thd->protocol->send_result_set_metadata(&field_list, Protocol::SEND_DEFAULTS)) + if (thd->protocol->send_result_set_metadata(&field_list, + Protocol::SEND_DEFAULTS)) DBUG_VOID_RETURN; my_eof(thd); DBUG_VOID_RETURN; @@ -2350,30 +2384,46 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_list_processes"); - 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 (mem_root) Item_empty_string(thd, "Host", - LIST_PROCESS_HOST_LEN)); - field_list.push_back(field=new (mem_root) Item_empty_string(thd, "db", NAME_CHAR_LEN)); + field_list.push_back(new (mem_root) + Item_int(thd, "Id", 0, MY_INT32_NUM_DECIMAL_DIGITS), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "User", + USERNAME_CHAR_LENGTH), + mem_root); + field_list.push_back(new (mem_root) + Item_empty_string(thd, "Host", + LIST_PROCESS_HOST_LEN), + mem_root); + field_list.push_back(field=new (mem_root) + Item_empty_string(thd, "db", NAME_CHAR_LEN), + mem_root); field->maybe_null=1; - 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_list.push_back(new (mem_root) Item_empty_string(thd, "Command", 16), + mem_root); + field_list.push_back(field= new (mem_root) + Item_return_int(thd, "Time", 7, MYSQL_TYPE_LONG), + mem_root); field->unsigned_flag= 0; - field_list.push_back(field=new (mem_root) Item_empty_string(thd, "State", 30)); + field_list.push_back(field=new (mem_root) + Item_empty_string(thd, "State", 30), + mem_root); field->maybe_null=1; - field_list.push_back(field=new (mem_root) Item_empty_string(thd, "Info", - max_query_length)); + field_list.push_back(field=new (mem_root) + Item_empty_string(thd, "Info", max_query_length), + mem_root); field->maybe_null=1; if (!thd->variables.old_mode && !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO)) { - field_list.push_back(field= new (mem_root) Item_float(thd, "Progress", 0.0, 3, 7)); + field_list.push_back(field= new (mem_root) + Item_float(thd, "Progress", 0.0, 3, 7), + mem_root); field->maybe_null= 0; } if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) DBUG_VOID_RETURN; if (thd->killed) @@ -2546,11 +2596,11 @@ int select_result_explain_buffer::send_data(List<Item> &items) DBUG_RETURN(MY_TEST(res)); } -bool select_result_text_buffer::send_result_set_metadata(List<Item> &fields, uint flag) +bool select_result_text_buffer::send_result_set_metadata(List<Item> &fields, + uint flag) { n_columns= fields.elements; return append_row(fields, true /*send item names */); - return send_data(fields); } @@ -2566,16 +2616,18 @@ int select_result_text_buffer::append_row(List<Item> &items, bool send_names) char **row; int column= 0; - if (!(row= (char**) thd->alloc(sizeof(char*) * n_columns))) + if (!(row= (char**) thd->alloc(sizeof(char*) * n_columns)) || + rows.push_back(row, thd->mem_root)) return true; - rows.push_back(row); while ((item= it++)) { DBUG_ASSERT(column < n_columns); StringBuffer<32> buf; const char *data_ptr; + char *ptr; size_t data_len; + if (send_names) { data_ptr= item->name; @@ -2597,8 +2649,8 @@ int select_result_text_buffer::append_row(List<Item> &items, bool send_names) } } - char *ptr= (char*)thd->alloc(data_len + 1); - memcpy(ptr, data_ptr, data_len + 1); + if (!(ptr= (char*) thd->memdup(data_ptr, data_len + 1))) + return true; row[column]= ptr; column++; @@ -3557,7 +3609,7 @@ COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table) { Item *fix= make_cond_for_info_schema(thd, item, table); if (fix) - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } switch (new_cond->argument_list()->elements) { case 0: @@ -3581,7 +3633,7 @@ COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table) Item *fix=make_cond_for_info_schema(thd, item, table); if (!fix) return (COND*) 0; - new_cond->argument_list()->push_back(fix); + new_cond->argument_list()->push_back(fix, thd->mem_root); } new_cond->quick_fix_field(); new_cond->top_level_item(); @@ -7422,7 +7474,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) strlen(fields_info->field_name), cs); break; } - field_list.push_back(item); + field_list.push_back(item, thd->mem_root); item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL); field_count++; } @@ -9171,9 +9223,11 @@ static bool show_create_trigger_impl(THD *thd, /* Send header. */ - 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)); + fields.push_back(new (mem_root) Item_empty_string(thd, "Trigger", NAME_LEN), + mem_root); + fields.push_back(new (mem_root) + Item_empty_string(thd, "sql_mode", trg_sql_mode_str.length), + mem_root); { /* @@ -9183,23 +9237,32 @@ static bool show_create_trigger_impl(THD *thd, Item_empty_string *stmt_fld= new (mem_root) Item_empty_string(thd, "SQL Original Statement", - MY_MAX(trg_sql_original_stmt.length, 1024)); + MY_MAX(trg_sql_original_stmt.length, + 1024)); stmt_fld->maybe_null= TRUE; - fields.push_back(stmt_fld); + fields.push_back(stmt_fld, mem_root); } - fields.push_back(new (mem_root) Item_empty_string(thd, "character_set_client", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "character_set_client", + MY_CS_NAME_SIZE), + mem_root); - fields.push_back(new (mem_root) Item_empty_string(thd, "collation_connection", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "collation_connection", + MY_CS_NAME_SIZE), + mem_root); - fields.push_back(new (mem_root) Item_empty_string(thd, "Database Collation", - MY_CS_NAME_SIZE)); + fields.push_back(new (mem_root) + Item_empty_string(thd, "Database Collation", + MY_CS_NAME_SIZE), + mem_root); - if (p->send_result_set_metadata(&fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + if (p->send_result_set_metadata(&fields, + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF)) return TRUE; /* Send data. */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0bf42a862f3..fbd40d848a2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5322,7 +5322,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, #ifdef WITH_PARTITION_STORAGE_ENGINE /* Partition info is not handled by mysql_prepare_alter_table() call. */ if (src_table->table->part_info) - thd->work_part_info= src_table->table->part_info->get_clone(); + thd->work_part_info= src_table->table->part_info->get_clone(thd); #endif /* @@ -5941,7 +5941,7 @@ remove_key: { // Adding the index into the drop list for replacing alter_info->flags |= Alter_info::ALTER_DROP_INDEX; - alter_info->drop_list.push_back(ad); + alter_info->drop_list.push_back(ad, thd->mem_root); } } } @@ -7390,7 +7390,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, Note that columns with AFTER clauses are added to the end of the list for now. Their positions will be corrected later. */ - new_create_list.push_back(def); + new_create_list.push_back(def, thd->mem_root); if (field->stored_in_db != def->stored_in_db) { my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN, MYF(0)); @@ -7414,8 +7414,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, This field was not dropped and not changed, add it to the list for the new table. */ - def= new Create_field(thd, field, field); - new_create_list.push_back(def); + def= new (thd->mem_root) Create_field(thd, field, field); + new_create_list.push_back(def, thd->mem_root); alter_it.rewind(); // Change default if ALTER Alter_column *alter; while ((alter=alter_it++)) @@ -7466,7 +7466,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, alter_ctx->error_if_not_empty= TRUE; } if (!def->after) - new_create_list.push_back(def); + new_create_list.push_back(def, thd->mem_root); else { Create_field *find; @@ -7494,7 +7494,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } if (def->after == first_keyword) - new_create_list.push_front(def); + new_create_list.push_front(def, thd->mem_root); else { find_it.rewind(); @@ -7633,7 +7633,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, key_part_length /= key_part->field->charset()->mbmaxlen; key_parts.push_back(new Key_part_spec(cfield->field_name, strlen(cfield->field_name), - key_part_length)); + key_part_length), + thd->mem_root); } if (table->s->tmp_table == NO_TMP_TABLE) { @@ -7683,7 +7684,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, &key_create_info, MY_TEST(key_info->flags & HA_GENERATED_KEY), key_parts, key_info->option_list, DDL_options()); - new_key_list.push_back(key); + new_key_list.push_back(key, thd->mem_root); } } { @@ -7693,7 +7694,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (key->type == Key::FOREIGN_KEY && ((Foreign_key *)key)->validate(new_create_list)) goto err; - new_key_list.push_back(key); + new_key_list.push_back(key, thd->mem_root); if (key->name.str && !my_strcasecmp(system_charset_info, key->name.str, primary_key_name)) { @@ -9626,11 +9627,14 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, */ DBUG_ASSERT(! thd->in_sub_stmt); - field_list.push_back(item= new (thd->mem_root) 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), + thd->mem_root); item->maybe_null= 1; - field_list.push_back(item= new (thd->mem_root) Item_int(thd, "Checksum", - (longlong) 1, - MY_INT64_NUM_DECIMAL_DIGITS)); + field_list.push_back(item= new (thd->mem_root) + Item_int(thd, "Checksum", (longlong) 1, + MY_INT64_NUM_DECIMAL_DIGITS), + thd->mem_root); item->maybe_null= 1; if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4f6371cc48f..0f17716974c 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1755,8 +1755,8 @@ int multi_update::prepare(List<Item> ¬_used_values, { Item *value= value_it++; uint offset= item->field->table->pos_in_table_list->shared; - fields_for_table[offset]->push_back(item); - values_for_table[offset]->push_back(value); + fields_for_table[offset]->push_back(item, thd->mem_root); + values_for_table[offset]->push_back(value, thd->mem_root); } if (thd->is_fatal_error) DBUG_RETURN(1); @@ -1982,7 +1982,7 @@ loop_end: if (!ifield) DBUG_RETURN(1); ifield->maybe_null= 0; - if (temp_fields.push_back(ifield)) + if (temp_fields.push_back(ifield, thd->mem_root)) DBUG_RETURN(1); } while ((tbl= tbl_it++)); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f66eda06199..e1b8bf0bb79 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1981,7 +1981,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view) { Item_field *fld; if ((fld= entry->item->field_for_view_update())) - list->push_back(fld); + list->push_back(fld, thd->mem_root); else { my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias, "INSERT"); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b9850f7da91..eaf82df9004 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -418,7 +418,7 @@ set_system_variable(THD *thd, struct sys_var_with_base *tmp, set_var(thd, var_type, tmp->var, &tmp->base_name, val))) return TRUE; - return lex->var_list.push_back(var); + return lex->var_list.push_back(var, thd->mem_root); } @@ -860,11 +860,15 @@ static void add_key_to_list(LEX *lex, LEX_STRING *field_name, enum Key::Keytype type, bool check_exists) { Key *key; - key= new Key(type, null_lex_str, HA_KEY_ALG_UNDEF, false, - DDL_options(check_exists ? DDL_options::OPT_IF_NOT_EXISTS : - DDL_options::OPT_NONE)); - key->columns.push_back(new Key_part_spec(*field_name, 0)); - lex->alter_info.key_list.push_back(key); + MEM_ROOT *mem_root= lex->thd->mem_root; + key= new (mem_root) + Key(type, null_lex_str, HA_KEY_ALG_UNDEF, false, + DDL_options(check_exists ? + DDL_options::OPT_IF_NOT_EXISTS : + DDL_options::OPT_NONE)); + key->columns.push_back(new (mem_root) Key_part_spec(*field_name, 0), + mem_root); + lex->alter_info.key_list.push_back(key, mem_root); } void LEX::init_last_field(Create_field *field, const char *field_name, @@ -2181,7 +2185,8 @@ execute_var_ident: { LEX *lex=Lex; LEX_STRING *lexstr= (LEX_STRING*)thd->memdup(&$2, sizeof(LEX_STRING)); - if (!lexstr || lex->prepared_stmt_params.push_back(lexstr)) + if (!lexstr || lex->prepared_stmt_params.push_back(lexstr, + thd->mem_root)) MYSQL_YYABORT; } ; @@ -2897,11 +2902,11 @@ opt_sp_cparams: sp_cparams: sp_cparams ',' expr { - Lex->value_list.push_back($3); + Lex->value_list.push_back($3, thd->mem_root); } | expr { - Lex->value_list.push_back($1); + Lex->value_list.push_back($1, thd->mem_root); } ; @@ -3520,12 +3525,12 @@ statement_information: statement_information_item { $$= new (thd->mem_root) List<Statement_information_item>; - if ($$ == NULL || $$->push_back($1)) + if ($$ == NULL || $$->push_back($1, thd->mem_root)) MYSQL_YYABORT; } | statement_information ',' statement_information_item { - if ($1->push_back($3)) + if ($1->push_back($3, thd->mem_root)) MYSQL_YYABORT; $$= $1; } @@ -3577,12 +3582,12 @@ condition_information: condition_information_item { $$= new (thd->mem_root) List<Condition_information_item>; - if ($$ == NULL || $$->push_back($1)) + if ($$ == NULL || $$->push_back($1, thd->mem_root)) MYSQL_YYABORT; } | condition_information ',' condition_information_item { - if ($1->push_back($3)) + if ($1->push_back($3, thd->mem_root)) MYSQL_YYABORT; $$= $1; } @@ -5009,7 +5014,7 @@ part_field_item: { partition_info *part_info= Lex->part_info; part_info->num_columns++; - if (part_info->part_field_list.push_back($1.str)) + if (part_info->part_field_list.push_back($1.str, thd->mem_root)) { mem_alloc_error(1); MYSQL_YYABORT; @@ -5094,7 +5099,7 @@ sub_part_field_item: ident { partition_info *part_info= Lex->part_info; - if (part_info->subpart_field_list.push_back($1.str)) + if (part_info->subpart_field_list.push_back($1.str, thd->mem_root)) { mem_alloc_error(1); MYSQL_YYABORT; @@ -5189,7 +5194,8 @@ part_definition: partition_info *part_info= Lex->part_info; partition_element *p_elem= new partition_element(); - if (!p_elem || part_info->partitions.push_back(p_elem)) + if (!p_elem || + part_info->partitions.push_back(p_elem, thd->mem_root)) { mem_alloc_error(sizeof(partition_element)); MYSQL_YYABORT; @@ -5289,11 +5295,11 @@ part_func_max: } else part_info->num_columns= 1U; - if (part_info->init_column_part()) + if (part_info->init_column_part(thd)) { MYSQL_YYABORT; } - if (part_info->add_max_value()) + if (part_info->add_max_value(thd)) { MYSQL_YYABORT; } @@ -5325,7 +5331,7 @@ part_values_in: we ADD or REORGANIZE partitions. Also can only happen for LIST partitions. */ - if (part_info->reorganize_into_single_field_col_val()) + if (part_info->reorganize_into_single_field_col_val(thd)) { MYSQL_YYABORT; } @@ -5355,7 +5361,7 @@ part_value_item: /* Initialisation code needed for each list of value expressions */ if (!(part_info->part_type == LIST_PARTITION && part_info->num_columns == 1U) && - part_info->init_column_part()) + part_info->init_column_part(thd)) { MYSQL_YYABORT; } @@ -5398,7 +5404,7 @@ part_value_expr_item: my_parse_error(ER_THD(thd, ER_MAXVALUE_IN_VALUES_IN)); MYSQL_YYABORT; } - if (part_info->add_max_value()) + if (part_info->add_max_value(thd)) { MYSQL_YYABORT; } @@ -5491,7 +5497,7 @@ sub_part_definition: MYSQL_YYABORT; } if (!sub_p_elem || - curr_part->subpartitions.push_back(sub_p_elem)) + curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root)) { mem_alloc_error(sizeof(partition_element)); MYSQL_YYABORT; @@ -6074,8 +6080,8 @@ key_def: handle_if_exists_options() expectes the two keys in this order: the Foreign_key, followed by its auto-generated Key. */ - lex->alter_info.key_list.push_back(key); - lex->alter_info.key_list.push_back(Lex->last_key); + lex->alter_info.key_list.push_back(key, thd->mem_root); + lex->alter_info.key_list.push_back(Lex->last_key, thd->mem_root); lex->option_list= NULL; /* Only used for ALTER TABLE. Ignored otherwise. */ @@ -6129,7 +6135,7 @@ field_spec: if (f->check(thd)) MYSQL_YYABORT; - lex->alter_info.create_list.push_back(f); + lex->alter_info.create_list.push_back(f, thd->mem_root); if (f->flags & PRI_KEY_FLAG) add_key_to_list(lex, &$1, Key::PRIMARY, Lex->check_exists); @@ -6837,7 +6843,7 @@ ref_list: Key_part_spec *key= new Key_part_spec($3, 0); if (key == NULL) MYSQL_YYABORT; - Lex->ref_list.push_back(key); + Lex->ref_list.push_back(key, thd->mem_root); } | ident { @@ -6846,7 +6852,7 @@ ref_list: MYSQL_YYABORT; LEX *lex= Lex; lex->ref_list.empty(); - lex->ref_list.push_back(key); + lex->ref_list.push_back(key, thd->mem_root); } ; @@ -7056,11 +7062,11 @@ btree_or_rtree: key_list: key_list ',' key_part order_dir { - Lex->last_key->columns.push_back($3); + Lex->last_key->columns.push_back($3, thd->mem_root); } | key_part order_dir { - Lex->last_key->columns.push_back($1); + Lex->last_key->columns.push_back($1, thd->mem_root); } ; @@ -7095,8 +7101,10 @@ opt_component: ; string_list: - text_string { Lex->last_field->interval_list.push_back($1); } - | string_list ',' text_string { Lex->last_field->interval_list.push_back($3); }; + text_string + { Lex->last_field->interval_list.push_back($1, thd->mem_root); } + | string_list ',' text_string + { Lex->last_field->interval_list.push_back($3, thd->mem_root); }; /* ** Alter table @@ -7548,7 +7556,8 @@ alt_part_name_list: alt_part_name_item: ident { - if (Lex->alter_info.partition_names.push_back($1.str)) + if (Lex->alter_info.partition_names.push_back($1.str, + thd->mem_root)) { mem_alloc_error(1); MYSQL_YYABORT; @@ -7608,7 +7617,7 @@ alter_list_item: Alter_drop *ad= new Alter_drop(Alter_drop::COLUMN, $4.str, $3); if (ad == NULL) MYSQL_YYABORT; - lex->alter_info.drop_list.push_back(ad); + lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= Alter_info::ALTER_DROP_COLUMN; } | DROP FOREIGN KEY_SYM opt_if_exists_table_element field_ident @@ -7617,7 +7626,7 @@ alter_list_item: Alter_drop *ad= new Alter_drop(Alter_drop::FOREIGN_KEY, $5.str, $4); if (ad == NULL) MYSQL_YYABORT; - lex->alter_info.drop_list.push_back(ad); + lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= Alter_info::DROP_FOREIGN_KEY; } | DROP PRIMARY_SYM KEY_SYM @@ -7627,7 +7636,7 @@ alter_list_item: FALSE); if (ad == NULL) MYSQL_YYABORT; - lex->alter_info.drop_list.push_back(ad); + lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX; } | DROP key_or_index opt_if_exists_table_element field_ident @@ -7636,7 +7645,7 @@ alter_list_item: Alter_drop *ad= new Alter_drop(Alter_drop::KEY, $4.str, $3); if (ad == NULL) MYSQL_YYABORT; - lex->alter_info.drop_list.push_back(ad); + lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= Alter_info::ALTER_DROP_INDEX; } | DISABLE_SYM KEYS @@ -7657,7 +7666,7 @@ alter_list_item: Alter_column *ac= new Alter_column($3.str,$6); if (ac == NULL) MYSQL_YYABORT; - lex->alter_info.alter_list.push_back(ac); + lex->alter_info.alter_list.push_back(ac, thd->mem_root); lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN_DEFAULT; } | ALTER opt_column field_ident DROP DEFAULT @@ -7666,7 +7675,7 @@ alter_list_item: Alter_column *ac= new Alter_column($3.str, (Item*) 0); if (ac == NULL) MYSQL_YYABORT; - lex->alter_info.alter_list.push_back(ac); + lex->alter_info.alter_list.push_back(ac, thd->mem_root); lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN_DEFAULT; } | RENAME opt_to table_ident @@ -8099,12 +8108,12 @@ table_column_list: | ident { Lex->column_list->push_back((LEX_STRING*) - thd->memdup(&$1, sizeof(LEX_STRING))); + thd->memdup(&$1, sizeof(LEX_STRING)), thd->mem_root); } | table_column_list ',' ident { Lex->column_list->push_back((LEX_STRING*) - thd->memdup(&$3, sizeof(LEX_STRING))); + thd->memdup(&$3, sizeof(LEX_STRING)), thd->mem_root); } ; @@ -8118,15 +8127,17 @@ table_index_list: table_index_name: ident { - Lex->index_list->push_back( - (LEX_STRING*) thd->memdup(&$1, sizeof(LEX_STRING))); + Lex->index_list->push_back((LEX_STRING*) + thd->memdup(&$1, sizeof(LEX_STRING)), + thd->mem_root); } | PRIMARY_SYM { LEX_STRING str= {(char*) "PRIMARY", 7}; - Lex->index_list->push_back( - (LEX_STRING*) thd->memdup(&str, sizeof(LEX_STRING))); + Lex->index_list->push_back((LEX_STRING*) + thd->memdup(&str, sizeof(LEX_STRING)), + thd->mem_root); } ; @@ -8235,12 +8246,14 @@ rename: rename_list: user TO_SYM user { - if (Lex->users_list.push_back($1) || Lex->users_list.push_back($3)) + if (Lex->users_list.push_back($1, thd->mem_root) || + Lex->users_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } | rename_list ',' user TO_SYM user { - if (Lex->users_list.push_back($3) || Lex->users_list.push_back($5)) + if (Lex->users_list.push_back($3, thd->mem_root) || + Lex->users_list.push_back($5, thd->mem_root)) MYSQL_YYABORT; } ; @@ -8692,7 +8705,7 @@ expr: /* (X1 OR X2) OR Y ==> OR (X1, X2, Y) */ - item1->add($3); + item1->add($3, thd->mem_root); $$ = $1; } } @@ -8702,7 +8715,7 @@ expr: /* X OR (Y1 OR Y2) ==> OR (X, Y1, Y2) */ - item3->add_at_head($1); + item3->add_at_head($1, thd->mem_root); $$ = $3; } else @@ -8742,7 +8755,7 @@ expr: /* (X1 AND X2) AND Y ==> AND (X1, X2, Y) */ - item1->add($3); + item1->add($3, thd->mem_root); $$ = $1; } } @@ -8752,7 +8765,7 @@ expr: /* X AND (Y1 AND Y2) ==> AND (X, Y1, Y2) */ - item3->add_at_head($1); + item3->add_at_head($1, thd->mem_root); $$ = $3; } else @@ -8866,8 +8879,8 @@ predicate: } | bit_expr IN_SYM '(' expr ',' expr_list ')' { - $6->push_front($4); - $6->push_front($1); + $6->push_front($4, thd->mem_root); + $6->push_front($1, thd->mem_root); $$= new (thd->mem_root) Item_func_in(thd, *$6); if ($$ == NULL) MYSQL_YYABORT; @@ -8880,8 +8893,8 @@ predicate: } | bit_expr not IN_SYM '(' expr ',' expr_list ')' { - $7->push_front($5); - $7->push_front($1); + $7->push_front($5, thd->mem_root); + $7->push_front($1, thd->mem_root); Item_func_in *item= new (thd->mem_root) Item_func_in(thd, *$7); if (item == NULL) MYSQL_YYABORT; @@ -9190,11 +9203,11 @@ dyncall_create_list: $$= new (thd->mem_root) List<DYNCALL_CREATE_DEF>; if ($$ == NULL) MYSQL_YYABORT; - $$->push_back($1); + $$->push_back($1, thd->mem_root); } | dyncall_create_list ',' dyncall_create_element { - $1->push_back($3); + $1->push_back($3, thd->mem_root); $$= $1; } ; @@ -9258,14 +9271,14 @@ simple_expr: { $$= $2; } | '(' expr ',' expr_list ')' { - $4->push_front($2); + $4->push_front($2, thd->mem_root); $$= new (thd->mem_root) Item_row(thd, *$4); if ($$ == NULL) MYSQL_YYABORT; } | ROW_SYM '(' expr ',' expr_list ')' { - $5->push_front($3); + $5->push_front($3, thd->mem_root); $$= new (thd->mem_root) Item_row(thd, *$5); if ($$ == NULL) MYSQL_YYABORT; @@ -9302,12 +9315,12 @@ simple_expr: } | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')' { - $2->push_front($5); + $2->push_front($5, thd->mem_root); Item_func_match *i1= new (thd->mem_root) Item_func_match(thd, *$2, $6); if (i1 == NULL) MYSQL_YYABORT; - Select->add_ftfunc_to_list(i1); + Select->add_ftfunc_to_list(thd, i1); $$= i1; } | BINARY simple_expr %prec NEG @@ -9440,8 +9453,8 @@ function_call_keyword: List<Item> *list= new (thd->mem_root) List<Item>; if (list == NULL) MYSQL_YYABORT; - list->push_front($5); - list->push_front($3); + list->push_front($5, thd->mem_root); + list->push_front($3, thd->mem_root); Item_row *item= new (thd->mem_root) Item_row(thd, *list); if (item == NULL) MYSQL_YYABORT; @@ -9451,8 +9464,8 @@ function_call_keyword: } | INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM { - $7->push_front($5); - $7->push_front($3); + $7->push_front($5, thd->mem_root); + $7->push_front($3, thd->mem_root); Item_row *item= new (thd->mem_root) Item_row(thd, *$7); if (item == NULL) MYSQL_YYABORT; @@ -10180,11 +10193,11 @@ udf_expr_list: $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; - $$->push_back($1); + $$->push_back($1, thd->mem_root); } | udf_expr_list ',' udf_expr { - $1->push_back($3); + $1->push_back($3, thd->mem_root); $$= $1; } ; @@ -10379,7 +10392,7 @@ variable_aux: MYSQL_YYABORT; LEX *lex= Lex; lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - lex->set_var_list.push_back(item); + lex->set_var_list.push_back(item, thd->mem_root); } | ident_or_text { @@ -10512,11 +10525,11 @@ expr_list: $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; - $$->push_back($1); + $$->push_back($1, thd->mem_root); } | expr_list ',' expr { - $1->push_back($3); + $1->push_back($3, thd->mem_root); $$= $1; } ; @@ -10532,11 +10545,11 @@ ident_list: $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; - $$->push_back($1); + $$->push_back($1, thd->mem_root); } | ident_list ',' simple_ident { - $1->push_back($3); + $1->push_back($3, thd->mem_root); $$= $1; } ; @@ -10557,13 +10570,13 @@ when_list: $$= new List<Item>; if ($$ == NULL) MYSQL_YYABORT; - $$->push_back($2); - $$->push_back($4); + $$->push_back($2, thd->mem_root); + $$->push_back($4, thd->mem_root); } | when_list WHEN_SYM expr THEN_SYM expr { - $1->push_back($3); - $1->push_back($5); + $1->push_back($3, thd->mem_root); + $1->push_back($5, thd->mem_root); $$= $1; } ; @@ -11121,7 +11134,7 @@ using_list: system_charset_info); if (s == NULL) MYSQL_YYABORT; - $$->push_back(s); + $$->push_back(s, thd->mem_root); } | using_list ',' ident { @@ -11130,7 +11143,7 @@ using_list: system_charset_info); if (s == NULL) MYSQL_YYABORT; - $1->push_back(s); + $1->push_back(s, thd->mem_root); $$= $1; } ; @@ -11681,7 +11694,7 @@ select_var_ident: select_outvar { if ($1 == NULL) MYSQL_YYABORT; - ((select_dumpvar *)Lex->result)->var_list.push_back($1); + ((select_dumpvar *)Lex->result)->var_list.push_back($1, thd->mem_root); } else { @@ -11798,7 +11811,7 @@ drop: lex->sql_command= SQLCOM_DROP_INDEX; lex->alter_info.reset(); lex->alter_info.flags= Alter_info::ALTER_DROP_INDEX; - lex->alter_info.drop_list.push_back(ad); + lex->alter_info.drop_list.push_back(ad, thd->mem_root); if (!lex->current_select->add_table_to_list(lex->thd, $6, NULL, TL_OPTION_UPDATING, TL_READ_NO_INSERT, @@ -12074,16 +12087,17 @@ insert_field_spec: | SET { LEX *lex=Lex; - if (!(lex->insert_list= new List_item) || - lex->many_values.push_back(lex->insert_list)) + if (!(lex->insert_list= new (thd->mem_root) List_item) || + lex->many_values.push_back(lex->insert_list, thd->mem_root)) MYSQL_YYABORT; } ident_eq_list ; fields: - fields ',' insert_ident { Lex->field_list.push_back($3); } - | insert_ident { Lex->field_list.push_back($1); } + fields ',' insert_ident + { Lex->field_list.push_back($3, thd->mem_root); } + | insert_ident { Lex->field_list.push_back($1, thd->mem_root); } ; insert_values: @@ -12111,8 +12125,8 @@ ident_eq_value: simple_ident_nospvar equal expr_or_default { LEX *lex=Lex; - if (lex->field_list.push_back($1) || - lex->insert_list->push_back($3)) + if (lex->field_list.push_back($1, thd->mem_root) || + lex->insert_list->push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -12130,13 +12144,13 @@ opt_equal: no_braces: '(' { - if (!(Lex->insert_list= new List_item)) + if (!(Lex->insert_list= new (thd->mem_root) List_item)) MYSQL_YYABORT; } opt_values ')' { LEX *lex=Lex; - if (lex->many_values.push_back(lex->insert_list)) + if (lex->many_values.push_back(lex->insert_list, thd->mem_root)) MYSQL_YYABORT; } ; @@ -12149,12 +12163,12 @@ opt_values: values: values ',' expr_or_default { - if (Lex->insert_list->push_back($3)) + if (Lex->insert_list->push_back($3, thd->mem_root)) MYSQL_YYABORT; } | expr_or_default { - if (Lex->insert_list->push_back($1)) + if (Lex->insert_list->push_back($1, thd->mem_root)) MYSQL_YYABORT; } ; @@ -12230,8 +12244,8 @@ insert_update_elem: simple_ident_nospvar equal expr_or_default { LEX *lex= Lex; - if (lex->update_list.push_back($1) || - lex->value_list.push_back($3)) + if (lex->update_list.push_back($1, thd->mem_root) || + lex->value_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -13037,8 +13051,9 @@ flush_option: my_parse_error(ER_THD(thd, ER_SYNTAX_ERROR), $2); MYSQL_YYABORT; } - Lex->view_list.push_back( - (LEX_STRING*)thd->memdup(&$1, sizeof(LEX_STRING))); + Lex->view_list.push_back((LEX_STRING*) + thd->memdup(&$1, sizeof(LEX_STRING)), + thd->mem_root); } ; @@ -13116,7 +13131,7 @@ purge_option: { LEX *lex= Lex; lex->value_list.empty(); - lex->value_list.push_front($2); + lex->value_list.push_front($2, thd->mem_root); lex->sql_command= SQLCOM_PURGE_BEFORE; } ; @@ -13157,11 +13172,11 @@ kill_option: kill_expr: expr { - Lex->value_list.push_front($$); + Lex->value_list.push_front($$, thd->mem_root); } | USER user { - Lex->users_list.push_back($2); + Lex->users_list.push_back($2, thd->mem_root); Lex->kill_type= KILL_TYPE_USER; } ; @@ -13338,9 +13353,9 @@ opt_field_or_var_spec: fields_or_vars: fields_or_vars ',' field_or_var - { Lex->field_list.push_back($3); } + { Lex->field_list.push_back($3, thd->mem_root); } | field_or_var - { Lex->field_list.push_back($1); } + { Lex->field_list.push_back($1, thd->mem_root); } ; field_or_var: @@ -13367,8 +13382,8 @@ load_data_set_elem: simple_ident_nospvar equal remember_name expr_or_default remember_end { LEX *lex= Lex; - if (lex->update_list.push_back($1) || - lex->value_list.push_back($4)) + if (lex->update_list.push_back($1, thd->mem_root) || + lex->value_list.push_back($4, thd->mem_root)) MYSQL_YYABORT; $4->set_name_no_truncate($3, (uint) ($5 - $3), thd->charset()); } @@ -13504,7 +13519,7 @@ param_marker: : thd->query(); item= new (thd->mem_root) Item_param(thd, lip->get_tok_start() - query_start); - if (!($$= item) || lex->param_list.push_back(item)) + if (!($$= item) || lex->param_list.push_back(item, thd->mem_root)) { my_message(ER_OUT_OF_RESOURCES, ER_THD(thd, ER_OUT_OF_RESOURCES), MYF(0)); MYSQL_YYABORT; @@ -14741,7 +14756,7 @@ option_value_no_option_type: set_var_user *var= new set_var_user(item); if (var == NULL) MYSQL_YYABORT; - Lex->var_list.push_back(var); + Lex->var_list.push_back(var, thd->mem_root); } | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default { @@ -14766,7 +14781,7 @@ option_value_no_option_type: cs2); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); } | NAMES_SYM equal expr { @@ -14800,7 +14815,7 @@ option_value_no_option_type: var= new set_var_collation_client(cs3, cs3, cs3); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); } | DEFAULT ROLE_SYM grant_role { @@ -14813,7 +14828,7 @@ option_value_no_option_type: $3->user); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); thd->lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -14824,7 +14839,7 @@ option_value_no_option_type: set_var_default_role *var= new set_var_default_role($5, $3->user); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); thd->lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -14835,7 +14850,7 @@ option_value_no_option_type: set_var_role *var= new set_var_role($2); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); } | PASSWORD_SYM opt_for_user text_or_password { @@ -14843,7 +14858,7 @@ option_value_no_option_type: set_var_password *var= new set_var_password(lex->definer); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -14954,7 +14969,7 @@ transaction_access_mode: item); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); } ; @@ -14971,7 +14986,7 @@ isolation_level: item); if (var == NULL) MYSQL_YYABORT; - lex->var_list.push_back(var); + lex->var_list.push_back(var, thd->mem_root); } ; @@ -15261,7 +15276,7 @@ revoke_command: | admin_option_for_role FROM user_and_role_list { Lex->sql_command= SQLCOM_REVOKE_ROLE; - if (Lex->users_list.push_front($1)) + if (Lex->users_list.push_front($1, thd->mem_root)) MYSQL_YYABORT; } ; @@ -15322,7 +15337,7 @@ grant_command: LEX *lex= Lex; lex->sql_command= SQLCOM_GRANT_ROLE; /* The first role is the one that is granted */ - if (Lex->users_list.push_front($1)) + if (Lex->users_list.push_front($1, thd->mem_root)) MYSQL_YYABORT; } @@ -15339,12 +15354,12 @@ opt_with_admin_option: role_list: grant_role { - if (Lex->users_list.push_back($1)) + if (Lex->users_list.push_back($1, thd->mem_root)) MYSQL_YYABORT; } | role_list ',' grant_role { - if (Lex->users_list.push_back($3)) + if (Lex->users_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -15549,12 +15564,12 @@ grant_ident: user_list: user { - if (Lex->users_list.push_back($1)) + if (Lex->users_list.push_back($1, thd->mem_root)) MYSQL_YYABORT; } | user_list ',' user { - if (Lex->users_list.push_back($3)) + if (Lex->users_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -15562,12 +15577,12 @@ user_list: grant_list: grant_user { - if (Lex->users_list.push_back($1)) + if (Lex->users_list.push_back($1, thd->mem_root)) MYSQL_YYABORT; } | grant_list ',' grant_user { - if (Lex->users_list.push_back($3)) + if (Lex->users_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -15575,12 +15590,12 @@ grant_list: user_and_role_list: user_or_role { - if (Lex->users_list.push_back($1)) + if (Lex->users_list.push_back($1, thd->mem_root)) MYSQL_YYABORT; } | user_and_role_list ',' user_or_role { - if (Lex->users_list.push_back($3)) + if (Lex->users_list.push_back($3, thd->mem_root)) MYSQL_YYABORT; } ; @@ -15653,7 +15668,7 @@ column_list_id: LEX_COLUMN *col= new LEX_COLUMN (*new_str,lex->which_columns); if (col == NULL) MYSQL_YYABORT; - lex->columns.push_back(col); + lex->columns.push_back(col, thd->mem_root); } } ; @@ -16128,15 +16143,17 @@ view_list_opt: view_list: ident - { - Lex->view_list.push_back((LEX_STRING*) - thd->memdup(&$1, sizeof(LEX_STRING))); - } + { + Lex->view_list.push_back((LEX_STRING*) + thd->memdup(&$1, sizeof(LEX_STRING)), + thd->mem_root); + } | view_list ',' ident - { - Lex->view_list.push_back((LEX_STRING*) - thd->memdup(&$3, sizeof(LEX_STRING))); - } + { + Lex->view_list.push_back((LEX_STRING*) + thd->memdup(&$3, sizeof(LEX_STRING)), + thd->mem_root); + } ; view_select: diff --git a/sql/table.cc b/sql/table.cc index f768cf93061..33b74ccb1a5 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5354,9 +5354,10 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, { DBUG_RETURN(field); } - Item *item= new (thd->mem_root) Item_direct_view_ref(thd, &view->view->select_lex.context, - field_ref, view->alias, - name, view); + Item *item= (new (thd->mem_root) + Item_direct_view_ref(thd, &view->view->select_lex.context, + field_ref, view->alias, + name, view)); /* Force creation of nullable item for the result tmp table for outer joined views/derived tables. @@ -5364,7 +5365,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, if (view->table && view->table->maybe_null) item->maybe_null= TRUE; /* Save item in case we will need to fall back to materialization. */ - view->used_items.push_front(item); + view->used_items.push_front(item, thd->mem_root); DBUG_RETURN(item); } |