summaryrefslogtreecommitdiff
path: root/sql/sql_help.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2015-08-20 15:24:13 +0300
committerSergey Vojtovich <svoj@mariadb.org>2015-08-21 10:40:51 +0400
commit1bae0d9e5669c2d03209082142e892417e24d09a (patch)
tree8702469bab1f515c78a06ede07ae4aeaa297c802 /sql/sql_help.cc
parent31e365efae28ba3208e80511c4d18fe11a79541a (diff)
downloadmariadb-git-1bae0d9e5669c2d03209082142e892417e24d09a.tar.gz
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
Diffstat (limited to 'sql/sql_help.cc')
-rw-r--r--sql/sql_help.cc45
1 files changed, 29 insertions, 16 deletions
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 0c74f3385eb..eb0e260c3f4 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -93,7 +93,7 @@ static bool init_fields(THD *thd, TABLE_LIST *tables,
for (; count-- ; find_fields++)
{
/* We have to use 'new' here as field will be re_linked on free */
- Item_field *field= new Item_field(thd, context,
+ Item_field *field= new (thd->mem_root) Item_field(thd, context,
"mysql", find_fields->table_name,
find_fields->field_name);
if (!(find_fields->field= find_field_in_tables(thd, field, tables, NULL,
@@ -450,11 +450,13 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname,
int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
{
THD *thd= protocol->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_answer_1");
+
List<Item> field_list;
- field_list.push_back(new Item_empty_string(thd, "name", 64));
- field_list.push_back(new Item_empty_string(thd, "description", 1000));
- field_list.push_back(new Item_empty_string(thd, "example", 1000));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "description", 1000));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "example", 1000));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -494,13 +496,14 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3)
int send_header_2(Protocol *protocol, bool for_category)
{
THD *thd= protocol->thd;
+ MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_header_2");
List<Item> field_list;
if (for_category)
- field_list.push_back(new Item_empty_string(thd, "source_category_name",
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "source_category_name",
64));
- field_list.push_back(new Item_empty_string(thd, "name", 64));
- field_list.push_back(new Item_empty_string(thd, "is_it_category", 1));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64));
+ field_list.push_back(new (mem_root) Item_empty_string(thd, "is_it_category", 1));
DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF));
}
@@ -628,11 +631,15 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen,
TABLE_LIST *tables, TABLE *table,
Field *pfname, int *error)
{
- Item *cond= new Item_func_like(thd, new Item_field(thd, pfname),
- new Item_string(thd, mask, mlen,
- pfname->charset()),
- new Item_string_ascii(thd, "\\"),
- FALSE);
+ MEM_ROOT *mem_root= thd->mem_root;
+ Item *cond= new (mem_root)
+ Item_func_like(thd,
+ new (mem_root)
+ Item_field(thd, pfname),
+ new (mem_root) Item_string(thd, mask, mlen,
+ pfname->charset()),
+ new (mem_root) Item_string_ascii(thd, "\\"),
+ FALSE);
if (thd->is_fatal_error)
return 0; // OOM
return prepare_simple_select(thd, cond, table, error);
@@ -767,11 +774,17 @@ bool mysqld_help(THD *thd, const char *mask)
{
Field *topic_cat_id= used_fields[help_topic_help_category_id].field;
Item *cond_topic_by_cat=
- new Item_func_equal(thd, new Item_field(thd, topic_cat_id),
- new Item_int(thd, (int32) category_id));
+ new (mem_root)
+ Item_func_equal(thd,
+ new (mem_root)
+ Item_field(thd, topic_cat_id),
+ new (mem_root)
+ Item_int(thd, (int32) category_id));
Item *cond_cat_by_cat=
- new Item_func_equal(thd, new Item_field(thd, cat_cat_id),
- new Item_int(thd, (int32) category_id));
+ new (mem_root)
+ Item_func_equal(thd,
+ new (mem_root) Item_field(thd, cat_cat_id),
+ new (mem_root) Item_int(thd, (int32) category_id));
if (!(select= prepare_simple_select(thd, cond_topic_by_cat,
tables[0].table, &error)))
goto error;