summaryrefslogtreecommitdiff
path: root/sql/item_create.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-04-04 12:16:12 +0300
committerMonty <monty@mariadb.org>2018-05-07 00:07:32 +0300
commit30ebc3ee9efcab635b1f3e14b9198a58ae93c233 (patch)
tree81e3ad66cd4ec8693964317cbf23515d0e9ecf35 /sql/item_create.cc
parenta22a339f8e044a1e8df011beb0b4c8f43792ac96 (diff)
downloadmariadb-git-30ebc3ee9efcab635b1f3e14b9198a58ae93c233.tar.gz
Add likely/unlikely to speed up execution
Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r--sql/item_create.cc92
1 files changed, 46 insertions, 46 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 8b8476bdc25..ab91e378be3 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -3313,7 +3313,7 @@ Create_qfunc::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
LEX_CSTRING db;
- if (! thd->db.str && ! thd->lex->sphead)
+ if (unlikely(! thd->db.str && ! thd->lex->sphead))
{
/*
The proper error message should be in the lines of:
@@ -3462,7 +3462,7 @@ Create_sp_func::create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
const Sp_handler *sph= &sp_handler_function;
Database_qualified_name pkgname(&null_clex_str, &null_clex_str);
- if (has_named_parameters(item_list))
+ if (unlikely(has_named_parameters(item_list)))
{
/*
The syntax "db.foo(expr AS p1, expr AS p2, ...) is invalid,
@@ -3481,8 +3481,8 @@ Create_sp_func::create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
arg_count= item_list->elements;
qname= new (thd->mem_root) sp_name(db, name, use_explicit_name);
- if (sph->sp_resolve_package_routine(thd, thd->lex->sphead,
- qname, &sph, &pkgname))
+ if (unlikely(sph->sp_resolve_package_routine(thd, thd->lex->sphead,
+ qname, &sph, &pkgname)))
return NULL;
sph->add_used_routine(lex, thd, qname);
if (pkgname.m_name.length)
@@ -3502,7 +3502,7 @@ Create_sp_func::create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
Item*
Create_native_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
- if (has_named_parameters(item_list))
+ if (unlikely(has_named_parameters(item_list)))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3520,7 +3520,7 @@ Create_func_arg0::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count != 0)
+ if (unlikely(arg_count != 0))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3538,7 +3538,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
if (item_list)
arg_count= item_list->elements;
- if (arg_count != 1)
+ if (unlikely(arg_count != 1))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3546,7 +3546,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop();
- if (! param_1->is_autogenerated_name)
+ if (unlikely(! param_1->is_autogenerated_name))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3564,7 +3564,7 @@ Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
if (item_list)
arg_count= item_list->elements;
- if (arg_count != 2)
+ if (unlikely(arg_count != 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3573,8 +3573,8 @@ Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
- if ( (! param_1->is_autogenerated_name)
- || (! param_2->is_autogenerated_name))
+ if (unlikely(!param_1->is_autogenerated_name ||
+ !param_2->is_autogenerated_name))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3592,7 +3592,7 @@ Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
if (item_list)
arg_count= item_list->elements;
- if (arg_count != 3)
+ if (unlikely(arg_count != 3))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3602,9 +3602,9 @@ Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_2= item_list->pop();
Item *param_3= item_list->pop();
- if ( (! param_1->is_autogenerated_name)
- || (! param_2->is_autogenerated_name)
- || (! param_3->is_autogenerated_name))
+ if (unlikely(!param_1->is_autogenerated_name ||
+ !param_2->is_autogenerated_name ||
+ !param_3->is_autogenerated_name))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3765,7 +3765,7 @@ Item*
Create_func_binlog_gtid_pos::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
#ifdef HAVE_REPLICATION
- if (!mysql_bin_log.is_open())
+ if (unlikely(!mysql_bin_log.is_open()))
#endif
{
my_error(ER_NO_BINARY_LOGGING, MYF(0));
@@ -3903,7 +3903,7 @@ Create_func_concat::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 1)
+ if (unlikely(arg_count < 1))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3926,7 +3926,7 @@ Create_func_concat_operator_oracle::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 1)
+ if (unlikely(arg_count < 1))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3950,7 +3950,7 @@ Create_func_decode_oracle::create_native(THD *thd, LEX_CSTRING *name,
List<Item> *item_list)
{
uint arg_count= item_list ? item_list->elements : 0;
- if (arg_count < 3)
+ if (unlikely(arg_count < 3))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -3970,7 +3970,7 @@ Create_func_concat_ws::create_native(THD *thd, LEX_CSTRING *name,
arg_count= item_list->elements;
/* "WS" stands for "With Separator": this function takes 2+ arguments */
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -4272,7 +4272,7 @@ Create_func_elt::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -4468,7 +4468,7 @@ Create_func_field::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -4841,7 +4841,7 @@ Create_func_greatest::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -5135,7 +5135,7 @@ Create_func_json_detailed::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/)
+ if (unlikely(arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5284,7 +5284,7 @@ Create_func_json_array_append::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
+ if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5310,7 +5310,7 @@ Create_func_json_array_insert::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
+ if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5336,7 +5336,7 @@ Create_func_json_insert::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
+ if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5363,7 +5363,7 @@ Create_func_json_set::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
+ if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5390,7 +5390,7 @@ Create_func_json_replace::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 || (arg_count & 1) == 0 /*is even*/)
+ if (unlikely(arg_count < 3 || (arg_count & 1) == 0 /*is even*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5417,7 +5417,7 @@ Create_func_json_remove::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2 /*json_doc, path [,path]*/)
+ if (unlikely(arg_count < 2 /*json_doc, path [,path]*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5443,7 +5443,7 @@ Create_func_json_object::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
{
arg_count= item_list->elements;
- if ((arg_count & 1) != 0 /*is odd*/)
+ if (unlikely((arg_count & 1) != 0 /*is odd*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
@@ -5473,8 +5473,8 @@ Create_func_json_length::create_native(THD *thd, LEX_CSTRING *name,
Item *func;
int arg_count;
- if (item_list == NULL ||
- (arg_count= item_list->elements) == 0)
+ if (unlikely(item_list == NULL ||
+ (arg_count= item_list->elements) == 0))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
@@ -5498,8 +5498,8 @@ Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name,
Item *func;
int arg_count;
- if (item_list == NULL ||
- (arg_count= item_list->elements) < 2) // json, json
+ if (unlikely(item_list == NULL ||
+ (arg_count= item_list->elements) < 2)) // json, json
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
func= NULL;
@@ -5526,7 +5526,7 @@ Create_func_json_contains::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count == 2 || arg_count == 3/* json_doc, val, [path] */)
+ if (unlikely(arg_count == 2 || arg_count == 3/* json_doc, val, [path] */))
{
func= new (thd->mem_root) Item_func_json_contains(thd, *item_list);
}
@@ -5552,7 +5552,7 @@ Create_func_json_keys::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/)
+ if (unlikely(arg_count < 1 || arg_count > 2 /* json_doc, [path]...*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5578,7 +5578,7 @@ Create_func_json_contains_path::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 /* json_doc, one_or_all, path, [path]...*/)
+ if (unlikely(arg_count < 3 /* json_doc, one_or_all, path, [path]...*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5604,7 +5604,7 @@ Create_func_json_extract::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2 /* json_doc, path, [path]...*/)
+ if (unlikely(arg_count < 2 /* json_doc, path, [path]...*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5630,7 +5630,7 @@ Create_func_json_search::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 3 /* json_doc, one_or_all, search_str, [escape_char[, path]...*/)
+ if (unlikely(arg_count < 3 /* json_doc, one_or_all, search_str, [escape_char[, path]...*/))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
}
@@ -5701,7 +5701,7 @@ Create_func_least::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -5979,7 +5979,7 @@ Create_func_make_set::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2)
+ if (unlikely(arg_count < 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -6004,7 +6004,7 @@ Create_func_master_pos_wait::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 2 || arg_count > 4)
+ if (unlikely(arg_count < 2 || arg_count > 4))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return func;
@@ -6054,7 +6054,7 @@ Create_func_master_gtid_wait::create_native(THD *thd, LEX_CSTRING *name,
if (item_list != NULL)
arg_count= item_list->elements;
- if (arg_count < 1 || arg_count > 2)
+ if (unlikely(arg_count < 1 || arg_count > 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return func;
@@ -7487,7 +7487,7 @@ Item *create_temporal_literal(THD *thd,
DBUG_ASSERT(0);
}
- if (item)
+ if (likely(item))
{
if (status.warnings) // e.g. a note on nanosecond truncation
{
@@ -7596,7 +7596,7 @@ Item *create_func_dyncol_get(THD *thd, Item *str, Item *num,
{
Item *res;
- if (!(res= new (thd->mem_root) Item_dyncol_get(thd, str, num)))
+ if (likely(!(res= new (thd->mem_root) Item_dyncol_get(thd, str, num))))
return res; // Return NULL
return handler->create_typecast_item(thd, res,
Type_cast_attributes(c_len, c_dec, cs));