1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)

Added mandatory thd parameter to Item (and all derivative classes) constructor.
Added thd parameter to all routines that may create items.
Also removed "current_thd" from Item::Item. This reduced number of
pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
This commit is contained in:
Sergey Vojtovich
2015-08-11 11:18:38 +04:00
parent 4374da63f0
commit 31e365efae
71 changed files with 2724 additions and 2474 deletions

View File

@ -449,11 +449,12 @@ 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;
DBUG_ENTER("send_answer_1");
List<Item> field_list;
field_list.push_back(new Item_empty_string("name",64));
field_list.push_back(new Item_empty_string("description",1000));
field_list.push_back(new Item_empty_string("example",1000));
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));
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@ -492,12 +493,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;
DBUG_ENTER("send_header_2");
List<Item> field_list;
if (for_category)
field_list.push_back(new Item_empty_string("source_category_name",64));
field_list.push_back(new Item_empty_string("name",64));
field_list.push_back(new Item_empty_string("is_it_category",1));
field_list.push_back(new 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));
DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF));
}
@ -625,9 +628,10 @@ 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(new Item_field(pfname),
new Item_string(mask,mlen,pfname->charset()),
new Item_string_ascii("\\"),
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);
if (thd->is_fatal_error)
return 0; // OOM
@ -763,11 +767,11 @@ 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(new Item_field(topic_cat_id),
new Item_int((int32)category_id));
new Item_func_equal(thd, new Item_field(thd, topic_cat_id),
new Item_int(thd, (int32) category_id));
Item *cond_cat_by_cat=
new Item_func_equal(new Item_field(cat_cat_id),
new Item_int((int32)category_id));
new Item_func_equal(thd, new Item_field(thd, cat_cat_id),
new Item_int(thd, (int32) category_id));
if (!(select= prepare_simple_select(thd, cond_topic_by_cat,
tables[0].table, &error)))
goto error;