1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Stage 2 of MDEV-6152:

- Added mem_root to all calls to new Item
- Added private method operator new(size_t size) to Item to ensure that
  we always use a mem_root when creating an item.

This saves use once call to current_thd per Item creation
This commit is contained in:
Monty
2015-08-20 15:24:13 +03:00
committed by Sergey Vojtovich
parent 31e365efae
commit 1bae0d9e56
51 changed files with 1146 additions and 881 deletions

View File

@ -93,7 +93,7 @@ static bool init_fields(THD *thd, TABLE_LIST *tables,
for (; count-- ; find_fields++)
{
/* We have to use 'new' here as field will be re_linked on free */
Item_field *field= new Item_field(thd, context,
Item_field *field= new (thd->mem_root) Item_field(thd, context,
"mysql", find_fields->table_name,
find_fields->field_name);
if (!(find_fields->field= find_field_in_tables(thd, field, tables, NULL,
@ -450,11 +450,13 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
{
THD *thd= protocol->thd;
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_answer_1");
List<Item> field_list;
field_list.push_back(new Item_empty_string(thd, "name", 64));
field_list.push_back(new Item_empty_string(thd, "description", 1000));
field_list.push_back(new Item_empty_string(thd, "example", 1000));
field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
field_list.push_back(new (mem_root) Item_empty_string(thd, "description", 1000));
field_list.push_back(new (mem_root) Item_empty_string(thd, "example", 1000));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@ -494,13 +496,14 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
int send_header_2(Protocol *protocol, bool for_category)
{
THD *thd= protocol->thd;
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_header_2");
List<Item> field_list;
if (for_category)
field_list.push_back(new Item_empty_string(thd, "source_category_name",
field_list.push_back(new (mem_root) Item_empty_string(thd, "source_category_name",
64));
field_list.push_back(new Item_empty_string(thd, "name", 64));
field_list.push_back(new Item_empty_string(thd, "is_it_category", 1));
field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
field_list.push_back(new (mem_root) Item_empty_string(thd, "is_it_category", 1));
DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF));
}
@ -628,11 +631,15 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
TABLE_LIST *tables, TABLE *table,
Field *pfname, int *error)
{
Item *cond= new Item_func_like(thd, new Item_field(thd, pfname),
new Item_string(thd, mask, mlen,
pfname->charset()),
new Item_string_ascii(thd, "\\"),
FALSE);
MEM_ROOT *mem_root= thd->mem_root;
Item *cond= new (mem_root)
Item_func_like(thd,
new (mem_root)
Item_field(thd, pfname),
new (mem_root) Item_string(thd, mask, mlen,
pfname->charset()),
new (mem_root) Item_string_ascii(thd, "\\"),
FALSE);
if (thd->is_fatal_error)
return 0; // OOM
return prepare_simple_select(thd, cond, table, error);
@ -767,11 +774,17 @@ bool mysqld_help(THD *thd, const char *mask)
{
Field *topic_cat_id= used_fields[help_topic_help_category_id].field;
Item *cond_topic_by_cat=
new Item_func_equal(thd, new Item_field(thd, topic_cat_id),
new Item_int(thd, (int32) category_id));
new (mem_root)
Item_func_equal(thd,
new (mem_root)
Item_field(thd, topic_cat_id),
new (mem_root)
Item_int(thd, (int32) category_id));
Item *cond_cat_by_cat=
new Item_func_equal(thd, new Item_field(thd, cat_cat_id),
new Item_int(thd, (int32) category_id));
new (mem_root)
Item_func_equal(thd,
new (mem_root) Item_field(thd, cat_cat_id),
new (mem_root) Item_int(thd, (int32) category_id));
if (!(select= prepare_simple_select(thd, cond_topic_by_cat,
tables[0].table, &error)))
goto error;