diff options
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 118 |
1 files changed, 72 insertions, 46 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 901dfa06f40..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; @@ -5118,6 +5118,7 @@ Create_func_json_exists Create_func_json_exists::s_singleton; Item* Create_func_json_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_exists(thd, arg1, arg2); } @@ -5134,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); } @@ -5143,6 +5144,7 @@ Create_func_json_detailed::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_format(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5152,6 +5154,7 @@ Create_func_json_loose Create_func_json_loose::s_singleton; Item* Create_func_json_loose::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_format(thd, arg1, Item_func_json_format::LOOSE); } @@ -5162,6 +5165,7 @@ Create_func_json_compact Create_func_json_compact::s_singleton; Item* Create_func_json_compact::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_format(thd, arg1, Item_func_json_format::COMPACT); } @@ -5172,6 +5176,7 @@ Create_func_json_valid Create_func_json_valid::s_singleton; Item* Create_func_json_valid::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_valid(thd, arg1); } @@ -5181,6 +5186,7 @@ Create_func_json_type Create_func_json_type::s_singleton; Item* Create_func_json_type::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_type(thd, arg1); } @@ -5190,6 +5196,7 @@ Create_func_json_depth Create_func_json_depth::s_singleton; Item* Create_func_json_depth::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_depth(thd, arg1); } @@ -5199,6 +5206,7 @@ Create_func_json_value Create_func_json_value::s_singleton; Item* Create_func_json_value::create_2_arg(THD *thd, Item *arg1, Item *arg2) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_value(thd, arg1, arg2); } @@ -5208,6 +5216,7 @@ Create_func_json_query Create_func_json_query::s_singleton; Item* Create_func_json_query::create_2_arg(THD *thd, Item *arg1, Item *arg2) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_query(thd, arg1, arg2); } @@ -5217,6 +5226,7 @@ Create_func_json_quote Create_func_json_quote::s_singleton; Item* Create_func_json_quote::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_quote(thd, arg1); } @@ -5226,6 +5236,7 @@ Create_func_json_unquote Create_func_json_unquote::s_singleton; Item* Create_func_json_unquote::create_1_arg(THD *thd, Item *arg1) { + status_var_increment(current_thd->status_var.feature_json); return new (thd->mem_root) Item_func_json_unquote(thd, arg1); } @@ -5256,6 +5267,7 @@ Create_func_json_array::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_array(thd); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5272,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); } @@ -5281,6 +5293,7 @@ Create_func_json_array_append::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_array_append(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5297,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); } @@ -5306,6 +5319,7 @@ Create_func_json_array_insert::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_array_insert(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5322,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); } @@ -5332,6 +5346,7 @@ Create_func_json_insert::create_native(THD *thd, LEX_CSTRING *name, thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5348,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); } @@ -5358,6 +5373,7 @@ Create_func_json_set::create_native(THD *thd, LEX_CSTRING *name, thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5374,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); } @@ -5384,6 +5400,7 @@ Create_func_json_replace::create_native(THD *thd, LEX_CSTRING *name, thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5400,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); } @@ -5409,6 +5426,7 @@ Create_func_json_remove::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_remove(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5425,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; @@ -5441,6 +5459,7 @@ Create_func_json_object::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_object(thd); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5454,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; @@ -5465,6 +5484,7 @@ Create_func_json_length::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_length(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5478,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; @@ -5489,6 +5509,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_merge(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5505,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); } @@ -5514,6 +5535,7 @@ Create_func_json_contains::create_native(THD *thd, LEX_CSTRING *name, my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5530,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); } @@ -5539,6 +5561,7 @@ Create_func_json_keys::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_keys(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5555,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); } @@ -5564,6 +5587,7 @@ Create_func_json_contains_path::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_contains_path(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5580,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); } @@ -5589,6 +5613,7 @@ Create_func_json_extract::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_extract(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5605,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); } @@ -5614,6 +5639,7 @@ Create_func_json_search::create_native(THD *thd, LEX_CSTRING *name, func= new (thd->mem_root) Item_func_json_search(thd, *item_list); } + status_var_increment(current_thd->status_var.feature_json); return func; } @@ -5675,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; @@ -5953,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; @@ -5978,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; @@ -6028,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; @@ -7461,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 { @@ -7570,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)); |