1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +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

@@ -2456,7 +2456,7 @@ int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is
void THD::make_explain_json_field_list(List<Item> &field_list, bool is_analyze)
{
Item *item= new Item_empty_string((is_analyze ?
Item *item= new Item_empty_string(this, (is_analyze ?
"ANALYZE" :
"EXPLAIN"),
78, system_charset_info);
@@ -2477,55 +2477,59 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
{
Item *item;
CHARSET_INFO *cs= system_charset_info;
field_list.push_back(item= new Item_return_int("id",3, MYSQL_TYPE_LONGLONG));
field_list.push_back(item= new Item_return_int(this, "id", 3,
MYSQL_TYPE_LONGLONG));
item->maybe_null= 1;
field_list.push_back(new Item_empty_string("select_type", 19, cs));
field_list.push_back(item= new Item_empty_string("table", NAME_CHAR_LEN, cs));
field_list.push_back(new Item_empty_string(this, "select_type", 19, cs));
field_list.push_back(item= new Item_empty_string(this, "table", NAME_CHAR_LEN,
cs));
item->maybe_null= 1;
if (explain_flags & DESCRIBE_PARTITIONS)
{
/* Maximum length of string that make_used_partitions_str() can produce */
item= new Item_empty_string("partitions", MAX_PARTITIONS * (1 + FN_LEN),
cs);
item= new Item_empty_string(this, "partitions",
MAX_PARTITIONS * (1 + FN_LEN), cs);
field_list.push_back(item);
item->maybe_null= 1;
}
field_list.push_back(item= new Item_empty_string("type", 10, cs));
field_list.push_back(item= new Item_empty_string(this, "type", 10, cs));
item->maybe_null= 1;
field_list.push_back(item=new Item_empty_string("possible_keys",
field_list.push_back(item=new Item_empty_string(this, "possible_keys",
NAME_CHAR_LEN*MAX_KEY, cs));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("key", NAME_CHAR_LEN, cs));
field_list.push_back(item=new Item_empty_string(this, "key", NAME_CHAR_LEN,
cs));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("key_len",
field_list.push_back(item=new Item_empty_string(this, "key_len",
NAME_CHAR_LEN*MAX_KEY));
item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("ref",
field_list.push_back(item=new Item_empty_string(this, "ref",
NAME_CHAR_LEN*MAX_REF_PARTS,
cs));
item->maybe_null=1;
field_list.push_back(item= new Item_return_int("rows", 10,
field_list.push_back(item= new Item_return_int(this, "rows", 10,
MYSQL_TYPE_LONGLONG));
if (is_analyze)
{
field_list.push_back(item= new Item_float("r_rows", 0.1234, 10, 4));
field_list.push_back(item= new Item_float(this, "r_rows", 0.1234, 10, 4));
item->maybe_null=1;
}
if (is_analyze || (explain_flags & DESCRIBE_EXTENDED))
{
field_list.push_back(item= new Item_float("filtered", 0.1234, 2, 4));
field_list.push_back(item= new Item_float(this, "filtered", 0.1234, 2, 4));
item->maybe_null=1;
}
if (is_analyze)
{
field_list.push_back(item= new Item_float("r_filtered", 0.1234, 2, 4));
field_list.push_back(item= new Item_float(this, "r_filtered", 0.1234, 2,
4));
item->maybe_null=1;
}
item->maybe_null= 1;
field_list.push_back(new Item_empty_string("Extra", 255, cs));
field_list.push_back(new Item_empty_string(this, "Extra", 255, cs));
}
@@ -3346,7 +3350,7 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
{
if (!cache)
{
cache= Item_cache::get_cache(val_item);
cache= Item_cache::get_cache(thd, val_item);
switch (val_item->result_type()) {
case REAL_RESULT:
op= &select_max_min_finder_subselect::cmp_real;
@@ -3803,7 +3807,7 @@ Statement_map::~Statement_map()
bool my_var_user::set(THD *thd, Item *item)
{
Item_func_set_user_var *suv= new Item_func_set_user_var(name, item);
Item_func_set_user_var *suv= new Item_func_set_user_var(thd, name, item);
suv->save_item_result(item);
return suv->fix_fields(thd, 0) || suv->update();
}