Commit 360176f3 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-7943 - pthread_getspecific() takes 0.76% in OLTP RO

Pass THD to Item_field (and all derivatives) constructors.
This reduces number of pthread_getspecific() calls from 322 to 292.
parent b85e5efc
......@@ -105,7 +105,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
for (; filter->str; filter++)
{
Item_field *fld= new Item_field(&nrc, db, table, field);
Item_field *fld= new Item_field(thd, &nrc, db, table, field);
Item_string *pattern= new Item_string(filter->str, filter->length, cs);
Item_string *escape= new Item_string("\\", 1, cs);
......
......@@ -2180,14 +2180,14 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
}
Item_field::Item_field(Name_resolution_context *context_arg,
Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
const char *field_name_arg)
:Item_ident(context_arg, db_arg,table_name_arg,field_name_arg),
field(0), item_equal(0), no_const_subst(0),
have_privileges(0), any_privileges(0)
{
SELECT_LEX *select= current_thd->lex->current_select;
SELECT_LEX *select= thd->lex->current_select;
collation.set(DERIVATION_IMPLICIT);
if (select && select->parsing_place != IN_HAVING)
select->select_n_where_fields++;
......
......@@ -2275,7 +2275,7 @@ public:
uint have_privileges;
/* field need any privileges (for VIEW creation) */
bool any_privileges;
Item_field(Name_resolution_context *context_arg,
Item_field(THD *thd, Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
const char *field_name_arg);
/*
......@@ -4510,12 +4510,12 @@ class Item_default_value : public Item_field
{
public:
Item *arg;
Item_default_value(Name_resolution_context *context_arg)
:Item_field(context_arg, (const char *)NULL, (const char *)NULL,
Item_default_value(THD *thd, Name_resolution_context *context_arg)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL),
arg(NULL) {}
Item_default_value(Name_resolution_context *context_arg, Item *a)
:Item_field(context_arg, (const char *)NULL, (const char *)NULL,
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL),
arg(a) {}
enum Type type() const { return DEFAULT_VALUE_ITEM; }
......@@ -4548,8 +4548,8 @@ class Item_insert_value : public Item_field
{
public:
Item *arg;
Item_insert_value(Name_resolution_context *context_arg, Item *a)
:Item_field(context_arg, (const char *)NULL, (const char *)NULL,
Item_insert_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL),
arg(a) {}
bool eq(const Item *item, bool binary_cmp) const;
......@@ -4606,11 +4606,11 @@ public:
/* Pointer to Table_trigger_list object for table of this trigger */
Table_triggers_list *triggers;
Item_trigger_field(Name_resolution_context *context_arg,
Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
row_version_type row_ver_arg,
const char *field_name_arg,
ulong priv, const bool ro)
:Item_field(context_arg,
:Item_field(thd, context_arg,
(const char *)NULL, (const char *)NULL, field_name_arg),
row_version(row_ver_arg), field_idx((uint)-1), original_privilege(priv),
want_privilege(priv), table_grants(NULL), read_only (ro)
......
......@@ -5719,7 +5719,7 @@ 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 Item_field(context,
field_list.push_back(new Item_field(thd, context,
affected_db, table_name, field));
field+= field_lens[i] + 1;
}
......
......@@ -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(context,
Item_field *field= new 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,
......
......@@ -121,7 +121,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
continue;
field_info= &schema_table->fields_info[i];
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
......
......@@ -7443,7 +7443,7 @@ static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
if (field_info->old_name)
{
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
......@@ -7470,7 +7470,7 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
ST_FIELD_INFO *field_info= &schema_table->fields_info[1];
String buffer(tmp,sizeof(tmp), system_charset_info);
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (!field || add_item_to_list(thd, field))
return 1;
......@@ -7505,7 +7505,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
buffer.append(lex->wild->ptr());
buffer.append(')');
}
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
......@@ -7514,7 +7514,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
{
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
field_info= &schema_table->fields_info[3];
field= new Item_field(context, NullS, NullS, field_info->field_name);
field= new Item_field(thd, context, NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
field->set_name(field_info->old_name, strlen(field_info->old_name),
......@@ -7538,7 +7538,7 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
*field_num == 18 ||
*field_num == 19))
continue;
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
......@@ -7563,7 +7563,7 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
......@@ -7588,7 +7588,7 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
for (; *field_num >= 0; field_num++)
{
field_info= &schema_table->fields_info[*field_num];
Item_field *field= new Item_field(context,
Item_field *field= new Item_field(thd, context,
NullS, NullS, field_info->field_name);
if (field)
{
......
......@@ -481,7 +481,7 @@ set_trigger_new_row(THD *thd, LEX_STRING *name, Item *val)
lex->trg_chistics.event == TRG_EVENT_UPDATE));
trg_fld= new (thd->mem_root)
Item_trigger_field(lex->current_context(),
Item_trigger_field(thd, lex->current_context(),
Item_trigger_field::NEW_ROW,
name->str, UPDATE_ACL, FALSE);
......@@ -8567,7 +8567,7 @@ select_item_list:
| '*'
{
Item *item= new (thd->mem_root)
Item_field(&thd->lex->current_select->context,
Item_field(thd, &thd->lex->current_select->context,
NULL, NULL, "*");
if (item == NULL)
MYSQL_YYABORT;
......@@ -9341,14 +9341,14 @@ simple_expr:
my_error(ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str);
MYSQL_YYABORT;
}
$$= new (thd->mem_root) Item_default_value(Lex->current_context(),
$$= new (thd->mem_root) Item_default_value(thd, Lex->current_context(),
$3);
if ($$ == NULL)
MYSQL_YYABORT;
}
| VALUES '(' simple_ident_nospvar ')'
{
$$= new (thd->mem_root) Item_insert_value(Lex->current_context(),
$$= new (thd->mem_root) Item_insert_value(thd, Lex->current_context(),
$3);
if ($$ == NULL)
MYSQL_YYABORT;
......@@ -11610,7 +11610,7 @@ procedure_clause:
lex->proc_list.first=0;
lex->proc_list.next= &lex->proc_list.first;
Item_field *item= new (thd->mem_root)
Item_field(&lex->current_select->context,
Item_field(thd, &lex->current_select->context,
NULL, NULL, $2.str);
if (item == NULL)
MYSQL_YYABORT;
......@@ -12145,7 +12145,7 @@ expr_or_default:
expr { $$= $1;}
| DEFAULT
{
$$= new (thd->mem_root) Item_default_value(Lex->current_context());
$$= new (thd->mem_root) Item_default_value(thd, Lex->current_context());
if ($$ == NULL)
MYSQL_YYABORT;
}
......@@ -13635,7 +13635,7 @@ table_wild:
ident '.' '*'
{
SELECT_LEX *sel= Select;
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
NullS, $1.str, "*");
if ($$ == NULL)
MYSQL_YYABORT;
......@@ -13646,7 +13646,7 @@ table_wild:
SELECT_LEX *sel= Select;
const char* schema= thd->client_capabilities & CLIENT_NO_SCHEMA ?
NullS : $1.str;
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
schema,
$3.str,"*");
if ($$ == NULL)
......@@ -13694,7 +13694,7 @@ simple_ident:
if ((sel->parsing_place != IN_HAVING) ||
(sel->get_in_sum_expr() > 0))
{
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
NullS, NullS, $1.str);
}
else
......@@ -13716,7 +13716,7 @@ simple_ident_nospvar:
if ((sel->parsing_place != IN_HAVING) ||
(sel->get_in_sum_expr() > 0))
{
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
NullS, NullS, $1.str);
}
else
......@@ -13767,7 +13767,7 @@ simple_ident_q:
const bool read_only=
!(new_row && lex->trg_chistics.action_time == TRG_ACTION_BEFORE);
trg_fld= new (thd->mem_root)
Item_trigger_field(Lex->current_context(),
Item_trigger_field(thd, Lex->current_context(),
new_row ?
Item_trigger_field::NEW_ROW:
Item_trigger_field::OLD_ROW,
......@@ -13797,7 +13797,7 @@ simple_ident_q:
if ((sel->parsing_place != IN_HAVING) ||
(sel->get_in_sum_expr() > 0))
{
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
NullS, $1.str, $3.str);
}
else
......@@ -13821,7 +13821,7 @@ simple_ident_q:
if ((sel->parsing_place != IN_HAVING) ||
(sel->get_in_sum_expr() > 0))
{
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
NullS, $2.str, $4.str);
}
......@@ -13847,7 +13847,7 @@ simple_ident_q:
if ((sel->parsing_place != IN_HAVING) ||
(sel->get_in_sum_expr() > 0))
{
$$= new (thd->mem_root) Item_field(Lex->current_context(),
$$= new (thd->mem_root) Item_field(thd, Lex->current_context(),
schema,
$3.str, $5.str);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment