diff options
author | Monty <monty@mariadb.org> | 2018-04-04 12:16:12 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-05-07 00:07:32 +0300 |
commit | 30ebc3ee9efcab635b1f3e14b9198a58ae93c233 (patch) | |
tree | 81e3ad66cd4ec8693964317cbf23515d0e9ecf35 /sql/sql_yacc.yy | |
parent | a22a339f8e044a1e8df011beb0b4c8f43792ac96 (diff) | |
download | mariadb-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/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 2385 |
1 files changed, 1228 insertions, 1157 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8789b218a8d..03d4d3b674f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -82,7 +82,7 @@ int yylex(void *yylval, void *yythd); #define yyoverflow(A,B,C,D,E,F) \ { \ size_t val= *(F); \ - if (my_yyoverflow((B), (D), &val)) \ + if (unlikely(my_yyoverflow((B), (D), &val))) \ { \ yyerror(thd, (char*) (A)); \ return 2; \ @@ -101,7 +101,7 @@ int yylex(void *yylval, void *yythd); } while (0) #define MYSQL_YYABORT_UNLESS(A) \ - if (!(A)) \ + if (unlikely(!(A))) \ { \ thd->parse_error(); \ MYSQL_YYABORT; \ @@ -342,14 +342,14 @@ bool LEX::set_trigger_new_row(const LEX_CSTRING *name, Item *val) Item_trigger_field::NEW_ROW, name, UPDATE_ACL, FALSE); - if (trg_fld == NULL) + if (unlikely(trg_fld == NULL)) return TRUE; sp_fld= new (thd->mem_root) sp_instr_set_trigger_field(sphead->instructions(), spcont, trg_fld, val, this); - if (sp_fld == NULL) + if (unlikely(sp_fld == NULL)) return TRUE; /* @@ -713,7 +713,7 @@ bool LEX::add_alter_list(const char *name, Virtual_column_info *expr, { MEM_ROOT *mem_root= thd->mem_root; Alter_column *ac= new (mem_root) Alter_column(name, expr, exists); - if (ac == NULL) + if (unlikely(ac == NULL)) return true; alter_info.alter_list.push_back(ac, mem_root); alter_info.flags|= ALTER_CHANGE_COLUMN_DEFAULT; @@ -756,7 +756,7 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin) #define bincmp_collation(X,Y) \ do \ { \ - if (Lex->set_bincmp(X,Y)) \ + if (unlikely(Lex->set_bincmp(X,Y))) \ MYSQL_YYABORT; \ } while(0) @@ -2099,8 +2099,8 @@ rule: <-- starts at col 1 query: END_OF_INPUT { - if (!thd->bootstrap && - (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) + if (likely(!thd->bootstrap) && + unlikely(!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) my_yyabort_error((ER_EMPTY_QUERY, MYF(0))); thd->lex->sql_command= SQLCOM_EMPTY_QUERY; @@ -2227,7 +2227,7 @@ prepare: PREPARE_SYM ident FROM prepare_src { LEX *lex= thd->lex; - if (lex->table_or_sp_used()) + if (unlikely(lex->table_or_sp_used())) my_yyabort_error((ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "PREPARE..FROM")); lex->sql_command= SQLCOM_PREPARE; @@ -2255,7 +2255,7 @@ execute: {} | EXECUTE_SYM IMMEDIATE_SYM prepare_src { - if (Lex->table_or_sp_used()) + if (unlikely(Lex->table_or_sp_used())) my_yyabort_error((ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "EXECUTE IMMEDIATE")); Lex->sql_command= SQLCOM_EXECUTE_IMMEDIATE; @@ -2269,7 +2269,7 @@ execute_using: | USING { Lex->expr_allows_subselect= false; } execute_var_list { - if (Lex->table_or_sp_used()) + if (unlikely(Lex->table_or_sp_used())) my_yyabort_error((ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "EXECUTE..USING")); Lex->expr_allows_subselect= true; @@ -2284,7 +2284,8 @@ execute_var_list: execute_var_ident: expr_or_default { - if (Lex->prepared_stmt_params.push_back($1, thd->mem_root)) + if (unlikely(Lex->prepared_stmt_params.push_back($1, + thd->mem_root))) MYSQL_YYABORT; } ; @@ -2294,7 +2295,7 @@ execute_var_ident: help: HELP_SYM { - if (Lex->sphead) + if (unlikely(Lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HELP")); } ident_or_text @@ -2394,20 +2395,21 @@ master_def: | MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal { Lex->mi.heartbeat_period= (float) $3->val_real(); - if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD || - Lex->mi.heartbeat_period < 0.0) + if (unlikely(Lex->mi.heartbeat_period > + SLAVE_MAX_HEARTBEAT_PERIOD) || + unlikely(Lex->mi.heartbeat_period < 0.0)) my_yyabort_error((ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE, MYF(0), SLAVE_MAX_HEARTBEAT_PERIOD)); - if (Lex->mi.heartbeat_period > slave_net_timeout) + if (unlikely(Lex->mi.heartbeat_period > slave_net_timeout)) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX, ER_THD(thd, ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX)); } - if (Lex->mi.heartbeat_period < 0.001) + if (unlikely(Lex->mi.heartbeat_period < 0.001)) { - if (Lex->mi.heartbeat_period != 0.0) + if (unlikely(Lex->mi.heartbeat_period != 0.0)) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN, @@ -2505,19 +2507,19 @@ master_file_def: } | MASTER_USE_GTID_SYM '=' CURRENT_POS_SYM { - if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) + if (unlikely(Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_CURRENT_POS; } | MASTER_USE_GTID_SYM '=' SLAVE_POS_SYM { - if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) + if (unlikely(Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_SLAVE_POS; } | MASTER_USE_GTID_SYM '=' NO_SYM { - if (Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED) + if (unlikely(Lex->mi.use_gtid_opt != LEX_MASTER_INFO::LEX_GTID_UNCHANGED)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MASTER_use_gtid")); Lex->mi.use_gtid_opt= LEX_MASTER_INFO::LEX_GTID_NO; } @@ -2537,7 +2539,7 @@ connection_name: { Lex->mi.connection_name= $1; #ifdef HAVE_REPLICATION - if (check_master_connection_name(&$1)) + if (unlikely(check_master_connection_name(&$1))) my_yyabort_error((ER_WRONG_ARGUMENTS, MYF(0), "MASTER_CONNECTION_NAME")); #endif } @@ -2550,11 +2552,13 @@ create: { LEX *lex= thd->lex; lex->create_info.init(); - if (lex->set_command_with_check(SQLCOM_CREATE_TABLE, $2, $1 | $4)) + if (unlikely(lex->set_command_with_check(SQLCOM_CREATE_TABLE, $2, + $1 | $4))) MYSQL_YYABORT; - if (!lex->select_lex.add_table_to_list(thd, $5, NULL, - TL_OPTION_UPDATING, - TL_WRITE, MDL_EXCLUSIVE)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $5, NULL, + TL_OPTION_UPDATING, + TL_WRITE, + MDL_EXCLUSIVE))) MYSQL_YYABORT; lex->alter_info.reset(); /* @@ -2586,12 +2590,14 @@ create: { LEX *lex= thd->lex; lex->create_info.init(); - if (lex->set_command_with_check(SQLCOM_CREATE_SEQUENCE, $2, $1 | $4)) + if (unlikely(lex->set_command_with_check(SQLCOM_CREATE_SEQUENCE, $2, + $1 | $4))) MYSQL_YYABORT; - if (!lex->select_lex.add_table_to_list(thd, $5, NULL, - TL_OPTION_UPDATING, - TL_WRITE, MDL_EXCLUSIVE)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $5, NULL, + TL_OPTION_UPDATING, + TL_WRITE, + MDL_EXCLUSIVE))) MYSQL_YYABORT; /* @@ -2603,15 +2609,15 @@ create: lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB; lex->name= null_clex_str; lex->create_last_non_select_table= lex->last_table(); - if (!(lex->create_info.seq_create_info= new (thd->mem_root) - sequence_definition())) + if (unlikely(!(lex->create_info.seq_create_info= + new (thd->mem_root) sequence_definition()))) MYSQL_YYABORT; } opt_sequence opt_create_table_options { LEX *lex= thd->lex; - if (lex->create_info.seq_create_info->check_and_adjust(1)) + if (unlikely(lex->create_info.seq_create_info->check_and_adjust(1))) { my_error(ER_SEQUENCE_INVALID_DATA, MYF(0), lex->select_lex.table_list.first->db.str, @@ -2620,7 +2626,8 @@ create: } /* No fields specified, generate them */ - if (prepare_sequence_fields(thd, &lex->alter_info.create_list)) + if (unlikely(prepare_sequence_fields(thd, + &lex->alter_info.create_list))) MYSQL_YYABORT; /* CREATE SEQUENCE always creates a sequence */ @@ -2628,8 +2635,9 @@ create: Lex->create_info.sequence= 1; lex->current_select= &lex->select_lex; - if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) && - !lex->create_info.db_type) + if (unlikely((lex->create_info.used_fields & + HA_CREATE_USED_ENGINE) && + !lex->create_info.db_type)) { lex->create_info.use_default_db_type(thd); push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, @@ -2644,9 +2652,9 @@ create: opt_key_algorithm_clause ON table_ident { - if (Lex->add_create_index_prepare($8)) + if (unlikely(Lex->add_create_index_prepare($8))) MYSQL_YYABORT; - if (Lex->add_create_index($2, &$5, $6, $1 | $4)) + if (unlikely(Lex->add_create_index($2, &$5, $6, $1 | $4))) MYSQL_YYABORT; } '(' key_list ')' opt_lock_wait_timeout normal_key_options @@ -2654,9 +2662,10 @@ create: | create_or_replace fulltext INDEX_SYM opt_if_not_exists ident ON table_ident { - if (Lex->add_create_index_prepare($7)) + if (unlikely(Lex->add_create_index_prepare($7))) MYSQL_YYABORT; - if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4)) + if (unlikely(Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, + $1 | $4))) MYSQL_YYABORT; } '(' key_list ')' opt_lock_wait_timeout fulltext_key_options @@ -2664,9 +2673,10 @@ create: | create_or_replace spatial INDEX_SYM opt_if_not_exists ident ON table_ident { - if (Lex->add_create_index_prepare($7)) + if (unlikely(Lex->add_create_index_prepare($7))) MYSQL_YYABORT; - if (Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, $1 | $4)) + if (unlikely(Lex->add_create_index($2, &$5, HA_KEY_ALG_UNDEF, + $1 | $4))) MYSQL_YYABORT; } '(' key_list ')' opt_lock_wait_timeout spatial_key_options @@ -2679,15 +2689,17 @@ create: opt_create_database_options { LEX *lex=Lex; - if (lex->set_command_with_check(SQLCOM_CREATE_DB, 0, $1 | $3)) + if (unlikely(lex->set_command_with_check(SQLCOM_CREATE_DB, 0, + $1 | $3))) MYSQL_YYABORT; lex->name= $4; } | create_or_replace definer_opt opt_view_suid VIEW_SYM opt_if_not_exists table_ident { - if (Lex->add_create_view(thd, $1 | $5, - DTYPE_ALGORITHM_UNDEFINED, $3, $6)) + if (unlikely(Lex->add_create_view(thd, $1 | $5, + DTYPE_ALGORITHM_UNDEFINED, $3, + $6))) MYSQL_YYABORT; } view_list_opt AS view_select @@ -2695,7 +2707,7 @@ create: | create_or_replace view_algorithm definer_opt opt_view_suid VIEW_SYM opt_if_not_exists table_ident { - if (Lex->add_create_view(thd, $1 | $6, $2, $4, $7)) + if (unlikely(Lex->add_create_view(thd, $1 | $6, $2, $4, $7))) MYSQL_YYABORT; } view_list_opt AS view_select @@ -2737,13 +2749,15 @@ create: | create_or_replace USER_SYM opt_if_not_exists clear_privileges grant_list opt_require_clause opt_resource_options { - if (Lex->set_command_with_check(SQLCOM_CREATE_USER, $1 | $3)) + if (unlikely(Lex->set_command_with_check(SQLCOM_CREATE_USER, + $1 | $3))) MYSQL_YYABORT; } | create_or_replace ROLE_SYM opt_if_not_exists clear_privileges role_list opt_with_admin { - if (Lex->set_command_with_check(SQLCOM_CREATE_ROLE, $1 | $3)) + if (unlikely(Lex->set_command_with_check(SQLCOM_CREATE_ROLE, + $1 | $3))) MYSQL_YYABORT; } | CREATE LOGFILE_SYM GROUP_SYM logfile_group_info @@ -2762,7 +2776,7 @@ create: sf_tail_not_aggregate: sf_tail { - if (Lex->sphead->m_flags & sp_head::HAS_AGGREGATE_INSTR) + if (unlikely(Lex->sphead->m_flags & sp_head::HAS_AGGREGATE_INSTR)) { my_yyabort_error((ER_NOT_AGGREGATE_FUNCTION, MYF(0))); } @@ -2772,7 +2786,7 @@ sf_tail_not_aggregate: sf_tail_aggregate: sf_tail { - if (!(Lex->sphead->m_flags & sp_head::HAS_AGGREGATE_INSTR)) + if (unlikely(!(Lex->sphead->m_flags & sp_head::HAS_AGGREGATE_INSTR))) { my_yyabort_error((ER_INVALID_AGGREGATE_FUNCTION, MYF(0))); } @@ -2807,105 +2821,105 @@ sequence_def: } | NO_SYM MINVALUE_SYM { - if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value) + if (unlikely(Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE")); Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; } | NOMINVALUE_SYM { - if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value) + if (unlikely(Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE")); Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value; } | MAXVALUE_SYM opt_equal longlong_num { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_max_value) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_max_value)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE")); Lex->create_info.seq_create_info->max_value= $3; Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; } | NO_SYM MAXVALUE_SYM { - if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value) + if (unlikely(Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE")); Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; } | NOMAXVALUE_SYM { - if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value) + if (unlikely(Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE")); Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value; } | START_SYM opt_with longlong_num { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_start) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_start)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "START")); Lex->create_info.seq_create_info->start= $3; Lex->create_info.seq_create_info->used_fields|= seq_field_used_start; } | INCREMENT_SYM opt_by longlong_num { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_increment) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_increment)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "INCREMENT")); Lex->create_info.seq_create_info->increment= $3; Lex->create_info.seq_create_info->used_fields|= seq_field_used_increment; } | CACHE_SYM opt_equal longlong_num { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_cache) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_cache)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE")); Lex->create_info.seq_create_info->cache= $3; Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache; } | NOCACHE_SYM { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_cache) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_cache)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE")); Lex->create_info.seq_create_info->cache= 0; Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache; } | CYCLE_SYM { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_cycle) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_cycle)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE")); Lex->create_info.seq_create_info->cycle= 1; Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle; } | NOCYCLE_SYM { - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_cycle) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_cycle)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE")); Lex->create_info.seq_create_info->cycle= 0; Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle; } | RESTART_SYM { - if (Lex->sql_command != SQLCOM_ALTER_SEQUENCE) + if (unlikely(Lex->sql_command != SQLCOM_ALTER_SEQUENCE)) { thd->parse_error(ER_SYNTAX_ERROR, "RESTART"); YYABORT; } - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_restart) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_restart)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART")); Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart; } | RESTART_SYM opt_with longlong_num { - if (Lex->sql_command != SQLCOM_ALTER_SEQUENCE) + if (unlikely(Lex->sql_command != SQLCOM_ALTER_SEQUENCE)) { thd->parse_error(ER_SYNTAX_ERROR, "RESTART"); YYABORT; } - if (Lex->create_info.seq_create_info->used_fields & - seq_field_used_restart) + if (unlikely(Lex->create_info.seq_create_info->used_fields & + seq_field_used_restart)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART")); Lex->create_info.seq_create_info->restart= $3; Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart | seq_field_used_restart_value; @@ -2915,7 +2929,7 @@ sequence_def: server_def: SERVER_SYM opt_if_not_exists ident_or_text { - if (Lex->add_create_options_with_check($2)) + if (unlikely(Lex->add_create_options_with_check($2))) MYSQL_YYABORT; Lex->server_options.reset($3); } @@ -2974,9 +2988,10 @@ event_tail: LEX *lex=Lex; lex->stmt_definition_begin= $1; - if (lex->add_create_options_with_check($2)) + if (unlikely(lex->add_create_options_with_check($2))) MYSQL_YYABORT; - if (!(lex->event_parse_data= Event_parse_data::new_instance(thd))) + if (unlikely(!(lex->event_parse_data= + Event_parse_data::new_instance(thd)))) MYSQL_YYABORT; lex->event_parse_data->identifier= $3; lex->event_parse_data->on_completion= @@ -3039,7 +3054,7 @@ ev_starts: /* empty */ { Item *item= new (thd->mem_root) Item_func_now_local(thd, 0); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; Lex->event_parse_data->item_starts= item; } @@ -3103,11 +3118,12 @@ ev_sql_stmt: (the nested ALTER EVENT can have anything but DO clause) - CREATE PROCEDURE ... BEGIN DROP EVENT ... END| */ - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_EVENT_RECURSION_FORBIDDEN, MYF(0))); - if (!lex->make_sp_head(thd, lex->event_parse_data->identifier, - &sp_handler_procedure)) + if (unlikely(!lex->make_sp_head(thd, + lex->event_parse_data->identifier, + &sp_handler_procedure))) MYSQL_YYABORT; lex->sphead->set_body_start(thd, lip->get_cpp_ptr()); @@ -3142,12 +3158,12 @@ clear_privileges: sp_name: ident '.' ident { - if (!($$= Lex->make_sp_name(thd, &$1, &$3))) + if (unlikely(!($$= Lex->make_sp_name(thd, &$1, &$3)))) MYSQL_YYABORT; } | ident { - if (!($$= Lex->make_sp_name(thd, &$1))) + if (unlikely(!($$= Lex->make_sp_name(thd, &$1)))) MYSQL_YYABORT; } ; @@ -3200,7 +3216,7 @@ sp_suid: call: CALL_SYM sp_name { - if (Lex->call_statement_start(thd, $2)) + if (unlikely(Lex->call_statement_start(thd, $2))) MYSQL_YYABORT; } opt_sp_cparam_list {} @@ -3242,7 +3258,7 @@ sp_fdparams: sp_param_name: ident { - if (!($$= Lex->sp_param_init(&$1))) + if (unlikely(!($$= Lex->sp_param_init(&$1)))) MYSQL_YYABORT; } ; @@ -3250,32 +3266,35 @@ sp_param_name: sp_param_name_and_type: sp_param_name type_with_opt_collate { - if (Lex->sp_param_fill_definition($$= $1)) + if (unlikely(Lex->sp_param_fill_definition($$= $1))) MYSQL_YYABORT; } | sp_param_name TYPE_SYM OF_SYM ident '.' ident { - if (Lex->sphead->spvar_fill_type_reference(thd, $$= $1, $4, $6)) + if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, + $$= $1, $4, + $6))) MYSQL_YYABORT; } | sp_param_name TYPE_SYM OF_SYM ident '.' ident '.' ident { - if (Lex->sphead->spvar_fill_type_reference(thd, $$= $1, $4, $6, $8)) + if (unlikely(Lex->sphead->spvar_fill_type_reference(thd, $$= $1, + $4, $6, $8))) MYSQL_YYABORT; } | sp_param_name ROW_SYM TYPE_SYM OF_SYM ident { - if (Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $5)) + if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $5))) MYSQL_YYABORT; } | sp_param_name ROW_SYM TYPE_SYM OF_SYM ident '.' ident { - if (Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $5, $7)) + if (unlikely(Lex->sphead->spvar_fill_table_rowtype_reference(thd, $$= $1, $5, $7))) MYSQL_YYABORT; } | sp_param_name ROW_SYM row_type_body { - if (Lex->sphead->spvar_fill_row(thd, $$= $1, $3)) + if (unlikely(Lex->sphead->spvar_fill_row(thd, $$= $1, $3))) MYSQL_YYABORT; } ; @@ -3347,7 +3366,7 @@ sp_decls: because letting the grammar rules reflect it caused tricky shift/reduce conflicts with the wrong result. (And we get better error handling this way.) */ - if (Lex->sp_declarations_join(&$$, $1, $2)) + if (unlikely(Lex->sp_declarations_join(&$$, $1, $2))) MYSQL_YYABORT; } ; @@ -3360,18 +3379,20 @@ sp_decl: optionally_qualified_column_ident: sp_decl_ident { - if (!($$= new (thd->mem_root) Qualified_column_ident(&$1))) + if (unlikely(!($$= new (thd->mem_root) + Qualified_column_ident(&$1)))) MYSQL_YYABORT; } | sp_decl_ident '.' ident { - if (!($$= new (thd->mem_root) Qualified_column_ident(&$1, &$3))) + if (unlikely(!($$= new (thd->mem_root) + Qualified_column_ident(&$1, &$3)))) MYSQL_YYABORT; } | sp_decl_ident '.' ident '.' ident { - if (!($$= new (thd->mem_root) Qualified_column_ident(thd, - &$1, &$3, &$5))) + if (unlikely(!($$= new (thd->mem_root) + Qualified_column_ident(thd, &$1, &$3, &$5)))) MYSQL_YYABORT; } ; @@ -3379,10 +3400,10 @@ optionally_qualified_column_ident: row_field_name: ident { - if (check_string_char_length(&$1, 0, NAME_CHAR_LEN, - system_charset_info, 1)) + if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN, + system_charset_info, 1))) my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str)); - if (!($$= new (thd->mem_root) Spvar_definition())) + if (unlikely(!($$= new (thd->mem_root) Spvar_definition()))) MYSQL_YYABORT; Lex->init_last_field($$, &$1, thd->variables.collation_database); } @@ -3395,17 +3416,18 @@ row_field_definition: row_field_definition_list: row_field_definition { - if (!($$= new (thd->mem_root) Row_definition_list())) + if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) || + unlikely($$->push_back($1, thd->mem_root))) MYSQL_YYABORT; - $$->push_back($1, thd->mem_root); } | row_field_definition_list ',' row_field_definition { uint unused; - if ($1->find_row_field_by_name(&$3->field_name, &unused)) + if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused))) my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str)); $$= $1; - $$->push_back($3, thd->mem_root); + if (unlikely($$->push_back($3, thd->mem_root))) + MYSQL_YYABORT; } ; @@ -3425,8 +3447,9 @@ sp_decl_variable_list: type_with_opt_collate sp_opt_default { - if (Lex->sp_variable_declarations_finalize(thd, $1, - &Lex->last_field[0], $3)) + if (unlikely(Lex->sp_variable_declarations_finalize(thd, $1, + &Lex->last_field[0], + $3))) MYSQL_YYABORT; $$.init_using_vars($1); } @@ -3434,7 +3457,7 @@ sp_decl_variable_list: TYPE_SYM OF_SYM optionally_qualified_column_ident sp_opt_default { - if (Lex->sp_variable_declarations_with_ref_finalize(thd, $1, $4, $5)) + if (unlikely(Lex->sp_variable_declarations_with_ref_finalize(thd, $1, $4, $5))) MYSQL_YYABORT; $$.init_using_vars($1); } @@ -3442,7 +3465,7 @@ sp_decl_variable_list: ROW_SYM TYPE_SYM OF_SYM optionally_qualified_column_ident sp_opt_default { - if (Lex->sp_variable_declarations_rowtype_finalize(thd, $1, $5, $6)) + if (unlikely(Lex->sp_variable_declarations_rowtype_finalize(thd, $1, $5, $6))) MYSQL_YYABORT; $$.init_using_vars($1); } @@ -3450,7 +3473,7 @@ sp_decl_variable_list: ROW_SYM row_type_body sp_opt_default { - if (Lex->sp_variable_declarations_row_finalize(thd, $1, $3, $4)) + if (unlikely(Lex->sp_variable_declarations_row_finalize(thd, $1, $3, $4))) MYSQL_YYABORT; $$.init_using_vars($1); } @@ -3460,19 +3483,19 @@ sp_decl_body: sp_decl_variable_list | sp_decl_ident CONDITION_SYM FOR_SYM sp_cond { - if (Lex->spcont->declare_condition(thd, &$1, $4)) + if (unlikely(Lex->spcont->declare_condition(thd, &$1, $4))) MYSQL_YYABORT; $$.vars= $$.hndlrs= $$.curs= 0; $$.conds= 1; } | sp_handler_type HANDLER_SYM FOR_SYM { - if (Lex->sp_handler_declaration_init(thd, $1)) + if (unlikely(Lex->sp_handler_declaration_init(thd, $1))) MYSQL_YYABORT; } sp_hcond_list sp_proc_stmt { - if (Lex->sp_handler_declaration_finalize(thd, $1)) + if (unlikely(Lex->sp_handler_declaration_finalize(thd, $1))) MYSQL_YYABORT; $$.vars= $$.conds= $$.curs= 0; $$.hndlrs= 1; @@ -3485,9 +3508,9 @@ sp_decl_body: FOR_SYM sp_cursor_stmt { sp_pcontext *param_ctx= Lex->spcont; - if (Lex->sp_block_finalize(thd)) + if (unlikely(Lex->sp_block_finalize(thd))) MYSQL_YYABORT; - if (Lex->sp_declare_cursor(thd, &$1, $6, param_ctx, true)) + if (unlikely(Lex->sp_declare_cursor(thd, &$1, $6, param_ctx, true))) MYSQL_YYABORT; $$.vars= $$.conds= $$.hndlrs= 0; $$.curs= 1; @@ -3503,7 +3526,7 @@ opt_parenthesized_cursor_formal_parameters: sp_cursor_stmt_lex: { DBUG_ASSERT(thd->lex->sphead); - if (!($$= new (thd->mem_root) sp_lex_cursor(thd, thd->lex))) + if (unlikely(!($$= new (thd->mem_root) sp_lex_cursor(thd, thd->lex)))) MYSQL_YYABORT; } ; @@ -3517,8 +3540,8 @@ sp_cursor_stmt: select { DBUG_ASSERT(Lex == $1); - if ($1->stmt_finalize(thd) || - $1->sphead->restore_lex(thd)) + if (unlikely($1->stmt_finalize(thd)) || + unlikely($1->sphead->restore_lex(thd))) MYSQL_YYABORT; $$= $1; } @@ -3544,7 +3567,7 @@ sp_hcond_element: sp_head *sp= lex->sphead; sp_pcontext *ctx= lex->spcont->parent_context(); - if (ctx->check_duplicate_handler($1)) + if (unlikely(ctx->check_duplicate_handler($1))) my_yyabort_error((ER_SP_DUP_HANDLER, MYF(0))); sp_instr_hpush_jump *i= (sp_instr_hpush_jump *)sp->last_instruction(); @@ -3555,10 +3578,10 @@ sp_hcond_element: sp_cond: ulong_num { /* mysql errno */ - if ($1 == 0) + if (unlikely($1 == 0)) my_yyabort_error((ER_WRONG_VALUE, MYF(0), "CONDITION", "0")); $$= new (thd->mem_root) sp_condition_value($1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | sqlstate @@ -3575,10 +3598,11 @@ sqlstate: allowed to SIGNAL, or declare a handler for the completion condition. */ - if (!is_sqlstate_valid(&$3) || is_sqlstate_completion($3.str)) + if (unlikely(!is_sqlstate_valid(&$3) || + is_sqlstate_completion($3.str))) my_yyabort_error((ER_SP_BAD_SQLSTATE, MYF(0), $3.str)); $$= new (thd->mem_root) sp_condition_value($3.str); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -3596,25 +3620,25 @@ sp_hcond: | ident /* CONDITION name */ { $$= Lex->spcont->find_condition(&$1, false); - if ($$ == NULL) + if (unlikely($$ == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); } | SQLWARNING_SYM /* SQLSTATEs 01??? */ { $$= new (thd->mem_root) sp_condition_value(sp_condition_value::WARNING); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | not FOUND_SYM /* SQLSTATEs 02??? */ { $$= new (thd->mem_root) sp_condition_value(sp_condition_value::NOT_FOUND); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SQLEXCEPTION_SYM /* All other SQLSTATEs */ { $$= new (thd->mem_root) sp_condition_value(sp_condition_value::EXCEPTION); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -3622,7 +3646,7 @@ sp_hcond: signal_stmt: SIGNAL_SYM signal_value opt_set_signal_information { - if (Lex->add_signal_statement(thd, $2)) + if (unlikely(Lex->add_signal_statement(thd, $2))) MYSQL_YYABORT; } ; @@ -3634,12 +3658,12 @@ signal_value: sp_condition_value *cond; /* SIGNAL foo cannot be used outside of stored programs */ - if (lex->spcont == NULL) + if (unlikely(lex->spcont == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); cond= lex->spcont->find_condition(&$1, false); - if (cond == NULL) + if (unlikely(cond == NULL)) my_yyabort_error((ER_SP_COND_MISMATCH, MYF(0), $1.str)); - if (cond->type != sp_condition_value::SQLSTATE) + if (unlikely(cond->type != sp_condition_value::SQLSTATE)) my_yyabort_error((ER_SIGNAL_BAD_CONDITION_TYPE, MYF(0))); $$= cond; } @@ -3677,7 +3701,7 @@ signal_information_item_list: Set_signal_information *info; info= &thd->m_parser_state->m_yacc.m_set_signal_info; int index= (int) $3; - if (info->m_item[index] != NULL) + if (unlikely(info->m_item[index] != NULL)) my_yyabort_error((ER_DUP_SIGNAL_SET, MYF(0), Diag_condition_item_names[index].str)); info->m_item[index]= $5; @@ -3695,7 +3719,7 @@ signal_allowed_expr: if ($1->type() == Item::FUNC_ITEM) { Item_func *item= (Item_func*) $1; - if (item->functype() == Item_func::SUSERVAR_FUNC) + if (unlikely(item->functype() == Item_func::SUSERVAR_FUNC)) { /* Don't allow the following syntax: @@ -3743,7 +3767,7 @@ signal_condition_information_item_name: resignal_stmt: RESIGNAL_SYM opt_signal_value opt_set_signal_information { - if (Lex->add_resignal_statement(thd, $2)) + if (unlikely(Lex->add_resignal_statement(thd, $2))) MYSQL_YYABORT; } ; @@ -3758,7 +3782,7 @@ get_diagnostics: Lex->sql_command= SQLCOM_GET_DIAGNOSTICS; Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_get_diagnostics(info); - if (Lex->m_sql_cmd == NULL) + if (unlikely(Lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -3774,13 +3798,13 @@ diagnostics_information: statement_information { $$= new (thd->mem_root) Statement_information($1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CONDITION_SYM condition_number condition_information { $$= new (thd->mem_root) Condition_information($2, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -3789,12 +3813,13 @@ statement_information: statement_information_item { $$= new (thd->mem_root) List<Statement_information_item>; - if ($$ == NULL || $$->push_back($1, thd->mem_root)) + if (unlikely($$ == NULL) || + unlikely($$->push_back($1, thd->mem_root))) MYSQL_YYABORT; } | statement_information ',' statement_information_item { - if ($1->push_back($3, thd->mem_root)) + if (unlikely($1->push_back($3, thd->mem_root))) MYSQL_YYABORT; $$= $1; } @@ -3804,20 +3829,20 @@ statement_information_item: simple_target_specification '=' statement_information_item_name { $$= new (thd->mem_root) Statement_information_item($3, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } simple_target_specification: ident_cli { - if (!($$= thd->lex->create_item_for_sp_var(&$1, NULL))) + if (unlikely(!($$= thd->lex->create_item_for_sp_var(&$1, NULL)))) MYSQL_YYABORT; } | '@' ident_or_text { $$= new (thd->mem_root) Item_func_get_user_var(thd, &$2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -3842,12 +3867,13 @@ condition_information: condition_information_item { $$= new (thd->mem_root) List<Condition_information_item>; - if ($$ == NULL || $$->push_back($1, thd->mem_root)) + if (unlikely($$ == NULL) || + unlikely($$->push_back($1, thd->mem_root))) MYSQL_YYABORT; } | condition_information ',' condition_information_item { - if ($1->push_back($3, thd->mem_root)) + if (unlikely($1->push_back($3, thd->mem_root))) MYSQL_YYABORT; $$= $1; } @@ -3857,7 +3883,7 @@ condition_information_item: simple_target_specification '=' condition_information_item_name { $$= new (thd->mem_root) Condition_information_item($3, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } @@ -3902,7 +3928,7 @@ sp_decl_idents: LEX *lex= Lex; sp_pcontext *spc= lex->spcont; - if (spc->find_variable(&$1, TRUE)) + if (unlikely(spc->find_variable(&$1, TRUE))) my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $1.str)); spc->add_variable(thd, &$1); $$= 1; @@ -3914,7 +3940,7 @@ sp_decl_idents: LEX *lex= Lex; sp_pcontext *spc= lex->spcont; - if (spc->find_variable(&$3, TRUE)) + if (unlikely(spc->find_variable(&$3, TRUE))) my_yyabort_error((ER_SP_DUP_VAR, MYF(0), $3.str)); spc->add_variable(thd, &$3); $$= $1 + 1; @@ -3963,7 +3989,7 @@ sp_proc_stmt_compound_ok: sp_proc_stmt_if: IF_SYM { - if (Lex->maybe_start_compound_statement(thd)) + if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; Lex->sphead->new_cont_backpatch(NULL); } @@ -3987,7 +4013,7 @@ sp_proc_stmt_statement: sp->m_flags|= sp_get_flags_for_command(lex); /* "USE db" doesn't work in a procedure */ - if (lex->sql_command == SQLCOM_CHANGE_DB) + if (unlikely(lex->sql_command == SQLCOM_CHANGE_DB)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "USE")); /* Don't add an instruction for SET statements, since all @@ -4000,7 +4026,7 @@ sp_proc_stmt_statement: { sp_instr_stmt *i=new (thd->mem_root) sp_instr_stmt(sp->instructions(), lex->spcont, lex); - if (i == NULL) + if (unlikely(i == NULL)) MYSQL_YYABORT; /* @@ -4012,13 +4038,13 @@ sp_proc_stmt_statement: i->m_query.length= lip->get_ptr() - sp->m_tmp_query; else i->m_query.length= lip->get_tok_start() - sp->m_tmp_query;; - if (!(i->m_query.str= strmake_root(thd->mem_root, - sp->m_tmp_query, - i->m_query.length)) || - sp->add_instr(i)) + if (unlikely(!(i->m_query.str= strmake_root(thd->mem_root, + sp->m_tmp_query, + i->m_query.length))) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; } - if (sp->restore_lex(thd)) + if (unlikely(sp->restore_lex(thd))) MYSQL_YYABORT; } ; @@ -4030,9 +4056,9 @@ sp_proc_stmt_return: { LEX *lex= Lex; sp_head *sp= lex->sphead; - if (sp->m_handler->add_instr_freturn(thd, sp, lex->spcont, - $3, lex) || - sp->restore_lex(thd)) + if (unlikely(sp->m_handler->add_instr_freturn(thd, sp, lex->spcont, + $3, lex)) || + unlikely(sp->restore_lex(thd))) MYSQL_YYABORT; } ; @@ -4040,7 +4066,7 @@ sp_proc_stmt_return: sp_proc_stmt_leave: LEAVE_SYM label_ident { - if (Lex->sp_leave_statement(thd, &$2)) + if (unlikely(Lex->sp_leave_statement(thd, &$2))) MYSQL_YYABORT; } ; @@ -4048,7 +4074,7 @@ sp_proc_stmt_leave: sp_proc_stmt_iterate: ITERATE_SYM label_ident { - if (Lex->sp_iterate_statement(thd, &$2)) + if (unlikely(Lex->sp_iterate_statement(thd, &$2))) MYSQL_YYABORT; } ; @@ -4056,7 +4082,8 @@ sp_proc_stmt_iterate: assignment_source_lex: { DBUG_ASSERT(Lex->sphead); - if (!($$= new (thd->mem_root) sp_assignment_lex(thd, thd->lex))) + if (unlikely(!($$= new (thd->mem_root) + sp_assignment_lex(thd, thd->lex)))) MYSQL_YYABORT; } ; @@ -4074,7 +4101,7 @@ assignment_source_expr: $$->sp_lex_in_use= true; $$->set_item_and_free_list($3, thd->free_list); thd->free_list= NULL; - if ($$->sphead->restore_lex(thd)) + if (unlikely($$->sphead->restore_lex(thd))) MYSQL_YYABORT; } ; @@ -4090,7 +4117,7 @@ for_loop_bound_expr: $$= $1; $$->sp_lex_in_use= true; $$->set_item_and_free_list($3, NULL); - if ($$->sphead->restore_lex(thd)) + if (unlikely($$->sphead->restore_lex(thd))) MYSQL_YYABORT; } ; @@ -4098,7 +4125,7 @@ for_loop_bound_expr: cursor_actual_parameters: assignment_source_expr { - if (!($$= new (thd->mem_root) List<sp_assignment_lex>)) + if (unlikely(!($$= new (thd->mem_root) List<sp_assignment_lex>))) MYSQL_YYABORT; $$->push_back($1, thd->mem_root); } @@ -4117,7 +4144,7 @@ opt_parenthesized_cursor_actual_parameters: sp_proc_stmt_open: OPEN_SYM ident opt_parenthesized_cursor_actual_parameters { - if (Lex->sp_open_cursor(thd, &$2, $3)) + if (unlikely(Lex->sp_open_cursor(thd, &$2, $3))) MYSQL_YYABORT; } ; @@ -4125,17 +4152,17 @@ sp_proc_stmt_open: sp_proc_stmt_fetch_head: FETCH_SYM ident INTO { - if (Lex->sp_add_cfetch(thd, &$2)) + if (unlikely(Lex->sp_add_cfetch(thd, &$2))) MYSQL_YYABORT; } | FETCH_SYM FROM ident INTO { - if (Lex->sp_add_cfetch(thd, &$3)) + if (unlikely(Lex->sp_add_cfetch(thd, &$3))) MYSQL_YYABORT; } | FETCH_SYM NEXT_SYM FROM ident INTO { - if (Lex->sp_add_cfetch(thd, &$4)) + if (unlikely(Lex->sp_add_cfetch(thd, &$4))) MYSQL_YYABORT; } ; @@ -4150,8 +4177,8 @@ sp_proc_stmt_fetch: sp_instr_agg_cfetch *i= new (thd->mem_root) sp_instr_agg_cfetch(sp->instructions(), lex->spcont); - if (i == NULL || - sp->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; } ; @@ -4164,12 +4191,12 @@ sp_proc_stmt_close: uint offset; sp_instr_cclose *i; - if (! lex->spcont->find_cursor(&$2, &offset, false)) + if (unlikely(!lex->spcont->find_cursor(&$2, &offset, false))) my_yyabort_error((ER_SP_CURSOR_MISMATCH, MYF(0), $2.str)); i= new (thd->mem_root) sp_instr_cclose(sp->instructions(), lex->spcont, offset); - if (i == NULL || - sp->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; } ; @@ -4182,7 +4209,7 @@ sp_fetch_list: sp_pcontext *spc= lex->spcont; sp_variable *spv; - if (!spc || !(spv = spc->find_variable(&$1, false))) + if (unlikely(!spc || !(spv = spc->find_variable(&$1, false)))) my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $1.str)); /* An SP local variable */ @@ -4196,7 +4223,7 @@ sp_fetch_list: sp_pcontext *spc= lex->spcont; sp_variable *spv; - if (!spc || !(spv = spc->find_variable(&$3, false))) + if (unlikely(!spc || !(spv = spc->find_variable(&$3, false)))) my_yyabort_error((ER_SP_UNDECLARED_VAR, MYF(0), $3.str)); /* An SP local variable */ @@ -4215,12 +4242,12 @@ sp_if: uint ip= sp->instructions(); sp_instr_jump_if_not *i= new (thd->mem_root) sp_instr_jump_if_not(ip, ctx, $2, lex); - if (i == NULL || - sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0)) || - sp->add_cont_backpatch(i) || - sp->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0))) || + unlikely(sp->add_cont_backpatch(i)) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; - if (sp->restore_lex(thd)) + if (unlikely(sp->restore_lex(thd))) MYSQL_YYABORT; } sp_proc_stmts1 @@ -4229,8 +4256,8 @@ sp_if: sp_pcontext *ctx= Lex->spcont; uint ip= sp->instructions(); sp_instr_jump *i= new (thd->mem_root) sp_instr_jump(ip, ctx); - if (i == NULL || - sp->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; sp->backpatch(ctx->pop_label()); sp->push_backpatch(thd, i, ctx->push_label(thd, &empty_clex_str, 0)); @@ -4252,7 +4279,7 @@ sp_elseifs: case_stmt_specification: CASE_SYM { - if (Lex->maybe_start_compound_statement(thd)) + if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; /** @@ -4323,10 +4350,9 @@ case_stmt_body: { Lex->sphead->reset_lex(thd); /* For expr $2 */ } expr { - if (Lex->case_stmt_action_expr($2)) + if (unlikely(Lex->case_stmt_action_expr($2))) MYSQL_YYABORT; - - if (Lex->sphead->restore_lex(thd)) + if (unlikely(Lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } simple_when_clause_list @@ -4355,16 +4381,16 @@ simple_when_clause: /* Simple case: <caseval> = <whenval> */ LEX *lex= Lex; - if (lex->case_stmt_action_when($3, true)) + if (unlikely(lex->case_stmt_action_when($3, true))) MYSQL_YYABORT; /* For expr $3 */ - if (lex->sphead->restore_lex(thd)) + if (unlikely(lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } THEN_SYM sp_proc_stmts1 { - if (Lex->case_stmt_action_then()) + if (unlikely(Lex->case_stmt_action_then())) MYSQL_YYABORT; } ; @@ -4377,16 +4403,16 @@ searched_when_clause: expr { LEX *lex= Lex; - if (lex->case_stmt_action_when($3, false)) + if (unlikely(lex->case_stmt_action_when($3, false))) MYSQL_YYABORT; /* For expr $3 */ - if (lex->sphead->restore_lex(thd)) + if (unlikely(lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } THEN_SYM sp_proc_stmts1 { - if (Lex->case_stmt_action_then()) + if (unlikely(Lex->case_stmt_action_then())) MYSQL_YYABORT; } ; @@ -4399,8 +4425,8 @@ else_clause_opt: uint ip= sp->instructions(); sp_instr_error *i= new (thd->mem_root) sp_instr_error(ip, lex->spcont, ER_SP_CASE_NOT_FOUND); - if (i == NULL || - sp->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(sp->add_instr(i))) MYSQL_YYABORT; } | ELSE sp_proc_stmts1 @@ -4418,7 +4444,7 @@ sp_opt_label: sp_block_label: sp_label { - if (Lex->spcont->block_label_declare(&$1)) + if (unlikely(Lex->spcont->block_label_declare(&$1))) MYSQL_YYABORT; $$= $1; } @@ -4435,7 +4461,7 @@ sp_labeled_block: END sp_opt_label { - if (Lex->sp_block_finalize(thd, $4, &$7)) + if (unlikely(Lex->sp_block_finalize(thd, $4, &$7))) MYSQL_YYABORT; } ; @@ -4449,7 +4475,7 @@ sp_unlabeled_block: sp_proc_stmts END { - if (Lex->sp_block_finalize(thd, $3)) + if (unlikely(Lex->sp_block_finalize(thd, $3))) MYSQL_YYABORT; } ; @@ -4457,7 +4483,7 @@ sp_unlabeled_block: sp_unlabeled_block_not_atomic: BEGIN_SYM not ATOMIC_SYM /* TODO: BEGIN ATOMIC (not -> opt_not) */ { - if (Lex->maybe_start_compound_statement(thd)) + if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; Lex->sp_block_init(thd); } @@ -4465,7 +4491,7 @@ sp_unlabeled_block_not_atomic: sp_proc_stmts END { - if (Lex->sp_block_finalize(thd, $5)) + if (unlikely(Lex->sp_block_finalize(thd, $5))) MYSQL_YYABORT; } ; @@ -4479,7 +4505,7 @@ opt_sp_for_loop_direction: sp_for_loop_index_and_bounds: ident sp_for_loop_bounds { - if (Lex->sp_for_loop_declarations(thd, &$$, &$1, $2)) + if (unlikely(Lex->sp_for_loop_declarations(thd, &$$, &$1, $2))) MYSQL_YYABORT; } ; @@ -4502,7 +4528,8 @@ sp_for_loop_bounds: } | IN_SYM opt_sp_for_loop_direction '(' sp_cursor_stmt ')' { - if (Lex->sp_for_loop_implicit_cursor_statement(thd, &$$, $4)) + if (unlikely(Lex->sp_for_loop_implicit_cursor_statement(thd, &$$, + $4))) MYSQL_YYABORT; } ; @@ -4515,8 +4542,8 @@ loop_body: sp_label *lab= lex->spcont->last_label(); /* Jumping back */ sp_instr_jump *i= new (thd->mem_root) sp_instr_jump(ip, lex->spcont, lab->ip); - if (i == NULL || - lex->sphead->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(lex->sphead->add_instr(i))) MYSQL_YYABORT; } ; @@ -4525,14 +4552,14 @@ while_body: expr DO_SYM { LEX *lex= Lex; - if (lex->sp_while_loop_expression(thd, $1)) + if (unlikely(lex->sp_while_loop_expression(thd, $1))) MYSQL_YYABORT; - if (lex->sphead->restore_lex(thd)) + if (unlikely(lex->sphead->restore_lex(thd))) MYSQL_YYABORT; } sp_proc_stmts1 END WHILE_SYM { - if (Lex->sp_while_loop_finalize(thd)) + if (unlikely(Lex->sp_while_loop_finalize(thd))) MYSQL_YYABORT; } ; @@ -4547,10 +4574,10 @@ repeat_body: sp_label *lab= lex->spcont->last_label(); /* Jumping back */ sp_instr_jump_if_not *i= new (thd->mem_root) sp_instr_jump_if_not(ip, lex->spcont, $4, lab->ip, lex); - if (i == NULL || - lex->sphead->add_instr(i)) + if (unlikely(i == NULL) || + unlikely(lex->sphead->add_instr(i))) MYSQL_YYABORT; - if (lex->sphead->restore_lex(thd)) + if (unlikely(lex->sphead->restore_lex(thd))) MYSQL_YYABORT; /* We can shortcut the cont_backpatch here */ i->m_cont_dest= ip+1; @@ -4560,7 +4587,7 @@ repeat_body: pop_sp_loop_label: sp_opt_label { - if (Lex->sp_pop_loop_label(thd, &$1)) + if (unlikely(Lex->sp_pop_loop_label(thd, &$1))) MYSQL_YYABORT; } ; @@ -4568,14 +4595,14 @@ pop_sp_loop_label: sp_labeled_control: sp_label LOOP_SYM { - if (Lex->sp_push_loop_label(thd, &$1)) + if (unlikely(Lex->sp_push_loop_label(thd, &$1))) MYSQL_YYABORT; } loop_body pop_sp_loop_label { } | sp_label WHILE_SYM { - if (Lex->sp_push_loop_label(thd, &$1)) + if (unlikely(Lex->sp_push_loop_label(thd, &$1))) MYSQL_YYABORT; Lex->sphead->reset_lex(thd); } @@ -4588,28 +4615,28 @@ sp_labeled_control: } sp_for_loop_index_and_bounds { - if (Lex->sp_push_loop_label(thd, &$1)) // The inner WHILE block + if (unlikely(Lex->sp_push_loop_label(thd, &$1))) // The inner WHILE block MYSQL_YYABORT; - if (Lex->sp_for_loop_condition_test(thd, $4)) + if (unlikely(Lex->sp_for_loop_condition_test(thd, $4))) MYSQL_YYABORT; } DO_SYM sp_proc_stmts1 END FOR_SYM { - if (Lex->sp_for_loop_finalize(thd, $4)) + if (unlikely(Lex->sp_for_loop_finalize(thd, $4))) MYSQL_YYABORT; } pop_sp_loop_label // The inner WHILE block { Lex_spblock tmp; tmp.curs= MY_TEST($4.m_implicit_cursor); - if (Lex->sp_block_finalize(thd, tmp)) // The outer DECLARE..BEGIN..END + if (unlikely(Lex->sp_block_finalize(thd, tmp))) // The outer DECLARE..BEGIN..END MYSQL_YYABORT; } | sp_label REPEAT_SYM { - if (Lex->sp_push_loop_label(thd, &$1)) + if (unlikely(Lex->sp_push_loop_label(thd, &$1))) MYSQL_YYABORT; } repeat_body pop_sp_loop_label @@ -4619,7 +4646,7 @@ sp_labeled_control: sp_unlabeled_control: LOOP_SYM { - if (Lex->sp_push_loop_empty_label(thd)) + if (unlikely(Lex->sp_push_loop_empty_label(thd))) MYSQL_YYABORT; } loop_body @@ -4628,7 +4655,7 @@ sp_unlabeled_control: } | WHILE_SYM { - if (Lex->sp_push_loop_empty_label(thd)) + if (unlikely(Lex->sp_push_loop_empty_label(thd))) MYSQL_YYABORT; Lex->sphead->reset_lex(thd); } @@ -4639,15 +4666,15 @@ sp_unlabeled_control: | FOR_SYM { // See "The FOR LOOP statement" comments in sql_lex.cc - if (Lex->maybe_start_compound_statement(thd)) + if (unlikely(Lex->maybe_start_compound_statement(thd))) MYSQL_YYABORT; Lex->sp_block_init(thd); // The outer DECLARE..BEGIN..END block } sp_for_loop_index_and_bounds { - if (Lex->sp_push_loop_empty_label(thd)) // The inner WHILE block + if (unlikely(Lex->sp_push_loop_empty_label(thd))) // The inner WHILE block MYSQL_YYABORT; - if (Lex->sp_for_loop_condition_test(thd, $3)) + if (unlikely(Lex->sp_for_loop_condition_test(thd, $3))) MYSQL_YYABORT; } DO_SYM @@ -4656,15 +4683,15 @@ sp_unlabeled_control: { Lex_spblock tmp; tmp.curs= MY_TEST($3.m_implicit_cursor); - if (Lex->sp_for_loop_finalize(thd, $3)) + if (unlikely(Lex->sp_for_loop_finalize(thd, $3))) MYSQL_YYABORT; Lex->sp_pop_loop_empty_label(thd); // The inner WHILE block - if (Lex->sp_block_finalize(thd, tmp)) // The outer DECLARE..BEGIN..END + if (unlikely(Lex->sp_block_finalize(thd, tmp))) // The outer DECLARE..BEGIN..END MYSQL_YYABORT; } | REPEAT_SYM { - if (Lex->sp_push_loop_empty_label(thd)) + if (unlikely(Lex->sp_push_loop_empty_label(thd))) MYSQL_YYABORT; } repeat_body @@ -4883,7 +4910,7 @@ tablespace_name: LEX *lex= Lex; lex->alter_tablespace_info= (new (thd->mem_root) st_alter_tablespace()); - if (lex->alter_tablespace_info == NULL) + if (unlikely(lex->alter_tablespace_info == NULL)) MYSQL_YYABORT; lex->alter_tablespace_info->tablespace_name= $1.str; lex->sql_command= SQLCOM_ALTER_TABLESPACE; @@ -4896,7 +4923,7 @@ logfile_group_name: LEX *lex= Lex; lex->alter_tablespace_info= (new (thd->mem_root) st_alter_tablespace()); - if (lex->alter_tablespace_info == NULL) + if (unlikely(lex->alter_tablespace_info == NULL)) MYSQL_YYABORT; lex->alter_tablespace_info->logfile_group_name= $1.str; lex->sql_command= SQLCOM_ALTER_TABLESPACE; @@ -4973,7 +5000,7 @@ opt_ts_nodegroup: NODEGROUP_SYM opt_equal real_ulong_num { LEX *lex= Lex; - if (lex->alter_tablespace_info->nodegroup_id != UNDEF_NODEGROUP) + if (unlikely(lex->alter_tablespace_info->nodegroup_id != UNDEF_NODEGROUP)) my_yyabort_error((ER_FILEGROUP_OPTION_ONLY_ONCE,MYF(0),"NODEGROUP")); lex->alter_tablespace_info->nodegroup_id= $3; } @@ -4983,7 +5010,7 @@ opt_ts_comment: COMMENT_SYM opt_equal TEXT_STRING_sys { LEX *lex= Lex; - if (lex->alter_tablespace_info->ts_comment != NULL) + if (unlikely(lex->alter_tablespace_info->ts_comment != NULL)) my_yyabort_error((ER_FILEGROUP_OPTION_ONLY_ONCE,MYF(0),"COMMENT")); lex->alter_tablespace_info->ts_comment= $3.str; } @@ -4993,7 +5020,7 @@ opt_ts_engine: opt_storage ENGINE_SYM opt_equal storage_engines { LEX *lex= Lex; - if (lex->alter_tablespace_info->storage_engine != NULL) + if (unlikely(lex->alter_tablespace_info->storage_engine != NULL)) my_yyabort_error((ER_FILEGROUP_OPTION_ONLY_ONCE, MYF(0), "STORAGE ENGINE")); lex->alter_tablespace_info->storage_engine= $4; @@ -5014,7 +5041,7 @@ ts_wait: | NO_WAIT_SYM { LEX *lex= Lex; - if (!(lex->alter_tablespace_info->wait_until_completed)) + if (unlikely(!(lex->alter_tablespace_info->wait_until_completed))) my_yyabort_error((ER_FILEGROUP_OPTION_ONLY_ONCE,MYF(0),"NO_WAIT")); lex->alter_tablespace_info->wait_until_completed= FALSE; } @@ -5032,7 +5059,7 @@ size_number: const char *end_ptr= start_ptr + str_len; int error; prefix_number= my_strtoll10(start_ptr, (char**) &end_ptr, &error); - if ((start_ptr + str_len - 1) == end_ptr) + if (likely((start_ptr + str_len - 1) == end_ptr)) { switch (end_ptr[0]) { @@ -5045,7 +5072,7 @@ size_number: default: my_yyabort_error((ER_WRONG_SIZE_NUMBER, MYF(0))); } - if (prefix_number >> 31) + if (unlikely(prefix_number >> 31)) my_yyabort_error((ER_SIZE_OVERFLOW_ERROR, MYF(0))); number= prefix_number << text_shift_number; } @@ -5080,7 +5107,7 @@ create_body: Lex->create_info.add(DDL_options_st::OPT_LIKE); TABLE_LIST *src_table= Lex->select_lex.add_table_to_list(thd, $1, NULL, 0, TL_READ, MDL_SHARED_READ); - if (! src_table) + if (unlikely(! src_table)) MYSQL_YYABORT; /* CREATE TABLE ... LIKE is not allowed for views. */ src_table->required_type= TABLE_TYPE_NORMAL; @@ -5164,11 +5191,8 @@ partitioning: { LEX *lex= Lex; lex->part_info= new (thd->mem_root) partition_info(); - if (!lex->part_info) - { - mem_alloc_error(sizeof(partition_info)); + if (unlikely(!lex->part_info)) MYSQL_YYABORT; - } if (lex->sql_command == SQLCOM_ALTER_TABLE) { lex->alter_info.partition_flags|= ALTER_PARTITION_INFO; @@ -5182,7 +5206,7 @@ have_partitioning: { #ifdef WITH_PARTITION_STORAGE_ENGINE LEX_CSTRING partition_name={STRING_WITH_LEN("partition")}; - if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + if (unlikely(!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN))) my_yyabort_error((ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-partition")); #else @@ -5195,7 +5219,7 @@ have_partitioning: partition_entry: PARTITION_SYM { - if (!Lex->part_info) + if (unlikely(!Lex->part_info)) { thd->parse_error(ER_PARTITION_ENTRY_ERROR); MYSQL_YYABORT; @@ -5242,7 +5266,10 @@ part_type_def: | LIST_SYM part_column_list { Lex->part_info->part_type= LIST_PARTITION; } | SYSTEM_TIME_SYM - { if (Lex->part_info->vers_init_info(thd)) MYSQL_YYABORT; } + { + if (unlikely(Lex->part_info->vers_init_info(thd))) + MYSQL_YYABORT; + } opt_versioning_rotation ; @@ -5286,11 +5313,9 @@ part_field_item: { partition_info *part_info= Lex->part_info; part_info->num_columns++; - if (part_info->part_field_list.push_back($1.str, thd->mem_root)) - { - mem_alloc_error(1); + if (unlikely(part_info->part_field_list.push_back($1.str, + thd->mem_root))) MYSQL_YYABORT; - } if (part_info->num_columns > MAX_REF_PARTS) my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), "list of partition fields")); @@ -5311,8 +5336,8 @@ part_func: '(' remember_name part_func_expr remember_end ')' { partition_info *part_info= Lex->part_info; - if (part_info->set_part_expr(thd, $2 + 1, $3, $4, FALSE)) - { MYSQL_YYABORT; } + if (unlikely(part_info->set_part_expr(thd, $2 + 1, $3, $4, FALSE))) + MYSQL_YYABORT; part_info->num_columns= 1; part_info->column_list= FALSE; } @@ -5321,8 +5346,8 @@ part_func: sub_part_func: '(' remember_name part_func_expr remember_end ')' { - if (Lex->part_info->set_part_expr(thd, $2 + 1, $3, $4, TRUE)) - { MYSQL_YYABORT; } + if (unlikely(Lex->part_info->set_part_expr(thd, $2 + 1, $3, $4, TRUE))) + MYSQL_YYABORT; } ; @@ -5333,7 +5358,7 @@ opt_num_parts: { uint num_parts= $2; partition_info *part_info= Lex->part_info; - if (num_parts == 0) + if (unlikely(num_parts == 0)) my_yyabort_error((ER_NO_PARTS_ERROR, MYF(0), "partitions")); part_info->num_parts= num_parts; @@ -5365,12 +5390,10 @@ sub_part_field_item: ident { partition_info *part_info= Lex->part_info; - if (part_info->subpart_field_list.push_back($1.str, thd->mem_root)) - { - mem_alloc_error(1); + if (unlikely(part_info->subpart_field_list.push_back($1.str, + thd->mem_root))) MYSQL_YYABORT; - } - if (part_info->subpart_field_list.elements > MAX_REF_PARTS) + if (unlikely(part_info->subpart_field_list.elements > MAX_REF_PARTS)) my_yyabort_error((ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR, MYF(0), "list of subpartition fields")); } @@ -5379,7 +5402,7 @@ sub_part_field_item: part_func_expr: bit_expr { - if (!Lex->safe_to_cache_query) + if (unlikely(!Lex->safe_to_cache_query)) { thd->parse_error(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR); MYSQL_YYABORT; @@ -5394,7 +5417,7 @@ opt_num_subparts: { uint num_parts= $2; LEX *lex= Lex; - if (num_parts == 0) + if (unlikely(num_parts == 0)) my_yyabort_error((ER_NO_PARTS_ERROR, MYF(0), "subpartitions")); lex->part_info->num_subparts= num_parts; lex->part_info->use_default_num_subpartitions= FALSE; @@ -5405,10 +5428,10 @@ part_defs: /* empty */ { partition_info *part_info= Lex->part_info; - if (part_info->part_type == RANGE_PARTITION) + if (unlikely(part_info->part_type == RANGE_PARTITION)) my_yyabort_error((ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "RANGE")); - if (part_info->part_type == LIST_PARTITION) + if (unlikely(part_info->part_type == LIST_PARTITION)) my_yyabort_error((ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "LIST")); } @@ -5418,8 +5441,8 @@ part_defs: uint count_curr_parts= part_info->partitions.elements; if (part_info->num_parts != 0) { - if (part_info->num_parts != - count_curr_parts) + if (unlikely(part_info->num_parts != + count_curr_parts)) { thd->parse_error(ER_PARTITION_WRONG_NO_PART_ERROR); MYSQL_YYABORT; @@ -5444,12 +5467,9 @@ part_definition: partition_info *part_info= Lex->part_info; partition_element *p_elem= new (thd->mem_root) partition_element(); - if (!p_elem || - part_info->partitions.push_back(p_elem, thd->mem_root)) - { - mem_alloc_error(sizeof(partition_element)); + if (unlikely(!p_elem) || + unlikely(part_info->partitions.push_back(p_elem, thd->mem_root))) MYSQL_YYABORT; - } p_elem->part_state= PART_NORMAL; p_elem->id= part_info->partitions.elements - 1; part_info->curr_part_elem= p_elem; @@ -5469,7 +5489,7 @@ part_name: { partition_info *part_info= Lex->part_info; partition_element *p_elem= part_info->curr_part_elem; - if (check_ident_length(&$1)) + if (unlikely(check_ident_length(&$1))) MYSQL_YYABORT; p_elem->partition_name= $1.str; } @@ -5482,9 +5502,9 @@ opt_part_values: partition_info *part_info= lex->part_info; if (! lex->is_partition_management()) { - if (part_info->error_if_requires_values()) - MYSQL_YYABORT; - if (part_info->part_type == VERSIONING_PARTITION) + if (unlikely(part_info->error_if_requires_values())) + MYSQL_YYABORT; + if (unlikely(part_info->part_type == VERSIONING_PARTITION)) my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), lex->create_last_non_select_table-> table_name.str)); @@ -5498,7 +5518,7 @@ opt_part_values: partition_info *part_info= lex->part_info; if (! lex->is_partition_management()) { - if (part_info->part_type != RANGE_PARTITION) + if (unlikely(part_info->part_type != RANGE_PARTITION)) my_yyabort_error((ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN")); } @@ -5512,7 +5532,7 @@ opt_part_values: partition_info *part_info= lex->part_info; if (! lex->is_partition_management()) { - if (part_info->part_type != LIST_PARTITION) + if (unlikely(part_info->part_type != LIST_PARTITION)) my_yyabort_error((ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), "LIST", "IN")); } @@ -5527,7 +5547,7 @@ opt_part_values: partition_element *elem= part_info->curr_part_elem; if (! lex->is_partition_management()) { - if (part_info->part_type != VERSIONING_PARTITION) + if (unlikely(part_info->part_type != VERSIONING_PARTITION)) my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME")); } else @@ -5542,10 +5562,8 @@ opt_part_values: elem->type(partition_element::CURRENT); DBUG_ASSERT(part_info->vers_info); part_info->vers_info->now_part= elem; - if (part_info->init_column_part(thd)) - { + if (unlikely(part_info->init_column_part(thd))) MYSQL_YYABORT; - } } | HISTORY_SYM { @@ -5554,7 +5572,7 @@ opt_part_values: partition_element *elem= part_info->curr_part_elem; if (! lex->is_partition_management()) { - if (part_info->part_type != VERSIONING_PARTITION) + if (unlikely(part_info->part_type != VERSIONING_PARTITION)) my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME")); } else @@ -5563,7 +5581,7 @@ opt_part_values: elem->id= UINT_MAX32; } DBUG_ASSERT(part_info->vers_info); - if (part_info->vers_info->now_part) + if (unlikely(part_info->vers_info->now_part)) { DBUG_ASSERT(Lex->create_last_non_select_table); DBUG_ASSERT(Lex->create_last_non_select_table->table_name.str); @@ -5572,10 +5590,8 @@ opt_part_values: table_name.str)); } elem->type(partition_element::HISTORY); - if (part_info->init_column_part(thd)) - { + if (unlikely(part_info->init_column_part(thd))) MYSQL_YYABORT; - } } | DEFAULT { @@ -5583,20 +5599,16 @@ opt_part_values: partition_info *part_info= lex->part_info; if (! lex->is_partition_management()) { - if (part_info->part_type != LIST_PARTITION) + if (unlikely(part_info->part_type != LIST_PARTITION)) my_yyabort_error((ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), "LIST", "DEFAULT")); } else part_info->part_type= LIST_PARTITION; - if (part_info->init_column_part(thd)) - { + if (unlikely(part_info->init_column_part(thd))) MYSQL_YYABORT; - } - if (part_info->add_max_value(thd)) - { + if (unlikely(part_info->add_max_value(thd))) MYSQL_YYABORT; - } } ; @@ -5605,8 +5617,8 @@ part_func_max: { partition_info *part_info= Lex->part_info; - if (part_info->num_columns && - part_info->num_columns != 1U) + if (unlikely(part_info->num_columns && + part_info->num_columns != 1U)) { part_info->print_debug("Kilroy II", NULL); thd->parse_error(ER_PARTITION_COLUMN_LIST_ERROR); @@ -5614,14 +5626,10 @@ part_func_max: } else part_info->num_columns= 1U; - if (part_info->init_column_part(thd)) - { + if (unlikely(part_info->init_column_part(thd))) MYSQL_YYABORT; - } - if (part_info->add_max_value(thd)) - { + if (unlikely(part_info->add_max_value(thd))) MYSQL_YYABORT; - } } | part_value_item {} ; @@ -5635,9 +5643,9 @@ part_values_in: if (part_info->num_columns != 1U) { - if (!lex->is_partition_management() || - part_info->num_columns == 0 || - part_info->num_columns > MAX_REF_PARTS) + if (unlikely(!lex->is_partition_management() || + part_info->num_columns == 0 || + part_info->num_columns > MAX_REF_PARTS)) { part_info->print_debug("Kilroy III", NULL); thd->parse_error(ER_PARTITION_COLUMN_LIST_ERROR); @@ -5650,16 +5658,14 @@ part_values_in: we ADD or REORGANIZE partitions. Also can only happen for LIST partitions. */ - if (part_info->reorganize_into_single_field_col_val(thd)) - { + if (unlikely(part_info->reorganize_into_single_field_col_val(thd))) MYSQL_YYABORT; - } } } | '(' part_value_list ')' { partition_info *part_info= Lex->part_info; - if (part_info->num_columns < 2U) + if (unlikely(part_info->num_columns < 2U)) { thd->parse_error(ER_ROW_SINGLE_PARTITION_FIELD_ERROR); MYSQL_YYABORT; @@ -5678,12 +5684,10 @@ part_value_item: partition_info *part_info= Lex->part_info; part_info->print_debug("( part_value_item", NULL); /* Initialisation code needed for each list of value expressions */ - if (!(part_info->part_type == LIST_PARTITION && - part_info->num_columns == 1U) && - part_info->init_column_part(thd)) - { + if (unlikely(!(part_info->part_type == LIST_PARTITION && + part_info->num_columns == 1U) && + part_info->init_column_part(thd))) MYSQL_YYABORT; - } } part_value_item_list {} ')' @@ -5692,7 +5696,7 @@ part_value_item: part_info->print_debug(") part_value_item", NULL); if (part_info->num_columns == 0) part_info->num_columns= part_info->curr_list_object; - if (part_info->num_columns != part_info->curr_list_object) + if (unlikely(part_info->num_columns != part_info->curr_list_object)) { /* All value items lists must be of equal length, in some cases @@ -5718,15 +5722,13 @@ part_value_expr_item: MAXVALUE_SYM { partition_info *part_info= Lex->part_info; - if (part_info->part_type == LIST_PARTITION) + if (unlikely(part_info->part_type == LIST_PARTITION)) { thd->parse_error(ER_MAXVALUE_IN_VALUES_IN); MYSQL_YYABORT; } - if (part_info->add_max_value(thd)) - { + if (unlikely(part_info->add_max_value(thd))) MYSQL_YYABORT; - } } | bit_expr { @@ -5734,15 +5736,13 @@ part_value_expr_item: partition_info *part_info= lex->part_info; Item *part_expr= $1; - if (!lex->safe_to_cache_query) + if (unlikely(!lex->safe_to_cache_query)) { thd->parse_error(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR); MYSQL_YYABORT; } - if (part_info->add_column_list_value(thd, part_expr)) - { + if (unlikely(part_info->add_column_list_value(thd, part_expr))) MYSQL_YYABORT; - } } ; @@ -5751,8 +5751,8 @@ opt_sub_partition: /* empty */ { partition_info *part_info= Lex->part_info; - if (part_info->num_subparts != 0 && - !part_info->use_default_subpartitions) + if (unlikely(part_info->num_subparts != 0 && + !part_info->use_default_subpartitions)) { /* We come here when we have defined subpartitions on the first @@ -5767,8 +5767,8 @@ opt_sub_partition: partition_info *part_info= Lex->part_info; if (part_info->num_subparts != 0) { - if (part_info->num_subparts != - part_info->count_curr_subparts) + if (unlikely(part_info->num_subparts != + part_info->count_curr_subparts)) { thd->parse_error(ER_PARTITION_WRONG_NO_SUBPART_ERROR); MYSQL_YYABORT; @@ -5776,7 +5776,7 @@ opt_sub_partition: } else if (part_info->count_curr_subparts > 0) { - if (part_info->partitions.elements > 1) + if (unlikely(part_info->partitions.elements > 1)) { thd->parse_error(ER_PARTITION_WRONG_NO_SUBPART_ERROR); MYSQL_YYABORT; @@ -5799,8 +5799,8 @@ sub_part_definition: partition_element *curr_part= part_info->current_partition; partition_element *sub_p_elem= new (thd->mem_root) partition_element(curr_part); - if (part_info->use_default_subpartitions && - part_info->partitions.elements >= 2) + if (unlikely(part_info->use_default_subpartitions && + part_info->partitions.elements >= 2)) { /* create table t1 (a int) @@ -5816,12 +5816,9 @@ sub_part_definition: thd->parse_error(ER_PARTITION_WRONG_NO_SUBPART_ERROR); MYSQL_YYABORT; } - if (!sub_p_elem || - curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root)) - { - mem_alloc_error(sizeof(partition_element)); + if (unlikely(!sub_p_elem) || + unlikely(curr_part->subpartitions.push_back(sub_p_elem, thd->mem_root))) MYSQL_YYABORT; - } sub_p_elem->id= curr_part->subpartitions.elements - 1; part_info->curr_part_elem= sub_p_elem; part_info->use_default_subpartitions= FALSE; @@ -5834,7 +5831,7 @@ sub_part_definition: sub_name: ident_or_text { - if (check_ident_length(&$1)) + if (unlikely(check_ident_length(&$1))) MYSQL_YYABORT; Lex->part_info->curr_part_elem->partition_name= $1.str; } @@ -5884,7 +5881,7 @@ opt_versioning_rotation: | INTERVAL_SYM expr interval opt_versioning_interval_start { partition_info *part_info= Lex->part_info; - if (part_info->vers_set_interval($2, $3, $4)) + if (unlikely(part_info->vers_set_interval($2, $3, $4))) { my_error(ER_PART_WRONG_VALUE, MYF(0), Lex->create_last_non_select_table->table_name.str, @@ -5895,7 +5892,7 @@ opt_versioning_rotation: | LIMIT ulonglong_num { partition_info *part_info= Lex->part_info; - if (part_info->vers_set_limit($2)) + if (unlikely(part_info->vers_set_limit($2))) { my_error(ER_PART_WRONG_VALUE, MYF(0), Lex->create_last_non_select_table->table_name.str, @@ -5915,7 +5912,7 @@ opt_versioning_interval_start: | STARTS_SYM ulong_num { /* only allowed from mysql_unpack_partition() */ - if (!Lex->part_info->table) + if (unlikely(!Lex->part_info->table)) { thd->parse_error(ER_SYNTAX_ERROR, $1.pos()); MYSQL_YYABORT; @@ -6155,7 +6152,7 @@ create_table_option: larger values. 65535 pages, 16kb each means to sample 1GB, which is impractical. If at some point this needs to be extended, then we can store the higher bits from stats_sample_pages in .frm too. */ - if ($3 == 0 || $3 > 0xffff) + if (unlikely($3 == 0 || $3 > 0xffff)) { thd->parse_error(); MYSQL_YYABORT; @@ -6260,31 +6257,33 @@ create_table_option: } | IDENT_sys equal TEXT_STRING_sys { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, true, &Lex->create_info.option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, true, + &Lex->create_info.option_list, + &Lex->option_list_last); } | IDENT_sys equal ident { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, false, &Lex->create_info.option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, false, + &Lex->create_info.option_list, + &Lex->option_list_last); } | IDENT_sys equal real_ulonglong_num { - new (thd->mem_root) - engine_option_value($1, $3, &Lex->create_info.option_list, - &Lex->option_list_last, thd->mem_root); + (void) new (thd->mem_root) + engine_option_value($1, $3, &Lex->create_info.option_list, + &Lex->option_list_last, thd->mem_root); } | IDENT_sys equal DEFAULT { - new (thd->mem_root) - engine_option_value($1, &Lex->create_info.option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, &Lex->create_info.option_list, + &Lex->option_list_last); } | SEQUENCE_SYM opt_equal choice { @@ -6302,7 +6301,7 @@ opt_versioning_option: versioning_option: WITH_SYSTEM_SYM VERSIONING_SYM { - if (Lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) + if (unlikely(Lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) { if (DBUG_EVALUATE_IF("sysvers_force", 0, 1)) { @@ -6321,7 +6320,7 @@ versioning_option: default_charset: opt_default charset opt_equal charset_name_or_default { - if (Lex->create_info.add_table_option_default_charset($4)) + if (unlikely(Lex->create_info.add_table_option_default_charset($4))) MYSQL_YYABORT; } ; @@ -6330,13 +6329,11 @@ default_collation: opt_default COLLATE_SYM opt_equal collation_name_or_default { HA_CREATE_INFO *cinfo= &Lex->create_info; - if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && - cinfo->default_table_charset && $4 && - !($4= merge_charset_and_collation(cinfo->default_table_charset, - $4))) - { + if (unlikely((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && + cinfo->default_table_charset && $4 && + !($4= merge_charset_and_collation(cinfo->default_table_charset, + $4)))) MYSQL_YYABORT; - } Lex->create_info.default_table_charset= $4; Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; @@ -6349,7 +6346,7 @@ storage_engines: plugin_ref plugin= ha_resolve_by_name(thd, &$1, thd->lex->create_info.tmp_table()); - if (plugin) + if (likely(plugin)) $$= plugin_hton(plugin); else { @@ -6368,7 +6365,7 @@ known_storage_engines: ident_or_text { plugin_ref plugin; - if ((plugin= ha_resolve_by_name(thd, &$1, false))) + if (likely((plugin= ha_resolve_by_name(thd, &$1, false)))) $$= plugin_hton(plugin); else my_yyabort_error((ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str)); @@ -6429,28 +6426,28 @@ key_def: key_or_index opt_if_not_exists opt_ident opt_USING_key_algorithm { Lex->option_list= NULL; - if (Lex->add_key(Key::MULTIPLE, &$3, $4, $2)) + if (unlikely(Lex->add_key(Key::MULTIPLE, &$3, $4, $2))) MYSQL_YYABORT; } '(' key_list ')' normal_key_options { } | key_or_index opt_if_not_exists ident TYPE_SYM btree_or_rtree { Lex->option_list= NULL; - if (Lex->add_key(Key::MULTIPLE, &$3, $5, $2)) + if (unlikely(Lex->add_key(Key::MULTIPLE, &$3, $5, $2))) MYSQL_YYABORT; } '(' key_list ')' normal_key_options { } | fulltext opt_key_or_index opt_if_not_exists opt_ident { Lex->option_list= NULL; - if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3)) + if (unlikely(Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))) MYSQL_YYABORT; } '(' key_list ')' fulltext_key_options { } | spatial opt_key_or_index opt_if_not_exists opt_ident { Lex->option_list= NULL; - if (Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3)) + if (unlikely(Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))) MYSQL_YYABORT; } '(' key_list ')' spatial_key_options { } @@ -6459,7 +6456,7 @@ key_def: opt_USING_key_algorithm { Lex->option_list= NULL; - if (Lex->add_key($2, $4.str ? &$4 : &$1, $5, $3)) + if (unlikely(Lex->add_key($2, $4.str ? &$4 : &$1, $5, $3))) MYSQL_YYABORT; } '(' key_list ')' normal_key_options { } @@ -6467,16 +6464,17 @@ key_def: TYPE_SYM btree_or_rtree { Lex->option_list= NULL; - if (Lex->add_key($2, $4.str ? &$4 : &$1, $6, $3)) + if (unlikely(Lex->add_key($2, $4.str ? &$4 : &$1, $6, $3))) MYSQL_YYABORT; } '(' key_list ')' normal_key_options { } | opt_constraint FOREIGN KEY_SYM opt_if_not_exists opt_ident { - if (Lex->check_add_key($4) || - !(Lex->last_key= (new (thd->mem_root) - Key(Key::MULTIPLE, $1.str ? &$1 : &$5, - HA_KEY_ALG_UNDEF, true, $4)))) + if (unlikely(Lex->check_add_key($4)) || + unlikely(!(Lex->last_key= (new (thd->mem_root) + Key(Key::MULTIPLE, + $1.str ? &$1 : &$5, + HA_KEY_ALG_UNDEF, true, $4))))) MYSQL_YYABORT; Lex->option_list= NULL; } @@ -6493,7 +6491,7 @@ key_def: lex->fk_update_opt, lex->fk_match_option, $4)); - if (key == NULL) + if (unlikely(key == NULL)) MYSQL_YYABORT; /* handle_if_exists_options() expectes the two keys in this order: @@ -6532,12 +6530,9 @@ opt_check_constraint: check_constraint: CHECK_SYM '(' expr ')' { - Virtual_column_info *v= - add_virtual_expression(thd, $3); - if (!v) - { + Virtual_column_info *v= add_virtual_expression(thd, $3); + if (unlikely(!v)) MYSQL_YYABORT; - } $$= v; } ; @@ -6557,11 +6552,11 @@ field_spec: LEX *lex=Lex; Create_field *f= new (thd->mem_root) Create_field(); - if (check_string_char_length(&$1, 0, NAME_CHAR_LEN, - system_charset_info, 1)) + if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN, + system_charset_info, 1))) my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str)); - if (!f) + if (unlikely(!f)) MYSQL_YYABORT; lex->init_last_field(f, &$1, NULL); @@ -6574,7 +6569,7 @@ field_spec: $$->check_constraint= $4; - if ($$->check(thd)) + if (unlikely($$->check(thd))) MYSQL_YYABORT; lex->alter_info.create_list.push_back($$, thd->mem_root); @@ -6638,7 +6633,7 @@ field_def: { case 1: p= &info.as_row.start; - if (*p) + if (unlikely(p->str)) { my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0), "START", field_name.str)); @@ -6647,7 +6642,7 @@ field_def: break; case 0: p= &info.as_row.end; - if (*p) + if (unlikely(p->str)) { my_yyabort_error((ER_VERS_DUPLICATE_ROW_START_END, MYF(0), "END", field_name.str)); @@ -6736,7 +6731,7 @@ parse_vcol_expr: expr { Virtual_column_info *v= add_virtual_expression(thd, $3); - if (!v) + if (unlikely(!v)) MYSQL_YYABORT; Lex->last_field->vcol_info= v; } @@ -6746,7 +6741,7 @@ parenthesized_expr: subselect { $$= new (thd->mem_root) Item_singlerow_subselect(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | expr @@ -6754,7 +6749,7 @@ parenthesized_expr: { $3->push_front($1, thd->mem_root); $$= new (thd->mem_root) Item_row(thd, *$3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -6764,10 +6759,8 @@ virtual_column_func: { Virtual_column_info *v= add_virtual_expression(thd, $2); - if (!v) - { + if (unlikely(!v)) MYSQL_YYABORT; - } $$= v; } ; @@ -6778,7 +6771,7 @@ column_default_expr: virtual_column_func | expr_or_literal { - if (!($$= add_virtual_expression(thd, $1))) + if (unlikely(!($$= add_virtual_expression(thd, $1)))) MYSQL_YYABORT; } ; @@ -6801,7 +6794,7 @@ field_type_numeric: { int err; ulonglong tmp_length= my_strtoll10($2.length(), NULL, &err); - if (err || tmp_length > PRECISION_FOR_DOUBLE) + if (unlikely(err || tmp_length > PRECISION_FOR_DOUBLE)) my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0), Lex->last_field->field_name.str)); if (tmp_length > PRECISION_FOR_FLOAT) @@ -7099,7 +7092,7 @@ attribute: | ON UPDATE_SYM NOW_SYM opt_default_time_precision { Item *item= new (thd->mem_root) Item_func_now_local(thd, $4); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; Lex->last_field->on_update= item; } @@ -7112,14 +7105,14 @@ attribute: } | COLLATE_SYM collation_name { - if (Lex->charset && !my_charset_same(Lex->charset,$2)) + if (unlikely(Lex->charset && !my_charset_same(Lex->charset,$2))) my_yyabort_error((ER_COLLATION_CHARSET_MISMATCH, MYF(0), $2->name,Lex->charset->csname)); Lex->last_field->charset= $2; } | COMPRESSED_SYM opt_compression_method { - if (Lex->last_field->set_compressed($2)) + if (unlikely(Lex->last_field->set_compressed($2))) MYSQL_YYABORT; } | serial_attribute @@ -7148,30 +7141,33 @@ serial_attribute: asrow_attribute | IDENT_sys equal TEXT_STRING_sys { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, true, &Lex->last_field->option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, true, + &Lex->last_field->option_list, + &Lex->option_list_last); } | IDENT_sys equal ident { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, false, &Lex->last_field->option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, false, + &Lex->last_field->option_list, + &Lex->option_list_last); } | IDENT_sys equal real_ulonglong_num { - new (thd->mem_root) - engine_option_value($1, $3, &Lex->last_field->option_list, - &Lex->option_list_last, thd->mem_root); + (void) new (thd->mem_root) + engine_option_value($1, $3, &Lex->last_field->option_list, + &Lex->option_list_last, thd->mem_root); } | IDENT_sys equal DEFAULT { - new (thd->mem_root) - engine_option_value($1, &Lex->last_field->option_list, &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, &Lex->last_field->option_list, + &Lex->option_list_last); } | with_or_without_system VERSIONING_SYM { @@ -7203,7 +7199,7 @@ type_with_opt_collate: if ($2) { - if (!(Lex->charset= merge_charset_and_collation(Lex->charset, $2))) + if (unlikely(!(Lex->charset= merge_charset_and_collation(Lex->charset, $2)))) MYSQL_YYABORT; } Lex->last_field->set_attributes($1, Lex->charset); @@ -7218,7 +7214,7 @@ charset: charset_name: ident_or_text { - if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0)))) + if (unlikely(!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))))) my_yyabort_error((ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str)); } | BINARY { $$= &my_charset_bin; } @@ -7237,8 +7233,9 @@ opt_load_data_charset: old_or_new_charset_name: ident_or_text { - if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) && - !($$=get_old_charset_by_name($1.str))) + if (unlikely(!($$=get_charset_by_csname($1.str, + MY_CS_PRIMARY,MYF(0))) && + !($$=get_old_charset_by_name($1.str)))) my_yyabort_error((ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str)); } | BINARY { $$= &my_charset_bin; } @@ -7252,7 +7249,7 @@ old_or_new_charset_name_or_default: collation_name: ident_or_text { - if (!($$= mysqld_collation_get_by_name($1.str))) + if (unlikely(!($$= mysqld_collation_get_by_name($1.str)))) MYSQL_YYABORT; } ; @@ -7277,7 +7274,7 @@ charset_or_alias: | ASCII_SYM { $$= &my_charset_latin1; } | UNICODE_SYM { - if (!($$= get_charset_by_csname("ucs2", MY_CS_PRIMARY,MYF(0)))) + if (unlikely(!($$= get_charset_by_csname("ucs2", MY_CS_PRIMARY,MYF(0))))) my_yyabort_error((ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2")); } ; @@ -7298,7 +7295,7 @@ opt_bin_mod: ws_nweights: '(' real_ulong_num { - if ($2 == 0) + if (unlikely($2 == 0)) { thd->parse_error(); MYSQL_YYABORT; @@ -7389,14 +7386,14 @@ ref_list: ref_list ',' ident { Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$3, 0); - if (key == NULL) + if (unlikely(key == NULL)) MYSQL_YYABORT; Lex->ref_list.push_back(key, thd->mem_root); } | ident { Key_part_spec *key= new (thd->mem_root) Key_part_spec(&$1, 0); - if (key == NULL) + if (unlikely(key == NULL)) MYSQL_YYABORT; LEX *lex= Lex; lex->ref_list.empty(); @@ -7557,30 +7554,31 @@ all_key_opt: { Lex->last_key->key_create_info.comment= $2; } | IDENT_sys equal TEXT_STRING_sys { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, true, &Lex->option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, true, &Lex->option_list, + &Lex->option_list_last); } | IDENT_sys equal ident { - if ($3.length > ENGINE_OPTION_MAX_LENGTH) + if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - new (thd->mem_root) - engine_option_value($1, $3, false, &Lex->option_list, - &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, $3, false, &Lex->option_list, + &Lex->option_list_last); } | IDENT_sys equal real_ulonglong_num { - new (thd->mem_root) - engine_option_value($1, $3, &Lex->option_list, - &Lex->option_list_last, thd->mem_root); + (void) new (thd->mem_root) + engine_option_value($1, $3, &Lex->option_list, + &Lex->option_list_last, thd->mem_root); } | IDENT_sys equal DEFAULT { - new (thd->mem_root) - engine_option_value($1, &Lex->option_list, &Lex->option_list_last); + (void) new (thd->mem_root) + engine_option_value($1, &Lex->option_list, + &Lex->option_list_last); } ; @@ -7597,7 +7595,7 @@ fulltext_key_opt: all_key_opt | WITH PARSER_SYM IDENT_sys { - if (plugin_is_ready(&$3, MYSQL_FTPARSER_PLUGIN)) + if (likely(plugin_is_ready(&$3, MYSQL_FTPARSER_PLUGIN))) Lex->last_key->key_create_info.parser_name= $3; else my_yyabort_error((ER_FUNCTION_NOT_DEFINED, MYF(0), $3.str)); @@ -7625,16 +7623,16 @@ key_part: ident { $$= new (thd->mem_root) Key_part_spec(&$1, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ident '(' NUM ')' { int key_part_len= atoi($3.str); - if (!key_part_len) + if (unlikely(!key_part_len)) my_yyabort_error((ER_KEY_PART_0, MYF(0), $1.str)); $$= new (thd->mem_root) Key_part_spec(&$1, (uint) key_part_len); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -7676,21 +7674,21 @@ alter: } alter_options TABLE_SYM table_ident opt_lock_wait_timeout { - if (!Lex->select_lex.add_table_to_list(thd, $5, NULL, - TL_OPTION_UPDATING, - TL_READ_NO_INSERT, - MDL_SHARED_UPGRADABLE)) + if (unlikely(!Lex->select_lex.add_table_to_list(thd, $5, NULL, + TL_OPTION_UPDATING, + TL_READ_NO_INSERT, + MDL_SHARED_UPGRADABLE))) MYSQL_YYABORT; Lex->select_lex.db= (Lex->select_lex.table_list.first)->db; Lex->create_last_non_select_table= Lex->last_table(); } alter_commands { - if (!Lex->m_sql_cmd) + if (likely(!Lex->m_sql_cmd)) { /* Create a generic ALTER TABLE statment. */ Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table(); - if (Lex->m_sql_cmd == NULL) + if (unlikely(Lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } } @@ -7704,13 +7702,14 @@ alter: LEX *lex=Lex; lex->sql_command=SQLCOM_ALTER_DB; lex->name= $3; - if (lex->name.str == NULL && lex->copy_db_to(&lex->name)) + if (lex->name.str == NULL && + unlikely(lex->copy_db_to(&lex->name))) MYSQL_YYABORT; } | ALTER DATABASE ident UPGRADE_SYM DATA_SYM DIRECTORY_SYM NAME_SYM { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "DATABASE")); lex->sql_command= SQLCOM_ALTER_DB_UPGRADE; lex->name= $3; @@ -7719,7 +7718,7 @@ alter: { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); lex->sp_chistics.init(); } @@ -7734,7 +7733,7 @@ alter: { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); lex->sp_chistics.init(); } @@ -7747,7 +7746,7 @@ alter: } | ALTER view_algorithm definer_opt opt_view_suid VIEW_SYM table_ident { - if (Lex->add_alter_view(thd, $2, $4, $6)) + if (unlikely(Lex->add_alter_view(thd, $2, $4, $6))) MYSQL_YYABORT; } view_list_opt AS view_select @@ -7759,7 +7758,7 @@ alter: with the ALTER EVENT below. */ { - if (Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5)) + if (unlikely(Lex->add_alter_view(thd, VIEW_ALGORITHM_INHERIT, $3, $5))) MYSQL_YYABORT; } view_list_opt AS view_select @@ -7774,7 +7773,7 @@ alter: Event_parse_data. */ - if (!(Lex->event_parse_data= Event_parse_data::new_instance(thd))) + if (unlikely(!(Lex->event_parse_data= Event_parse_data::new_instance(thd)))) MYSQL_YYABORT; Lex->event_parse_data->identifier= $5; @@ -7787,7 +7786,7 @@ alter: opt_ev_comment opt_ev_sql_stmt { - if (!($7 || $8 || $9 || $10 || $11)) + if (unlikely(!($7 || $8 || $9 || $10 || $11))) { thd->parse_error(); MYSQL_YYABORT; @@ -7845,18 +7844,19 @@ alter: table_ident { LEX *lex= Lex; - if (!(lex->create_info.seq_create_info= new (thd->mem_root) - sequence_definition()) || - !lex->select_lex.add_table_to_list(thd, $5, NULL, - TL_OPTION_SEQUENCE, - TL_WRITE, MDL_EXCLUSIVE)) + if (unlikely(!(lex->create_info.seq_create_info= + new (thd->mem_root) sequence_definition())) || + unlikely(!lex->select_lex.add_table_to_list(thd, $5, NULL, + TL_OPTION_SEQUENCE, + TL_WRITE, + MDL_EXCLUSIVE))) MYSQL_YYABORT; } sequence_defs { /* Create a generic ALTER SEQUENCE statment. */ Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_sequence($3); - if (Lex->m_sql_cmd == NULL) + if (unlikely(Lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -7898,7 +7898,7 @@ alter_commands: Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_discard_import_tablespace( Sql_cmd_discard_import_tablespace::DISCARD_TABLESPACE); - if (Lex->m_sql_cmd == NULL) + if (unlikely(Lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } | IMPORT TABLESPACE @@ -7906,7 +7906,7 @@ alter_commands: Lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_discard_import_tablespace( Sql_cmd_discard_import_tablespace::IMPORT_TABLESPACE); - if (Lex->m_sql_cmd == NULL) + if (unlikely(Lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } | alter_list @@ -7945,7 +7945,7 @@ alter_commands: DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_optimize_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } opt_no_write_to_binlog @@ -7958,7 +7958,7 @@ alter_commands: DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_analyze_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } | CHECK_SYM PARTITION_SYM all_or_alt_part_name_list @@ -7968,7 +7968,7 @@ alter_commands: DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_check_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } opt_mi_check_type @@ -7981,7 +7981,7 @@ alter_commands: DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_repair_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } opt_mi_repair_type @@ -7999,7 +7999,7 @@ alter_commands: DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_truncate_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } | reorg_partition_rule @@ -8009,21 +8009,19 @@ alter_commands: LEX *lex= thd->lex; lex->select_lex.db= $6->db; if (lex->select_lex.db.str == NULL && - lex->copy_db_to(&lex->select_lex.db)) - { + unlikely(lex->copy_db_to(&lex->select_lex.db))) MYSQL_YYABORT; - } lex->name= $6->table; lex->alter_info.partition_flags|= ALTER_PARTITION_EXCHANGE; - if (!lex->select_lex.add_table_to_list(thd, $6, NULL, - TL_OPTION_UPDATING, - TL_READ_NO_INSERT, - MDL_SHARED_NO_WRITE)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $6, NULL, + TL_OPTION_UPDATING, + TL_READ_NO_INSERT, + MDL_SHARED_NO_WRITE))) MYSQL_YYABORT; DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_alter_table_exchange_partition(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -8049,11 +8047,8 @@ add_partition_rule: { LEX *lex= Lex; lex->part_info= new (thd->mem_root) partition_info(); - if (!lex->part_info) - { - mem_alloc_error(sizeof(partition_info)); + if (unlikely(!lex->part_info)) MYSQL_YYABORT; - } lex->alter_info.partition_flags|= ALTER_PARTITION_ADD; DBUG_ASSERT(!Lex->create_info.if_not_exists()); lex->create_info.set($3); @@ -8081,11 +8076,8 @@ reorg_partition_rule: { LEX *lex= Lex; lex->part_info= new (thd->mem_root) partition_info(); - if (!lex->part_info) - { - mem_alloc_error(sizeof(partition_info)); + if (unlikely(!lex->part_info)) MYSQL_YYABORT; - } lex->no_write_to_binlog= $3; } reorg_parts_rule @@ -8115,12 +8107,9 @@ alt_part_name_list: alt_part_name_item: ident { - if (Lex->alter_info.partition_names.push_back($1.str, - thd->mem_root)) - { - mem_alloc_error(1); + if (unlikely(Lex->alter_info.partition_names.push_back($1.str, + thd->mem_root))) MYSQL_YYABORT; - } } ; @@ -8191,7 +8180,7 @@ alter_list_item: LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::COLUMN, $4.str, $3)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= ALTER_PARSER_DROP_COLUMN; @@ -8202,7 +8191,7 @@ alter_list_item: Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::CHECK_CONSTRAINT, $4.str, $3)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= ALTER_DROP_CHECK_CONSTRAINT; @@ -8212,7 +8201,7 @@ alter_list_item: LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::FOREIGN_KEY, $5.str, $4)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= ALTER_DROP_FOREIGN_KEY; @@ -8223,7 +8212,7 @@ alter_list_item: Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::KEY, primary_key_name, FALSE)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= ALTER_DROP_INDEX; @@ -8233,7 +8222,7 @@ alter_list_item: LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::KEY, $4.str, $3)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->alter_info.drop_list.push_back(ad, thd->mem_root); lex->alter_info.flags|= ALTER_DROP_INDEX; @@ -8252,12 +8241,13 @@ alter_list_item: } | ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr { - if (Lex->add_alter_list($4.str, $7, $3)) + if (unlikely(Lex->add_alter_list($4.str, $7, $3))) MYSQL_YYABORT; } | ALTER opt_column opt_if_exists_table_element field_ident DROP DEFAULT { - if (Lex->add_alter_list($4.str, (Virtual_column_info*) 0, $3)) + if (unlikely(Lex->add_alter_list($4.str, (Virtual_column_info*) 0, + $3))) MYSQL_YYABORT; } | RENAME opt_to table_ident @@ -8265,12 +8255,13 @@ alter_list_item: LEX *lex=Lex; lex->select_lex.db= $3->db; if (lex->select_lex.db.str == NULL && - lex->copy_db_to(&lex->select_lex.db)) + unlikely(lex->copy_db_to(&lex->select_lex.db))) { MYSQL_YYABORT; } - if (check_table_name($3->table.str,$3->table.length, FALSE) || - ($3->db.str && check_db_name((LEX_STRING*) &$3->db))) + if (unlikely(check_table_name($3->table.str,$3->table.length, + FALSE)) || + ($3->db.str && unlikely(check_db_name((LEX_STRING*) &$3->db)))) my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3->table.str)); lex->name= $3->table; lex->alter_info.flags|= ALTER_RENAME; @@ -8282,10 +8273,10 @@ alter_list_item: $4= thd->variables.collation_database; } $5= $5 ? $5 : $4; - if (!my_charset_same($4,$5)) + if (unlikely(!my_charset_same($4,$5))) my_yyabort_error((ER_COLLATION_CHARSET_MISMATCH, MYF(0), $5->name, $4->csname)); - if (Lex->create_info.add_alter_list_item_convert_to_charset($5)) + if (unlikely(Lex->create_info.add_alter_list_item_convert_to_charset($5))) MYSQL_YYABORT; Lex->alter_info.flags|= ALTER_OPTIONS; } @@ -8340,7 +8331,7 @@ alter_algorithm_option: } | ALGORITHM_SYM opt_equal ident { - if (Lex->alter_info.set_requested_algorithm(&$3)) + if (unlikely(Lex->alter_info.set_requested_algorithm(&$3))) my_yyabort_error((ER_UNKNOWN_ALTER_ALGORITHM, MYF(0), $3.str)); } ; @@ -8353,7 +8344,7 @@ alter_lock_option: } | LOCK_SYM opt_equal ident { - if (Lex->alter_info.set_requested_lock(&$3)) + if (unlikely(Lex->alter_info.set_requested_lock(&$3))) my_yyabort_error((ER_UNKNOWN_ALTER_LOCK, MYF(0), $3.str)); } ; @@ -8459,8 +8450,8 @@ start: LEX *lex= Lex; lex->sql_command= SQLCOM_BEGIN; /* READ ONLY and READ WRITE are mutually exclusive. */ - if (($3 & MYSQL_START_TRANS_OPT_READ_WRITE) && - ($3 & MYSQL_START_TRANS_OPT_READ_ONLY)) + if (unlikely(($3 & MYSQL_START_TRANS_OPT_READ_WRITE) && + ($3 & MYSQL_START_TRANS_OPT_READ_ONLY))) { thd->parse_error(); MYSQL_YYABORT; @@ -8528,10 +8519,10 @@ slave_until: | UNTIL_SYM slave_until_opts { LEX *lex=Lex; - if (((lex->mi.log_file_name || lex->mi.pos) && - (lex->mi.relay_log_name || lex->mi.relay_log_pos)) || - !((lex->mi.log_file_name && lex->mi.pos) || - (lex->mi.relay_log_name && lex->mi.relay_log_pos))) + if (unlikely(((lex->mi.log_file_name || lex->mi.pos) && + (lex->mi.relay_log_name || lex->mi.relay_log_pos)) || + !((lex->mi.log_file_name && lex->mi.pos) || + (lex->mi.relay_log_name && lex->mi.relay_log_pos)))) my_yyabort_error((ER_BAD_SLAVE_UNTIL_COND, MYF(0))); } | UNTIL_SYM MASTER_GTID_POS_SYM '=' TEXT_STRING_sys @@ -8586,7 +8577,7 @@ repair: LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_repair_table(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -8628,7 +8619,7 @@ analyze: LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_analyze_table(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -8663,7 +8654,7 @@ persistent_column_stat_spec: { LEX* lex= thd->lex; lex->column_list= new (thd->mem_root) List<LEX_STRING>; - if (lex->column_list == NULL) + if (unlikely(lex->column_list == NULL)) MYSQL_YYABORT; } table_column_list @@ -8676,7 +8667,7 @@ persistent_index_stat_spec: { LEX* lex= thd->lex; lex->index_list= new (thd->mem_root) List<LEX_STRING>; - if (lex->index_list == NULL) + if (unlikely(lex->index_list == NULL)) MYSQL_YYABORT; } table_index_list @@ -8750,11 +8741,11 @@ check: CHECK_SYM check_view_or_table { LEX* lex= thd->lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "CHECK")); DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_check_table(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -8799,7 +8790,7 @@ optimize: LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_optimize_table(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -8826,14 +8817,14 @@ rename: rename_list: user TO_SYM user { - if (Lex->users_list.push_back($1, thd->mem_root) || - Lex->users_list.push_back($3, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($1, thd->mem_root) || + Lex->users_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } | rename_list ',' user TO_SYM user { - if (Lex->users_list.push_back($3, thd->mem_root) || - Lex->users_list.push_back($5, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($3, thd->mem_root) || + Lex->users_list.push_back($5, thd->mem_root))) MYSQL_YYABORT; } ; @@ -8848,10 +8839,12 @@ table_to_table: { LEX *lex=Lex; SELECT_LEX *sl= lex->current_select; - if (!sl->add_table_to_list(thd, $1,NULL,TL_OPTION_UPDATING, - TL_IGNORE, MDL_EXCLUSIVE) || - !sl->add_table_to_list(thd, $4, NULL, TL_OPTION_UPDATING, - TL_IGNORE, MDL_EXCLUSIVE)) + if (unlikely(!sl->add_table_to_list(thd, $1,NULL, + TL_OPTION_UPDATING, + TL_IGNORE, MDL_EXCLUSIVE)) || + unlikely(!sl->add_table_to_list(thd, $4, NULL, + TL_OPTION_UPDATING, + TL_IGNORE, MDL_EXCLUSIVE))) MYSQL_YYABORT; } ; @@ -8882,9 +8875,10 @@ keycache_list: assign_to_keycache: table_ident cache_keys_spec { - if (!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, - MDL_SHARED_READ, - Select->pop_index_hints())) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, + MDL_SHARED_READ, + Select-> + pop_index_hints()))) MYSQL_YYABORT; } ; @@ -8892,9 +8886,10 @@ assign_to_keycache: assign_to_keycache_parts: table_ident adm_partition cache_keys_spec { - if (!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, - MDL_SHARED_READ, - Select->pop_index_hints())) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, + MDL_SHARED_READ, + Select-> + pop_index_hints()))) MYSQL_YYABORT; } ; @@ -8928,9 +8923,10 @@ preload_list: preload_keys: table_ident cache_keys_spec opt_ignore_leaves { - if (!Select->add_table_to_list(thd, $1, NULL, $3, TL_READ, - MDL_SHARED_READ, - Select->pop_index_hints())) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, $3, TL_READ, + MDL_SHARED_READ, + Select-> + pop_index_hints()))) MYSQL_YYABORT; } ; @@ -8938,9 +8934,10 @@ preload_keys: preload_keys_parts: table_ident adm_partition cache_keys_spec opt_ignore_leaves { - if (!Select->add_table_to_list(thd, $1, NULL, $4, TL_READ, - MDL_SHARED_READ, - Select->pop_index_hints())) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, $4, TL_READ, + MDL_SHARED_READ, + Select-> + pop_index_hints()))) MYSQL_YYABORT; } ; @@ -9230,7 +9227,8 @@ select_options: /* empty*/ | select_option_list { - if (Select->options & SELECT_DISTINCT && Select->options & SELECT_ALL) + if (unlikely((Select->options & SELECT_DISTINCT) && + (Select->options & SELECT_ALL))) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT")); } ; @@ -9308,11 +9306,11 @@ select_option: Allow this flag only on the first top-level SELECT statement, if SQL_CACHE wasn't specified, and only once per query. */ - if (Lex->current_select != &Lex->select_lex) + if (unlikely(Lex->current_select != &Lex->select_lex)) my_yyabort_error((ER_CANT_USE_OPTION_HERE, MYF(0), "SQL_NO_CACHE")); - if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE) + if (unlikely(Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "SQL_CACHE", "SQL_NO_CACHE")); - if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE) + if (unlikely(Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "SQL_NO_CACHE")); Lex->safe_to_cache_query=0; @@ -9325,11 +9323,11 @@ select_option: Allow this flag only on the first top-level SELECT statement, if SQL_NO_CACHE wasn't specified, and only once per query. */ - if (Lex->current_select != &Lex->select_lex) + if (unlikely(Lex->current_select != &Lex->select_lex)) my_yyabort_error((ER_CANT_USE_OPTION_HERE, MYF(0), "SQL_CACHE")); - if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE) + if (unlikely(Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "SQL_NO_CACHE", "SQL_CACHE")); - if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE) + if (unlikely(Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "SQL_CACHE")); Lex->safe_to_cache_query=1; @@ -9365,9 +9363,9 @@ select_item_list: Item *item= new (thd->mem_root) Item_field(thd, &thd->lex->current_select->context, NULL, NULL, &star_clex_str); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; - if (add_item_to_list(thd, item)) + if (unlikely(add_item_to_list(thd, item))) MYSQL_YYABORT; (thd->lex->current_select->with_wild)++; } @@ -9376,19 +9374,19 @@ select_item_list: select_item: remember_name select_sublist_qualified_asterisk remember_end { - if (add_item_to_list(thd, $2)) + if (unlikely(add_item_to_list(thd, $2))) MYSQL_YYABORT; } | remember_name expr remember_end select_alias { DBUG_ASSERT($1 < $3); - if (add_item_to_list(thd, $2)) + if (unlikely(add_item_to_list(thd, $2))) MYSQL_YYABORT; if ($4.str) { - if (Lex->sql_command == SQLCOM_CREATE_VIEW && - check_column_name($4.str)) + if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW && + check_column_name($4.str))) my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), $4.str)); $2->is_autogenerated_name= FALSE; $2->set_name(thd, $4.str, $4.length, system_charset_info); @@ -9492,7 +9490,7 @@ expr: { /* X OR Y */ $$= new (thd->mem_root) Item_cond_or(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } } @@ -9500,7 +9498,7 @@ expr: { /* XOR is a proprietary extension */ $$= new (thd->mem_root) Item_func_xor(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | expr and expr %prec AND_SYM @@ -9542,50 +9540,50 @@ expr: { /* X AND Y */ $$= new (thd->mem_root) Item_cond_and(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } } | NOT_SYM expr %prec NOT_SYM { $$= negate_expression(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS TRUE_SYM %prec IS { $$= new (thd->mem_root) Item_func_istrue(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS not TRUE_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnottrue(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS FALSE_SYM %prec IS { $$= new (thd->mem_root) Item_func_isfalse(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS not FALSE_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnotfalse(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS UNKNOWN_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnull(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS not UNKNOWN_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnotnull(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri @@ -9595,31 +9593,31 @@ bool_pri: bool_pri IS NULL_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnull(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri IS not NULL_SYM %prec IS { $$= new (thd->mem_root) Item_func_isnotnull(thd, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM { $$= new (thd->mem_root) Item_func_equal(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri comp_op predicate %prec '=' { $$= (*$2)(0)->create(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bool_pri comp_op all_or_any '(' subselect ')' %prec '=' { $$= all_any_subquery_creator(thd, $1, $2, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | predicate @@ -9629,22 +9627,22 @@ predicate: bit_expr IN_SYM '(' subselect ')' { $$= new (thd->mem_root) Item_in_subselect(thd, $1, $4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not IN_SYM '(' subselect ')' { Item *item= new (thd->mem_root) Item_in_subselect(thd, $1, $5); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= negate_expression(thd, item); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr IN_SYM '(' expr ')' { $$= handle_sql2003_note184_exception(thd, $1, true, $4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr IN_SYM '(' expr ',' expr_list ')' @@ -9652,13 +9650,13 @@ predicate: $6->push_front($4, thd->mem_root); $6->push_front($1, thd->mem_root); $$= new (thd->mem_root) Item_func_in(thd, *$6); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not IN_SYM '(' expr ')' { $$= handle_sql2003_note184_exception(thd, $1, false, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not IN_SYM '(' expr ',' expr_list ')' @@ -9666,21 +9664,21 @@ predicate: $7->push_front($5, thd->mem_root); $7->push_front($1, thd->mem_root); Item_func_in *item= new (thd->mem_root) Item_func_in(thd, *$7); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= item->neg_transformer(thd); } | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate { $$= new (thd->mem_root) Item_func_between(thd, $1, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate { Item_func_between *item; item= new (thd->mem_root) Item_func_between(thd, $1, $4, $6); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= item->neg_transformer(thd); } @@ -9688,40 +9686,40 @@ predicate: { Item *item1= new (thd->mem_root) Item_func_soundex(thd, $1); Item *item4= new (thd->mem_root) Item_func_soundex(thd, $4); - if ((item1 == NULL) || (item4 == NULL)) + if (unlikely(item1 == NULL) || unlikely(item4 == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_func_eq(thd, item1, item4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr LIKE simple_expr opt_escape { $$= new (thd->mem_root) Item_func_like(thd, $1, $3, $4, Lex->escape_used); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not LIKE simple_expr opt_escape { Item *item= new (thd->mem_root) Item_func_like(thd, $1, $4, $5, Lex->escape_used); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= item->neg_transformer(thd); } | bit_expr REGEXP bit_expr { $$= new (thd->mem_root) Item_func_regex(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr not REGEXP bit_expr { Item *item= new (thd->mem_root) Item_func_regex(thd, $1, $4); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= negate_expression(thd, item); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr @@ -9731,85 +9729,85 @@ bit_expr: bit_expr '|' bit_expr %prec '|' { $$= new (thd->mem_root) Item_func_bit_or(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '&' bit_expr %prec '&' { $$= new (thd->mem_root) Item_func_bit_and(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT { $$= new (thd->mem_root) Item_func_shift_left(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT { $$= new (thd->mem_root) Item_func_shift_right(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '+' bit_expr %prec '+' { $$= new (thd->mem_root) Item_func_plus(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '-' bit_expr %prec '-' { $$= new (thd->mem_root) Item_func_minus(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '+' INTERVAL_SYM expr interval %prec '+' { $$= new (thd->mem_root) Item_date_add_interval(thd, $1, $4, $5, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '-' INTERVAL_SYM expr interval %prec '-' { $$= new (thd->mem_root) Item_date_add_interval(thd, $1, $4, $5, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '*' bit_expr %prec '*' { $$= new (thd->mem_root) Item_func_mul(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '/' bit_expr %prec '/' { $$= new (thd->mem_root) Item_func_div(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '%' bit_expr %prec '%' { $$= new (thd->mem_root) Item_func_mod(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr DIV_SYM bit_expr %prec DIV_SYM { $$= new (thd->mem_root) Item_func_int_div(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr MOD_SYM bit_expr %prec MOD_SYM { $$= new (thd->mem_root) Item_func_mod(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | bit_expr '^' bit_expr { $$= new (thd->mem_root) Item_func_bit_xor(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | simple_expr @@ -9899,7 +9897,7 @@ dyncall_create_element: LEX *lex= Lex; $$= (DYNCALL_CREATE_DEF *) alloc_root(thd->mem_root, sizeof(DYNCALL_CREATE_DEF)); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; $$->key= $1; $$->value= $3; @@ -9919,7 +9917,7 @@ dyncall_create_list: dyncall_create_element { $$= new (thd->mem_root) List<DYNCALL_CREATE_DEF>; - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; $$->push_back($1, thd->mem_root); } @@ -9985,18 +9983,18 @@ column_default_non_parenthesized_expr: { $5->push_front($3, thd->mem_root); $$= new (thd->mem_root) Item_row(thd, *$5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | EXISTS '(' subselect ')' { $$= new (thd->mem_root) Item_exists_subselect(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | '{' ident expr '}' { - if (!($$= $3->make_odbc_literal(thd, &$2))) + if (unlikely(!($$= $3->make_odbc_literal(thd, &$2)))) MYSQL_YYABORT; } | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')' @@ -10004,46 +10002,46 @@ column_default_non_parenthesized_expr: $2->push_front($5, thd->mem_root); Item_func_match *i1= new (thd->mem_root) Item_func_match(thd, *$2, $6); - if (i1 == NULL) + if (unlikely(i1 == NULL)) MYSQL_YYABORT; Select->add_ftfunc_to_list(thd, i1); $$= i1; } | CAST_SYM '(' expr AS cast_type ')' { - if (!($$= $5.create_typecast_item(thd, $3, Lex->charset))) + if (unlikely(!($$= $5.create_typecast_item(thd, $3, Lex->charset)))) MYSQL_YYABORT; } | CASE_SYM when_list_opt_else END { - if (!($$= new(thd->mem_root) Item_func_case_searched(thd, *$2))) + if (unlikely(!($$= new(thd->mem_root) Item_func_case_searched(thd, *$2)))) MYSQL_YYABORT; } | CASE_SYM expr when_list_opt_else END { $3->push_front($2, thd->mem_root); - if (!($$= new (thd->mem_root) Item_func_case_simple(thd, *$3))) + if (unlikely(!($$= new (thd->mem_root) Item_func_case_simple(thd, *$3)))) MYSQL_YYABORT; } | CONVERT_SYM '(' expr ',' cast_type ')' { - if (!($$= $5.create_typecast_item(thd, $3, Lex->charset))) + if (unlikely(!($$= $5.create_typecast_item(thd, $3, Lex->charset)))) MYSQL_YYABORT; } | CONVERT_SYM '(' expr USING charset_name ')' { $$= new (thd->mem_root) Item_func_conv_charset(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DEFAULT '(' simple_ident ')' { Item_splocal *il= $3->get_item_splocal(); - if (il) + if (unlikely(il)) my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str)); $$= new (thd->mem_root) Item_default_value(thd, Lex->current_context(), $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->default_used= TRUE; } @@ -10051,42 +10049,42 @@ column_default_non_parenthesized_expr: { $$= new (thd->mem_root) Item_insert_value(thd, Lex->current_context(), $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | NEXT_SYM VALUE_SYM FOR_SYM table_ident { - if (!($$= Lex->create_item_func_nextval(thd, $4))) + if (unlikely(!($$= Lex->create_item_func_nextval(thd, $4)))) MYSQL_YYABORT; } | NEXTVAL_SYM '(' table_ident ')' { - if (!($$= Lex->create_item_func_nextval(thd, $3))) + if (unlikely(!($$= Lex->create_item_func_nextval(thd, $3)))) MYSQL_YYABORT; } | PREVIOUS_SYM VALUE_SYM FOR_SYM table_ident { - if (!($$= Lex->create_item_func_lastval(thd, $4))) + if (unlikely(!($$= Lex->create_item_func_lastval(thd, $4)))) MYSQL_YYABORT; } | LASTVAL_SYM '(' table_ident ')' { - if (!($$= Lex->create_item_func_lastval(thd, $3))) + if (unlikely(!($$= Lex->create_item_func_lastval(thd, $3)))) MYSQL_YYABORT; } | SETVAL_SYM '(' table_ident ',' longlong_num ')' { - if (!($$= Lex->create_item_func_setval(thd, $3, $5, 0, 1))) + if (unlikely(!($$= Lex->create_item_func_setval(thd, $3, $5, 0, 1)))) MYSQL_YYABORT; } | SETVAL_SYM '(' table_ident ',' longlong_num ',' bool ')' { - if (!($$= Lex->create_item_func_setval(thd, $3, $5, 0, $7))) + if (unlikely(!($$= Lex->create_item_func_setval(thd, $3, $5, 0, $7)))) MYSQL_YYABORT; } | SETVAL_SYM '(' table_ident ',' longlong_num ',' bool ',' ulonglong_num ')' { - if (!($$= Lex->create_item_func_setval(thd, $3, $5, $9, $7))) + if (unlikely(!($$= Lex->create_item_func_setval(thd, $3, $5, $9, $7)))) MYSQL_YYABORT; } ; @@ -10095,20 +10093,20 @@ simple_expr: column_default_non_parenthesized_expr | simple_expr COLLATE_SYM collation_name %prec NEG { - if (!($$= new (thd->mem_root) Item_func_set_collation(thd, $1, $3))) + if (unlikely(!($$= new (thd->mem_root) Item_func_set_collation(thd, $1, $3)))) MYSQL_YYABORT; } | '(' parenthesized_expr ')' { $$= $2; } | BINARY simple_expr %prec NEG { Type_cast_attributes at(&my_charset_bin); - if (!($$= type_handler_long_blob.create_typecast_item(thd, $2, at))) + if (unlikely(!($$= type_handler_long_blob.create_typecast_item(thd, $2, at)))) MYSQL_YYABORT; } | simple_expr OR_OR_SYM simple_expr { $$= new (thd->mem_root) Item_func_concat(thd, $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | '+' simple_expr %prec NEG @@ -10118,26 +10116,26 @@ simple_expr: | '-' simple_expr %prec NEG { $$= $2->neg(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | '~' simple_expr %prec NEG { $$= new (thd->mem_root) Item_func_bit_neg(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | not2 simple_expr %prec NEG { $$= negate_expression(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM /* we cannot put interval before - */ { $$= new (thd->mem_root) Item_date_add_interval(thd, $5, $2, $3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -10147,13 +10145,13 @@ function_call_keyword_timestamp: { $$= new (thd->mem_root) Item_datetime_typecast(thd, $3, AUTO_SEC_PART_DIGITS); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | TIMESTAMP '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_add_time(thd, $3, $5, 1, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -10167,20 +10165,20 @@ function_call_keyword: CHAR_SYM '(' expr_list ')' { $$= new (thd->mem_root) Item_func_char(thd, *$3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CHAR_SYM '(' expr_list USING charset_name ')' { $$= new (thd->mem_root) Item_func_char(thd, *$3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CURRENT_USER optional_braces { $$= new (thd->mem_root) Item_func_current_user(thd, Lex->current_context()); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); Lex->safe_to_cache_query= 0; @@ -10189,7 +10187,7 @@ function_call_keyword: { $$= new (thd->mem_root) Item_func_current_role(thd, Lex->current_context()); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); Lex->safe_to_cache_query= 0; @@ -10197,39 +10195,40 @@ function_call_keyword: | DATE_SYM '(' expr ')' { $$= new (thd->mem_root) Item_date_typecast(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DAY_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_dayofmonth(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | HOUR_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_hour(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | INSERT '(' expr ',' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_insert(thd, $3, $5, $7, $9); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM { List<Item> *list= new (thd->mem_root) List<Item>; - if (list == NULL) + if (unlikely(list == NULL)) + MYSQL_YYABORT; + if (unlikely(list->push_front($5, thd->mem_root)) || + unlikely(list->push_front($3, thd->mem_root))) MYSQL_YYABORT; - list->push_front($5, thd->mem_root); - list->push_front($3, thd->mem_root); Item_row *item= new (thd->mem_root) Item_row(thd, *list); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_func_interval(thd, item); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM @@ -10237,47 +10236,47 @@ function_call_keyword: $7->push_front($5, thd->mem_root); $7->push_front($3, thd->mem_root); Item_row *item= new (thd->mem_root) Item_row(thd, *$7); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_func_interval(thd, item); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LEFT '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_left(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MINUTE_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_minute(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MONTH_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_month(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | RIGHT '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_right(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SECOND_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_second(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | TIME_SYM '(' expr ')' { $$= new (thd->mem_root) Item_time_typecast(thd, $3, AUTO_SEC_PART_DIGITS); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | function_call_keyword_timestamp @@ -10286,13 +10285,13 @@ function_call_keyword: } | TRIM '(' trim_operands ')' { - if (!($$= $3.make_item_func_trim(thd))) + if (unlikely(!($$= $3.make_item_func_trim(thd)))) MYSQL_YYABORT; } | USER_SYM '(' ')' { $$= new (thd->mem_root) Item_func_user(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); Lex->safe_to_cache_query=0; @@ -10300,7 +10299,7 @@ function_call_keyword: | YEAR_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_year(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -10322,26 +10321,26 @@ function_call_nonkeyword: { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CURDATE optional_braces { $$= new (thd->mem_root) Item_func_curdate_local(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | CURTIME opt_time_precision { $$= new (thd->mem_root) Item_func_curtime_local(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } @@ -10349,90 +10348,90 @@ function_call_nonkeyword: %prec INTERVAL_SYM { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DATE_FORMAT_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DECODE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_decode(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new (thd->mem_root) Item_extract(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | GET_FORMAT '(' date_time_type ',' expr ')' { $$= new (thd->mem_root) Item_func_get_format(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | NOW_SYM opt_time_precision { $$= new (thd->mem_root) Item_func_now_local(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | POSITION_SYM '(' bit_expr IN_SYM expr ')' { $$= new (thd->mem_root) Item_func_locate(thd, $5, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ',' expr ')' { - if (!($$= Lex->make_item_func_substr(thd, $3, $5, $7))) + if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7)))) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ')' { - if (!($$= Lex->make_item_func_substr(thd, $3, $5))) + if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5)))) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr FOR_SYM expr ')' { - if (!($$= Lex->make_item_func_substr(thd, $3, $5, $7))) + if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5, $7)))) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr ')' { - if (!($$= Lex->make_item_func_substr(thd, $3, $5))) + if (unlikely(!($$= Lex->make_item_func_substr(thd, $3, $5)))) MYSQL_YYABORT; } | SYSDATE opt_time_precision @@ -10449,45 +10448,45 @@ function_call_nonkeyword: $$= new (thd->mem_root) Item_func_sysdate_local(thd, $2); else $$= new (thd->mem_root) Item_func_now_local(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $7, $5, $3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_timestamp_diff(thd, $5, $7, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | TRIM_ORACLE '(' trim_operands ')' { - if (!($$= $3.make_item_func_trim_oracle(thd))) + if (unlikely(!($$= $3.make_item_func_trim_oracle(thd)))) MYSQL_YYABORT; } | UTC_DATE_SYM optional_braces { $$= new (thd->mem_root) Item_func_curdate_utc(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | UTC_TIME_SYM opt_time_precision { $$= new (thd->mem_root) Item_func_curtime_utc(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | UTC_TIMESTAMP_SYM opt_time_precision { $$= new (thd->mem_root) Item_func_now_utc(thd, $2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } @@ -10495,28 +10494,28 @@ function_call_nonkeyword: COLUMN_ADD_SYM '(' expr ',' dyncall_create_list ')' { $$= create_func_dyncol_add(thd, $3, *$5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COLUMN_DELETE_SYM '(' expr ',' expr_list ')' { $$= create_func_dyncol_delete(thd, $3, *$5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COLUMN_CHECK_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_dyncol_check(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COLUMN_CREATE_SYM '(' dyncall_create_list ')' { $$= create_func_dyncol_create(thd, *$3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | @@ -10526,7 +10525,7 @@ function_call_nonkeyword: $$= create_func_dyncol_get(thd, $3, $5, $7.type_handler(), $7.length(), $7.dec(), lex->charset); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -10540,50 +10539,50 @@ function_call_conflict: ASCII_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_ascii(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CHARSET '(' expr ')' { $$= new (thd->mem_root) Item_func_charset(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COALESCE '(' expr_list ')' { $$= new (thd->mem_root) Item_func_coalesce(thd, *$3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COLLATION_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_collation(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DATABASE '(' ')' { $$= new (thd->mem_root) Item_func_database(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | IF_SYM '(' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_if(thd, $3, $5, $7); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | FORMAT_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_format(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | FORMAT_SYM '(' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_format(thd, $3, $5, $7); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } /* LAST_VALUE here conflicts with the definition for window functions. @@ -10592,75 +10591,75 @@ function_call_conflict: | LAST_VALUE '(' expr ')' { List<Item> *list= new (thd->mem_root) List<Item>; - if (list == NULL) + if (unlikely(list == NULL)) MYSQL_YYABORT; list->push_back($3, thd->mem_root); $$= new (thd->mem_root) Item_func_last_value(thd, *list); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LAST_VALUE '(' expr_list ',' expr ')' { $3->push_back($5, thd->mem_root); $$= new (thd->mem_root) Item_func_last_value(thd, *$3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MICROSECOND_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_microsecond(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MOD_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_mod(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | OLD_PASSWORD_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_password(thd, $3, Item_func_password::OLD); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | PASSWORD_SYM '(' expr ')' { Item* i1; i1= new (thd->mem_root) Item_func_password(thd, $3); - if (i1 == NULL) + if (unlikely(i1 == NULL)) MYSQL_YYABORT; $$= i1; } | QUARTER_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_quarter(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | REPEAT_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_repeat(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | REPLACE '(' expr ',' expr ',' expr ')' { - if (!($$= Lex->make_item_func_replace(thd, $3, $5, $7))) + if (unlikely(!($$= Lex->make_item_func_replace(thd, $3, $5, $7)))) MYSQL_YYABORT; } | REVERSE_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_reverse(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ROW_COUNT_SYM '(' ')' { $$= new (thd->mem_root) Item_func_row_count(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); Lex->safe_to_cache_query= 0; @@ -10668,25 +10667,25 @@ function_call_conflict: | TRUNCATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_round(thd, $3, $5, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEEK_SYM '(' expr ')' { $$= new (thd->mem_root) Item_func_week(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEEK_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_week(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr opt_ws_levels ')' { $$= new (thd->mem_root) Item_func_weight_string(thd, $3, 0, 0, $4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')' @@ -10694,26 +10693,26 @@ function_call_conflict: $$= new (thd->mem_root) Item_func_weight_string(thd, $3, 0, $6, $7 | MY_STRXFRM_PAD_WITH_SPACE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')' { Item *item= new (thd->mem_root) Item_char_typecast(thd, $3, $6, &my_charset_bin); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_func_weight_string(thd, item, 0, $6, MY_STRXFRM_PAD_WITH_SPACE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr ',' ulong_num ',' ulong_num ',' ulong_num ')' { $$= new (thd->mem_root) Item_func_weight_string(thd, $3, $5, $7, $9); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | geometry_function @@ -10721,7 +10720,7 @@ function_call_conflict: #ifdef HAVE_SPATIAL $$= $1; /* $1 may be NULL, GEOM_NEW not tested for out of memory */ - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; #else my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name, @@ -10809,7 +10808,7 @@ function_call_generic: (udf= find_udf($1.str, $1.length)) && udf->type == UDFTYPE_AGGREGATE) { - if (lex->current_select->inc_in_sum_expr()) + if (unlikely(lex->current_select->inc_in_sum_expr())) { thd->parse_error(); MYSQL_YYABORT; @@ -10824,10 +10823,8 @@ function_call_generic: Create_func *builder; Item *item= NULL; - if (check_routine_name(&$1)) - { + if (unlikely(check_routine_name(&$1))) MYSQL_YYABORT; - } /* Implementation note: @@ -10867,14 +10864,12 @@ function_call_generic: } } - if (! ($$= item)) - { + if (unlikely(! ($$= item))) MYSQL_YYABORT; - } } | ident_cli '.' ident_cli '(' opt_expr_list ')' { - if (!($$= Lex->make_item_func_call_generic(thd, &$1, &$3, $5))) + if (unlikely(!($$= Lex->make_item_func_call_generic(thd, &$1, &$3, $5)))) MYSQL_YYABORT; } ; @@ -10905,7 +10900,7 @@ udf_expr_list: udf_expr { $$= new (thd->mem_root) List<Item>; - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; $$->push_back($1, thd->mem_root); } @@ -10947,46 +10942,46 @@ sum_expr: AVG_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_avg(thd, $3, FALSE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | AVG_SYM '(' DISTINCT in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_avg(thd, $4, TRUE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | BIT_AND '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_and(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | BIT_OR '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_or(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | BIT_XOR '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_xor(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COUNT_SYM '(' opt_all '*' ')' { Item *item= new (thd->mem_root) Item_int(thd, (int32) 0L, 1); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_sum_count(thd, item); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COUNT_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_count(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | COUNT_SYM '(' DISTINCT @@ -10996,13 +10991,13 @@ sum_expr: ')' { $$= new (thd->mem_root) Item_sum_count(thd, *$5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MIN_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_min(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } /* @@ -11013,55 +11008,55 @@ sum_expr: | MIN_SYM '(' DISTINCT in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_min(thd, $4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MAX_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_max(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | MAX_SYM '(' DISTINCT in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_max(thd, $4); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | STD_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_std(thd, $3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | VARIANCE_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_variance(thd, $3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | STDDEV_SAMP_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_std(thd, $3, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | VAR_SAMP_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_variance(thd, $3, 1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SUM_SYM '(' in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_sum(thd, $3, FALSE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SUM_SYM '(' DISTINCT in_sum_expr ')' { $$= new (thd->mem_root) Item_sum_sum(thd, $4, TRUE); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | GROUP_CONCAT_SYM '(' opt_distinct @@ -11078,7 +11073,7 @@ sum_expr: sel->gorder_list, $7, $8, sel->select_limit, sel->offset_limit); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; sel->select_limit= NULL; sel->offset_limit= NULL; @@ -11092,7 +11087,7 @@ window_func_expr: window_func OVER_SYM window_name { $$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; if (Select->add_window_func((Item_window_func *) $$)) MYSQL_YYABORT; @@ -11108,9 +11103,9 @@ window_func_expr: MYSQL_YYABORT; $$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, thd->lex->win_spec); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; - if (Select->add_window_func((Item_window_func *) $$)) + if (unlikely(Select->add_window_func((Item_window_func *) $$))) MYSQL_YYABORT; } ; @@ -11128,63 +11123,63 @@ simple_window_func: ROW_NUMBER_SYM '(' ')' { $$= new (thd->mem_root) Item_sum_row_number(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | RANK_SYM '(' ')' { $$= new (thd->mem_root) Item_sum_rank(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DENSE_RANK_SYM '(' ')' { $$= new (thd->mem_root) Item_sum_dense_rank(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | PERCENT_RANK_SYM '(' ')' { $$= new (thd->mem_root) Item_sum_percent_rank(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CUME_DIST_SYM '(' ')' { $$= new (thd->mem_root) Item_sum_cume_dist(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | NTILE_SYM '(' expr ')' { $$= new (thd->mem_root) Item_sum_ntile(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | FIRST_VALUE_SYM '(' expr ')' { $$= new (thd->mem_root) Item_sum_first_value(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LAST_VALUE '(' expr ')' { $$= new (thd->mem_root) Item_sum_last_value(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | NTH_VALUE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_sum_nth_value(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | @@ -11192,17 +11187,17 @@ simple_window_func: { /* No second argument defaults to 1. */ Item* item_offset= new (thd->mem_root) Item_uint(thd, 1); - if (item_offset == NULL) + if (unlikely(item_offset == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_sum_lead(thd, $3, item_offset); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LEAD_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_sum_lead(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | @@ -11210,17 +11205,17 @@ simple_window_func: { /* No second argument defaults to 1. */ Item* item_offset= new (thd->mem_root) Item_uint(thd, 1); - if (item_offset == NULL) + if (unlikely(item_offset == NULL)) MYSQL_YYABORT; $$= new (thd->mem_root) Item_sum_lag(thd, $3, item_offset); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LAG_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_sum_lag(thd, $3, $5); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -11239,9 +11234,9 @@ inverse_distribution_function: MYSQL_YYABORT; $$= new (thd->mem_root) Item_window_func(thd, (Item_sum *) $1, thd->lex->win_spec); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; - if (Select->add_window_func((Item_window_func *) $$)) + if (unlikely(Select->add_window_func((Item_window_func *) $$))) MYSQL_YYABORT; } ; @@ -11257,15 +11252,16 @@ percentile_function: { Item *args= new (thd->mem_root) Item_decimal(thd, "0.5", 3, thd->charset()); - if ((args == NULL) || (thd->is_error())) + if (unlikely(args == NULL) || unlikely(thd->is_error())) { MYSQL_YYABORT; } Select->prepare_add_window_spec(thd); - if (add_order_to_list(thd, $3,FALSE)) MYSQL_YYABORT; + if (unlikely(add_order_to_list(thd, $3,FALSE))) + MYSQL_YYABORT; $$= new (thd->mem_root) Item_sum_percentile_cont(thd, args); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -11274,20 +11270,23 @@ inverse_distribution_function_def: PERCENTILE_CONT_SYM '(' expr ')' { $$= new (thd->mem_root) Item_sum_percentile_cont(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | PERCENTILE_DISC_SYM '(' expr ')' { $$= new (thd->mem_root) Item_sum_percentile_disc(thd, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; order_by_single_element_list: ORDER_SYM BY order_ident order_dir - { if (add_order_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } + { + if (unlikely(add_order_to_list(thd, $3,(bool) $4))) + MYSQL_YYABORT; + } ; @@ -11295,7 +11294,7 @@ window_name: ident { $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING)); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -11303,7 +11302,7 @@ window_name: variable: '@' { - if (! Lex->parsing_options.allows_variable) + if (unlikely(! Lex->parsing_options.allows_variable)) my_yyabort_error((ER_VIEW_SELECT_VARIABLE, MYF(0))); } variable_aux @@ -11317,7 +11316,7 @@ variable_aux: { Item_func_set_user_var *item; $$= item= new (thd->mem_root) Item_func_set_user_var(thd, &$1, $3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; LEX *lex= Lex; lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -11326,7 +11325,7 @@ variable_aux: | ident_or_text { $$= new (thd->mem_root) Item_func_get_user_var(thd, &$1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; LEX *lex= Lex; lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -11334,12 +11333,12 @@ variable_aux: | '@' opt_var_ident_type ident_or_text opt_component { /* disallow "SELECT @@global.global.variable" */ - if ($3.str && $4.str && check_reserved_words(&$3)) + if (unlikely($3.str && $4.str && check_reserved_words(&$3))) { thd->parse_error(); MYSQL_YYABORT; } - if (!($$= get_system_var(thd, $2, &$3, &$4))) + if (unlikely(!($$= get_system_var(thd, $2, &$3, &$4)))) MYSQL_YYABORT; if (!((Item_func_get_system_var*) $$)->is_written_to_binlog()) Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE); @@ -11355,7 +11354,7 @@ opt_gconcat_separator: /* empty */ { $$= new (thd->mem_root) String(",", 1, &my_charset_latin1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | SEPARATOR_SYM text_string { $$ = $2; } @@ -11368,9 +11367,15 @@ opt_gorder_clause: gorder_list: gorder_list ',' order_ident order_dir - { if (add_gorder_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } + { + if (unlikely(add_gorder_to_list(thd, $3,(bool) $4))) + MYSQL_YYABORT; + } | order_ident order_dir - { if (add_gorder_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } + { + if (unlikely(add_gorder_to_list(thd, $1,(bool) $2))) + MYSQL_YYABORT; + } ; opt_glimit_clause: @@ -11419,7 +11424,7 @@ in_sum_expr: opt_all { LEX *lex= Lex; - if (lex->current_select->inc_in_sum_expr()) + if (unlikely(lex->current_select->inc_in_sum_expr())) { thd->parse_error(); MYSQL_YYABORT; @@ -11473,9 +11478,9 @@ expr_list: expr { $$= new (thd->mem_root) List<Item>; - if ($$ == NULL) + if (unlikely($$ == NULL) || + unlikely($$->push_back($1, thd->mem_root))) MYSQL_YYABORT; - $$->push_back($1, thd->mem_root); } | expr_list ',' expr { @@ -11493,9 +11498,9 @@ ident_list: simple_ident { $$= new (thd->mem_root) List<Item>; - if ($$ == NULL) + if (unlikely($$ == NULL) || + unlikely($$->push_back($1, thd->mem_root))) MYSQL_YYABORT; - $$->push_back($1, thd->mem_root); } | ident_list ',' simple_ident { @@ -11508,7 +11513,7 @@ when_list: WHEN_SYM expr THEN_SYM expr { $$= new (thd->mem_root) List<Item>; - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; $$->push_back($2, thd->mem_root); $$->push_back($4, thd->mem_root); @@ -11537,7 +11542,7 @@ table_ref: | join_table { LEX *lex= Lex; - if (!($$= lex->current_select->nest_last_join(thd))) + if (unlikely(!($$= lex->current_select->nest_last_join(thd)))) { thd->parse_error(); MYSQL_YYABORT; @@ -11592,7 +11597,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $3); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(thd, $1, $3)) + if (unlikely(push_new_name_resolution_context(thd, $1, $3))) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -11609,7 +11614,7 @@ join_table: MYSQL_YYABORT_UNLESS($1 && $3); } '(' using_list ')' - { + { $3->straight=$2; add_join_natural($1,$3,$7,Select); $$=$3; @@ -11627,7 +11632,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $5); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(thd, $1, $5)) + if (unlikely(push_new_name_resolution_context(thd, $1, $5))) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -11663,14 +11668,14 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $5); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(thd, $1, $5)) + if (unlikely(push_new_name_resolution_context(thd, $1, $5))) MYSQL_YYABORT; Select->parsing_place= IN_ON; } expr { LEX *lex= Lex; - if (!($$= lex->current_select->convert_right_join())) + if (unlikely(!($$= lex->current_select->convert_right_join()))) MYSQL_YYABORT; add_join_on(thd, $$, $8); Lex->pop_context(); @@ -11683,7 +11688,7 @@ join_table: USING '(' using_list ')' { LEX *lex= Lex; - if (!($$= lex->current_select->convert_right_join())) + if (unlikely(!($$= lex->current_select->convert_right_join()))) MYSQL_YYABORT; add_join_natural($$,$5,$9,Select); } @@ -11692,7 +11697,7 @@ join_table: MYSQL_YYABORT_UNLESS($1 && $6); add_join_natural($6,$1,NULL,Select); LEX *lex= Lex; - if (!($$= lex->current_select->convert_right_join())) + if (unlikely(!($$= lex->current_select->convert_right_join()))) MYSQL_YYABORT; } ; @@ -11746,12 +11751,13 @@ table_primary_ident: } table_ident opt_use_partition opt_for_system_time_clause opt_table_alias opt_key_definition { - if (!($$= Select->add_table_to_list(thd, $2, $5, - Select->get_table_join_options(), - YYPS->m_lock_type, - YYPS->m_mdl_type, - Select->pop_index_hints(), - $3))) + if (unlikely(!($$= Select->add_table_to_list(thd, $2, $5, + Select->get_table_join_options(), + YYPS->m_lock_type, + YYPS->m_mdl_type, + Select-> + pop_index_hints(), + $3)))) MYSQL_YYABORT; Select->add_joined_table($$); if ($4) @@ -11802,18 +11808,18 @@ table_primary_derived: SELECT_LEX_UNIT *unit= sel->master_unit(); lex->current_select= sel= unit->outer_select(); Table_ident *ti= new (thd->mem_root) Table_ident(unit); - if (ti == NULL) + if (unlikely(ti == NULL)) MYSQL_YYABORT; - if (!($$= sel->add_table_to_list(thd, - ti, $6, 0, - TL_READ, MDL_SHARED_READ))) - + if (unlikely(!($$= sel->add_table_to_list(thd, + ti, $6, 0, + TL_READ, + MDL_SHARED_READ)))) MYSQL_YYABORT; sel->add_joined_table($$); lex->pop_context(); lex->nest_level--; } - else if ($6 != NULL) + else if (unlikely($6 != NULL)) { /* Tables with or without joins within parentheses cannot @@ -11852,13 +11858,14 @@ table_primary_derived: SELECT_LEX *sel= $2; SELECT_LEX_UNIT *unit= $5->master_unit(); Table_ident *ti= new (thd->mem_root) Table_ident(unit); - if (ti == NULL) + if (unlikely(ti == NULL)) MYSQL_YYABORT; $5->set_with_clause($4); lex->current_select= sel; - if (!($$= sel->add_table_to_list(lex->thd, - ti, $9, 0, - TL_READ, MDL_SHARED_READ))) + if (unlikely(!($$= sel->add_table_to_list(lex->thd, + ti, $9, 0, + TL_READ, + MDL_SHARED_READ)))) MYSQL_YYABORT; sel->add_joined_table($$); if ($8) @@ -11889,7 +11896,7 @@ select_derived_union: select_derived | select_derived union_order_or_limit { - if ($1) + if (unlikely($1)) { thd->parse_error(); MYSQL_YYABORT; @@ -11897,7 +11904,7 @@ select_derived_union: } | select_derived union_head_non_top { - if ($1) + if (unlikely($1)) { thd->parse_error(); MYSQL_YYABORT; @@ -11951,9 +11958,9 @@ select_derived: /* for normal joins, $2 != NULL and end_nested_join() != NULL, for derived tables, both must equal NULL */ - if (!($$= $1->end_nested_join(lex->thd)) && $2) + if (unlikely(!($$= $1->end_nested_join(lex->thd)) && $2)) MYSQL_YYABORT; - if (!$2 && $$) + if (unlikely(!$2 && $$)) { thd->parse_error(); MYSQL_YYABORT; @@ -11991,22 +11998,23 @@ derived_table_value_constructor: { LEX *lex= Lex; lex->derived_tables|= DERIVED_SUBQUERY; - if (!lex->expr_allows_subselect || - lex->sql_command == (int)SQLCOM_PURGE) + if (unlikely(!lex->expr_allows_subselect || + lex->sql_command == (int)SQLCOM_PURGE)) { thd->parse_error(); MYSQL_YYABORT; } if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || - mysql_new_select(lex, 1, NULL)) + unlikely(mysql_new_select(lex, 1, NULL))) MYSQL_YYABORT; mysql_init_select(lex); lex->current_select->linkage= DERIVED_TABLE_TYPE; - if (!(lex->current_select->tvc= - new (lex->thd->mem_root) table_value_constr(lex->many_values, - lex->current_select, - lex->current_select->options))) + if (unlikely(!(lex->current_select->tvc= + new (lex->thd->mem_root) + table_value_constr(lex->many_values, + lex->current_select, + lex->current_select->options)))) MYSQL_YYABORT; lex->many_values.empty(); $$= NULL; @@ -12018,14 +12026,14 @@ select_derived2: { LEX *lex= Lex; lex->derived_tables|= DERIVED_SUBQUERY; - if (!lex->expr_allows_subselect || - lex->sql_command == (int)SQLCOM_PURGE) + if (unlikely(!lex->expr_allows_subselect || + lex->sql_command == (int)SQLCOM_PURGE)) { thd->parse_error(); MYSQL_YYABORT; } if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE || - mysql_new_select(lex, 1, NULL)) + unlikely(mysql_new_select(lex, 1, NULL))) MYSQL_YYABORT; mysql_init_select(lex); lex->current_select->linkage= DERIVED_TABLE_TYPE; @@ -12046,7 +12054,7 @@ get_select_lex_derived: get_select_lex { LEX *lex= Lex; - if ($1->init_nested_join(lex->thd)) + if (unlikely($1->init_nested_join(lex->thd))) MYSQL_YYABORT; } ; @@ -12130,12 +12138,12 @@ key_usage_list: using_list: ident { - if (!($$= new (thd->mem_root) List<String>)) + if (unlikely(!($$= new (thd->mem_root) List<String>))) MYSQL_YYABORT; String *s= new (thd->mem_root) String((const char *) $1.str, $1.length, system_charset_info); - if (s == NULL) + if (unlikely(unlikely(s == NULL))) MYSQL_YYABORT; $$->push_back(s, thd->mem_root); } @@ -12144,9 +12152,10 @@ using_list: String *s= new (thd->mem_root) String((const char *) $3.str, $3.length, system_charset_info); - if (s == NULL) + if (unlikely(unlikely(s == NULL))) + MYSQL_YYABORT; + if (unlikely($1->push_back(s, thd->mem_root))) MYSQL_YYABORT; - $1->push_back(s, thd->mem_root); $$= $1; } ; @@ -12196,7 +12205,7 @@ opt_table_alias: | table_alias ident_table_alias { $$= (LEX_CSTRING*) thd->memdup(&$2,sizeof(LEX_STRING)); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -12250,7 +12259,7 @@ opt_escape: $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? new (thd->mem_root) Item_string_ascii(thd, "", 0) : new (thd->mem_root) Item_string_ascii(thd, "\\", 1)); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -12266,9 +12275,15 @@ opt_group_clause: group_list: group_list ',' order_ident order_dir - { if (add_group_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } + { + if (unlikely(add_group_to_list(thd, $3,(bool) $4))) + MYSQL_YYABORT; + } | order_ident order_dir - { if (add_group_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } + { + if (unlikely(add_group_to_list(thd, $1,(bool) $2))) + MYSQL_YYABORT; + } ; olap_opt: @@ -12283,7 +12298,7 @@ olap_opt: SQL-2003: GROUP BY ... CUBE(col1, col2, col3) */ LEX *lex=Lex; - if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) + if (unlikely(lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "WITH CUBE", "global union parameters")); lex->current_select->olap= CUBE_TYPE; @@ -12300,7 +12315,7 @@ olap_opt: SQL-2003: GROUP BY ... ROLLUP(col1, col2, col3) */ LEX *lex= Lex; - if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) + if (unlikely(lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "WITH ROLLUP", "global union parameters")); lex->current_select->olap= ROLLUP_TYPE; @@ -12328,10 +12343,10 @@ window_def: window_name AS window_spec { LEX *lex= Lex; - if (Select->add_window_def(thd, $1, lex->win_ref, - Select->group_list, - Select->order_list, - lex->win_frame)) + if (unlikely(Select->add_window_def(thd, $1, lex->win_ref, + Select->group_list, + Select->order_list, + lex->win_frame))) MYSQL_YYABORT; } ; @@ -12349,7 +12364,7 @@ opt_window_ref: | ident { thd->lex->win_ref= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING)); - if (thd->lex->win_ref == NULL) + if (unlikely(thd->lex->win_ref == NULL)) MYSQL_YYABORT; } @@ -12373,7 +12388,7 @@ opt_window_frame_clause: lex->frame_top_bound, lex->frame_bottom_bound, $3); - if (lex->win_frame == NULL) + if (unlikely(lex->win_frame == NULL)) MYSQL_YYABORT; } ; @@ -12391,7 +12406,7 @@ window_frame_extent: lex->frame_bottom_bound= new (thd->mem_root) Window_frame_bound(Window_frame_bound::CURRENT, NULL); - if (lex->frame_bottom_bound == NULL) + if (unlikely(lex->frame_bottom_bound == NULL)) MYSQL_YYABORT; } | BETWEEN_SYM window_frame_bound AND_SYM window_frame_bound @@ -12407,21 +12422,21 @@ window_frame_start: { $$= new (thd->mem_root) Window_frame_bound(Window_frame_bound::PRECEDING, NULL); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | CURRENT_SYM ROW_SYM { $$= new (thd->mem_root) Window_frame_bound(Window_frame_bound::CURRENT, NULL); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | literal PRECEDING_SYM { $$= new (thd->mem_root) Window_frame_bound(Window_frame_bound::PRECEDING, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -12432,14 +12447,14 @@ window_frame_bound: { $$= new (thd->mem_root) Window_frame_bound(Window_frame_bound::FOLLOWING, NULL); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | literal FOLLOWING_SYM { $$= new (thd->mem_root) Window_frame_bound(Window_frame_bound::FOLLOWING, $1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -12473,7 +12488,7 @@ alter_order_item: simple_ident_nospvar order_dir { bool ascending= ($2 == 1) ? true : false; - if (add_order_to_list(thd, $1, ascending)) + if (unlikely(add_order_to_list(thd, $1, ascending))) MYSQL_YYABORT; } ; @@ -12493,9 +12508,9 @@ order_clause: LEX *lex=Lex; SELECT_LEX *sel= lex->current_select; SELECT_LEX_UNIT *unit= sel-> master_unit(); - if (sel->linkage != GLOBAL_OPTIONS_TYPE && - sel->olap != UNSPECIFIED_OLAP_TYPE && - (sel->linkage != UNION_TYPE || sel->braces)) + if (unlikely(sel->linkage != GLOBAL_OPTIONS_TYPE && + sel->olap != UNSPECIFIED_OLAP_TYPE && + (sel->linkage != UNION_TYPE || sel->braces))) { my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY"); @@ -12509,14 +12524,14 @@ order_clause: executed in the same way as the query SELECT ... ORDER BY order_list unless the SELECT construct contains ORDER BY or LIMIT clauses. - Otherwise we create a fake SELECT_LEX if it has not been created - yet. + Otherwise we create a fake SELECT_LEX if it has not been + created yet. */ SELECT_LEX *first_sl= unit->first_select(); - if (!unit->is_unit_op() && - (first_sl->order_list.elements || - first_sl->select_limit) && - unit->add_fake_select_lex(thd)) + if (unlikely(!unit->is_unit_op() && + (first_sl->order_list.elements || + first_sl->select_limit) && + unit->add_fake_select_lex(thd))) MYSQL_YYABORT; } if (sel->master_unit()->is_unit_op() && !sel->braces) @@ -12539,9 +12554,15 @@ order_clause: order_list: order_list ',' order_ident order_dir - { if (add_order_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } + { + if (unlikely(add_order_to_list(thd, $3,(bool) $4))) + MYSQL_YYABORT; + } | order_ident order_dir - { if (add_order_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } + { + if (unlikely(add_order_to_list(thd, $1,(bool) $2))) + MYSQL_YYABORT; + } ; order_dir: @@ -12614,12 +12635,12 @@ limit_options: limit_option: ident_cli { - if (!($$= Lex->create_item_limit(thd, &$1))) + if (unlikely(!($$= Lex->create_item_limit(thd, &$1)))) MYSQL_YYABORT; } | ident_cli '.' ident_cli { - if (!($$= Lex->create_item_limit(thd, &$1, &$3))) + if (unlikely(!($$= Lex->create_item_limit(thd, &$1, &$3)))) MYSQL_YYABORT; } | param_marker @@ -12629,19 +12650,19 @@ limit_option: | ULONGLONG_NUM { $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LONG_NUM { $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | NUM { $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -12753,9 +12774,9 @@ procedure_clause: Item_field *item= new (thd->mem_root) Item_field(thd, &lex->current_select->context, NULL, NULL, &$2); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; - if (add_proc_to_list(thd, item)) + if (unlikely(add_proc_to_list(thd, item))) MYSQL_YYABORT; Lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -12787,7 +12808,7 @@ procedure_list2: procedure_item: remember_name expr remember_end { - if (add_proc_to_list(thd, $2)) + if (unlikely(add_proc_to_list(thd, $2))) MYSQL_YYABORT; if (!$2->name.str || $2->name.str == item_empty_name) $2->set_name(thd, $1, (uint) ($3 - $1), thd->charset()); @@ -12798,7 +12819,8 @@ select_var_list_init: { LEX *lex=Lex; if (!lex->describe && - (!(lex->result= new (thd->mem_root) select_dumpvar(thd)))) + unlikely((!(lex->result= new (thd->mem_root) + select_dumpvar(thd))))) MYSQL_YYABORT; } select_var_list @@ -12814,7 +12836,7 @@ select_var_ident: select_outvar { if (Lex->result) { - if ($1 == NULL) + if (unlikely($1 == NULL)) MYSQL_YYABORT; ((select_dumpvar *)Lex->result)->var_list.push_back($1, thd->mem_root); } @@ -12836,12 +12858,12 @@ select_outvar: } | ident_or_text { - if (!($$= Lex->create_outvar(thd, &$1)) && Lex->result) + if (unlikely(!($$= Lex->create_outvar(thd, &$1)) && Lex->result)) MYSQL_YYABORT; } | ident '.' ident { - if (!($$= Lex->create_outvar(thd, &$1, &$3)) && Lex->result) + if (unlikely(!($$= Lex->create_outvar(thd, &$1, &$3)) && Lex->result)) MYSQL_YYABORT; } ; @@ -12855,10 +12877,11 @@ into_destination: { LEX *lex= Lex; lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - if (!(lex->exchange= - new (thd->mem_root) sql_exchange($2.str, 0)) || - !(lex->result= - new (thd->mem_root) select_export(thd, lex->exchange))) + if (unlikely(!(lex->exchange= + new (thd->mem_root) sql_exchange($2.str, 0))) || + unlikely(!(lex->result= + new (thd->mem_root) + select_export(thd, lex->exchange)))) MYSQL_YYABORT; } opt_load_data_charset @@ -12870,10 +12893,12 @@ into_destination: if (!lex->describe) { lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - if (!(lex->exchange= new (thd->mem_root) sql_exchange($2.str,1))) + if (unlikely(!(lex->exchange= + new (thd->mem_root) sql_exchange($2.str,1)))) MYSQL_YYABORT; - if (!(lex->result= - new (thd->mem_root) select_dump(thd, lex->exchange))) + if (unlikely(!(lex->result= + new (thd->mem_root) + select_dump(thd, lex->exchange)))) MYSQL_YYABORT; } } @@ -12919,16 +12944,16 @@ drop: LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) Alter_drop(Alter_drop::KEY, $4.str, $3)); - if (ad == NULL) + if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->sql_command= SQLCOM_DROP_INDEX; lex->alter_info.reset(); lex->alter_info.flags= ALTER_DROP_INDEX; lex->alter_info.drop_list.push_back(ad, thd->mem_root); - if (!lex->current_select->add_table_to_list(thd, $6, NULL, - TL_OPTION_UPDATING, - TL_READ_NO_INSERT, - MDL_SHARED_UPGRADABLE)) + if (unlikely(!lex->current_select-> + add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING, + TL_READ_NO_INSERT, + MDL_SHARED_UPGRADABLE))) MYSQL_YYABORT; } | DROP DATABASE opt_if_exists ident @@ -12941,13 +12966,13 @@ drop: { LEX *lex= thd->lex; sp_name *spname; - if ($4.str && check_db_name((LEX_STRING*) &$4)) - my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str)); - if (lex->sphead) + if (unlikely($4.str && check_db_name((LEX_STRING*) &$4))) + my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $4.str)); + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); lex->set_command(SQLCOM_DROP_FUNCTION, $3); spname= new (thd->mem_root) sp_name(&$4, &$6, true); - if (spname == NULL) + if (unlikely(spname == NULL)) MYSQL_YYABORT; lex->spname= spname; } @@ -12956,20 +12981,20 @@ drop: LEX *lex= thd->lex; LEX_CSTRING db= {0, 0}; sp_name *spname; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "FUNCTION")); - if (thd->db.str && lex->copy_db_to(&db)) + if (thd->db.str && unlikely(lex->copy_db_to(&db))) MYSQL_YYABORT; lex->set_command(SQLCOM_DROP_FUNCTION, $3); spname= new (thd->mem_root) sp_name(&db, &$4, false); - if (spname == NULL) + if (unlikely(spname == NULL)) MYSQL_YYABORT; lex->spname= spname; } | DROP PROCEDURE_SYM opt_if_exists sp_name { LEX *lex=Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE")); lex->set_command(SQLCOM_DROP_PROCEDURE, $3); lex->spname= $4; @@ -13038,10 +13063,10 @@ table_list: table_name: table_ident { - if (!Select->add_table_to_list(thd, $1, NULL, - TL_OPTION_UPDATING, - YYPS->m_lock_type, - YYPS->m_mdl_type)) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, + TL_OPTION_UPDATING, + YYPS->m_lock_type, + YYPS->m_mdl_type))) MYSQL_YYABORT; } ; @@ -13049,12 +13074,12 @@ table_name: table_name_with_opt_use_partition: table_ident opt_use_partition { - if (!Select->add_table_to_list(thd, $1, NULL, - TL_OPTION_UPDATING, - YYPS->m_lock_type, - YYPS->m_mdl_type, - NULL, - $2)) + if (unlikely(!Select->add_table_to_list(thd, $1, NULL, + TL_OPTION_UPDATING, + YYPS->m_lock_type, + YYPS->m_mdl_type, + NULL, + $2))) MYSQL_YYABORT; } ; @@ -13067,10 +13092,12 @@ table_alias_ref_list: table_alias_ref: table_ident_opt_wild { - if (!Select->add_table_to_list(thd, $1, NULL, - TL_OPTION_UPDATING | TL_OPTION_ALIAS, + if (unlikely(!Select-> + add_table_to_list(thd, $1, NULL, + (TL_OPTION_UPDATING | + TL_OPTION_ALIAS), YYPS->m_lock_type, - YYPS->m_mdl_type)) + YYPS->m_mdl_type))) MYSQL_YYABORT; } ; @@ -13194,8 +13221,9 @@ insert_field_spec: | SET { LEX *lex=Lex; - if (!(lex->insert_list= new (thd->mem_root) List_item) || - lex->many_values.push_back(lex->insert_list, thd->mem_root)) + if (unlikely(!(lex->insert_list= new (thd->mem_root) List_item)) || + unlikely(lex->many_values.push_back(lex->insert_list, + thd->mem_root))) MYSQL_YYABORT; } ident_eq_list @@ -13227,8 +13255,8 @@ ident_eq_value: simple_ident_nospvar equal expr_or_default { LEX *lex=Lex; - if (lex->field_list.push_back($1, thd->mem_root) || - lex->insert_list->push_back($3, thd->mem_root)) + if (unlikely(lex->field_list.push_back($1, thd->mem_root)) || + unlikely(lex->insert_list->push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -13256,13 +13284,14 @@ opt_by: no_braces: '(' { - if (!(Lex->insert_list= new (thd->mem_root) List_item)) - MYSQL_YYABORT; + if (unlikely(!(Lex->insert_list= new (thd->mem_root) List_item))) + MYSQL_YYABORT; } opt_values ')' { LEX *lex=Lex; - if (lex->many_values.push_back(lex->insert_list, thd->mem_root)) + if (unlikely(lex->many_values.push_back(lex->insert_list, + thd->mem_root))) MYSQL_YYABORT; } ; @@ -13275,12 +13304,12 @@ opt_values: values: values ',' expr_or_default { - if (Lex->insert_list->push_back($3, thd->mem_root)) + if (unlikely(Lex->insert_list->push_back($3, thd->mem_root))) MYSQL_YYABORT; } | expr_or_default { - if (Lex->insert_list->push_back($1, thd->mem_root)) + if (unlikely(Lex->insert_list->push_back($1, thd->mem_root))) MYSQL_YYABORT; } ; @@ -13290,13 +13319,13 @@ expr_or_default: | DEFAULT { $$= new (thd->mem_root) Item_default_value(thd, Lex->current_context()); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | IGNORE_SYM { $$= new (thd->mem_root) Item_ignore_value(thd, Lex->current_context()); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -13330,7 +13359,7 @@ update: LEX *lex= Lex; if (lex->select_lex.table_list.elements > 1) lex->sql_command= SQLCOM_UPDATE_MULTI; - else if (lex->select_lex.get_table_list()->derived) + else if (unlikely(lex->select_lex.get_table_list()->derived)) { /* it is single table update and it is update of derived table */ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), @@ -13355,7 +13384,8 @@ update_list: update_elem: simple_ident_nospvar equal expr_or_default { - if (add_item_to_list(thd, $1) || add_value_to_list(thd, $3)) + if (unlikely(add_item_to_list(thd, $1)) || + unlikely(add_value_to_list(thd, $3))) MYSQL_YYABORT; } ; @@ -13369,8 +13399,8 @@ insert_update_elem: simple_ident_nospvar equal expr_or_default { LEX *lex= Lex; - if (lex->update_list.push_back($1, thd->mem_root) || - lex->value_list.push_back($3, thd->mem_root)) + if (unlikely(lex->update_list.push_back($1, thd->mem_root)) || + unlikely(lex->value_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -13419,11 +13449,12 @@ delete_part2: delete_single_table: FROM table_ident opt_use_partition { - if (!Select->add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING, + if (unlikely(!Select-> + add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING, YYPS->m_lock_type, YYPS->m_mdl_type, NULL, - $3)) + $3))) MYSQL_YYABORT; YYPS->m_lock_type= TL_READ_DEFAULT; YYPS->m_mdl_type= MDL_SHARED_READ; @@ -13444,7 +13475,7 @@ single_multi: } FROM join_table_list opt_where_clause { - if (multi_delete_set_locks_and_link_aux_tables(Lex)) + if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) MYSQL_YYABORT; } | FROM table_alias_ref_list @@ -13455,7 +13486,7 @@ single_multi: } USING join_table_list opt_where_clause { - if (multi_delete_set_locks_and_link_aux_tables(Lex)) + if (unlikely(multi_delete_set_locks_and_link_aux_tables(Lex))) MYSQL_YYABORT; } ; @@ -13474,27 +13505,31 @@ table_wild_one: ident opt_wild { Table_ident *ti= new (thd->mem_root) Table_ident(&$1); - if (ti == NULL) + if (unlikely(ti == NULL)) MYSQL_YYABORT; - if (!Select->add_table_to_list(thd, + if (unlikely(!Select-> + add_table_to_list(thd, ti, NULL, - TL_OPTION_UPDATING | TL_OPTION_ALIAS, + (TL_OPTION_UPDATING | + TL_OPTION_ALIAS), YYPS->m_lock_type, - YYPS->m_mdl_type)) + YYPS->m_mdl_type))) MYSQL_YYABORT; } | ident '.' ident opt_wild { Table_ident *ti= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0); - if (ti == NULL) + if (unlikely(ti == NULL)) MYSQL_YYABORT; - if (!Select->add_table_to_list(thd, + if (unlikely(!Select-> + add_table_to_list(thd, ti, NULL, - TL_OPTION_UPDATING | TL_OPTION_ALIAS, + (TL_OPTION_UPDATING | + TL_OPTION_ALIAS), YYPS->m_lock_type, - YYPS->m_mdl_type)) + YYPS->m_mdl_type))) MYSQL_YYABORT; } ; @@ -13532,7 +13567,7 @@ truncate: LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_sql_cmd); lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_truncate_table(); - if (lex->m_sql_cmd == NULL) + if (unlikely(lex->m_sql_cmd == NULL)) MYSQL_YYABORT; } ; @@ -13623,7 +13658,7 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_DATABASES; - if (prepare_schema_table(thd, lex, 0, SCH_SCHEMATA)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_SCHEMATA))) MYSQL_YYABORT; } | opt_full TABLES opt_db wild_and_where @@ -13631,7 +13666,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TABLES; lex->select_lex.db= $3; - if (prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES))) MYSQL_YYABORT; } | opt_full TRIGGERS_SYM opt_db wild_and_where @@ -13639,7 +13674,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TRIGGERS; lex->select_lex.db= $3; - if (prepare_schema_table(thd, lex, 0, SCH_TRIGGERS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_TRIGGERS))) MYSQL_YYABORT; } | EVENTS_SYM opt_db wild_and_where @@ -13647,7 +13682,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_EVENTS; lex->select_lex.db= $2; - if (prepare_schema_table(thd, lex, 0, SCH_EVENTS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_EVENTS))) MYSQL_YYABORT; } | TABLE_SYM STATUS_SYM opt_db wild_and_where @@ -13655,7 +13690,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TABLE_STATUS; lex->select_lex.db= $3; - if (prepare_schema_table(thd, lex, 0, SCH_TABLES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_TABLES))) MYSQL_YYABORT; } | OPEN_SYM TABLES opt_db wild_and_where @@ -13663,27 +13698,27 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_OPEN_TABLES; lex->select_lex.db= $3; - if (prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES))) MYSQL_YYABORT; } | PLUGINS_SYM { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_PLUGINS; - if (prepare_schema_table(thd, lex, 0, SCH_PLUGINS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PLUGINS))) MYSQL_YYABORT; } | PLUGINS_SYM SONAME_SYM TEXT_STRING_sys { Lex->ident= $3; Lex->sql_command= SQLCOM_SHOW_PLUGINS; - if (prepare_schema_table(thd, Lex, 0, SCH_ALL_PLUGINS)) + if (unlikely(prepare_schema_table(thd, Lex, 0, SCH_ALL_PLUGINS))) MYSQL_YYABORT; } | PLUGINS_SYM SONAME_SYM wild_and_where { Lex->sql_command= SQLCOM_SHOW_PLUGINS; - if (prepare_schema_table(thd, Lex, 0, SCH_ALL_PLUGINS)) + if (unlikely(prepare_schema_table(thd, Lex, 0, SCH_ALL_PLUGINS))) MYSQL_YYABORT; } | ENGINE_SYM known_storage_engines show_engine_param @@ -13696,7 +13731,7 @@ show_param: lex->sql_command= SQLCOM_SHOW_FIELDS; if ($5.str) $4->change_db(&$5); - if (prepare_schema_table(thd, lex, $4, SCH_COLUMNS)) + if (unlikely(prepare_schema_table(thd, lex, $4, SCH_COLUMNS))) MYSQL_YYABORT; } | master_or_binary LOGS_SYM @@ -13724,14 +13759,14 @@ show_param: lex->sql_command= SQLCOM_SHOW_KEYS; if ($4.str) $3->change_db(&$4); - if (prepare_schema_table(thd, lex, $3, SCH_STATISTICS)) + if (unlikely(prepare_schema_table(thd, lex, $3, SCH_STATISTICS))) MYSQL_YYABORT; } | opt_storage ENGINES_SYM { LEX *lex=Lex; lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES; - if (prepare_schema_table(thd, lex, 0, SCH_ENGINES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_ENGINES))) MYSQL_YYABORT; } | AUTHORS_SYM @@ -13769,7 +13804,7 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_PROFILE; - if (prepare_schema_table(thd, lex, NULL, SCH_PROFILES) != 0) + if (unlikely(prepare_schema_table(thd, lex, NULL, SCH_PROFILES))) MYSQL_YYABORT; } | opt_var_type STATUS_SYM wild_and_where @@ -13777,7 +13812,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS; lex->option_type= $1; - if (prepare_schema_table(thd, lex, 0, SCH_SESSION_STATUS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_SESSION_STATUS))) MYSQL_YYABORT; } | opt_full PROCESSLIST_SYM @@ -13787,27 +13822,28 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_VARIABLES; lex->option_type= $1; - if (prepare_schema_table(thd, lex, 0, SCH_SESSION_VARIABLES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_SESSION_VARIABLES))) MYSQL_YYABORT; } | charset wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_CHARSETS; - if (prepare_schema_table(thd, lex, 0, SCH_CHARSETS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_CHARSETS))) MYSQL_YYABORT; } | COLLATION_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_COLLATIONS; - if (prepare_schema_table(thd, lex, 0, SCH_COLLATIONS)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_COLLATIONS))) MYSQL_YYABORT; } | GRANTS { Lex->sql_command= SQLCOM_SHOW_GRANTS; - if (!(Lex->grant_user= (LEX_USER*)thd->alloc(sizeof(LEX_USER)))) + if (unlikely(!(Lex->grant_user= + (LEX_USER*)thd->alloc(sizeof(LEX_USER))))) MYSQL_YYABORT; Lex->grant_user->user= current_user_and_current_role; } @@ -13826,7 +13862,7 @@ show_param: { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE; - if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $3, NULL,0))) MYSQL_YYABORT; lex->create_info.storage_media= HA_SM_DEFAULT; } @@ -13834,7 +13870,7 @@ show_param: { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE; - if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $3, NULL, 0))) MYSQL_YYABORT; lex->table_type= TABLE_TYPE_VIEW; } @@ -13842,7 +13878,7 @@ show_param: { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE; - if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0)) + if (unlikely(!lex->select_lex.add_table_to_list(thd, $3, NULL, 0))) MYSQL_YYABORT; lex->table_type= TABLE_TYPE_SEQUENCE; } @@ -13902,7 +13938,8 @@ show_param: | CREATE USER_SYM { Lex->sql_command= SQLCOM_SHOW_CREATE_USER; - if (!(Lex->grant_user= (LEX_USER*)thd->alloc(sizeof(LEX_USER)))) + if (unlikely(!(Lex->grant_user= + (LEX_USER*)thd->alloc(sizeof(LEX_USER))))) MYSQL_YYABORT; Lex->grant_user->user= current_user; } @@ -13915,28 +13952,28 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PROC; - if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } | FUNCTION_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_FUNC; - if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } | PACKAGE_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE; - if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } | PACKAGE_SYM BODY_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PACKAGE_BODY; - if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) + if (unlikely(prepare_schema_table(thd, lex, 0, SCH_PROCEDURES))) MYSQL_YYABORT; } | PROCEDURE_SYM CODE_SYM sp_name @@ -13962,7 +13999,7 @@ show_param: | describe_command FOR_SYM expr { Lex->sql_command= SQLCOM_SHOW_EXPLAIN; - if (prepare_schema_table(thd, Lex, 0, SCH_EXPLAIN)) + if (unlikely(prepare_schema_table(thd, Lex, 0, SCH_EXPLAIN))) MYSQL_YYABORT; add_value_to_list(thd, $3); } @@ -13972,17 +14009,17 @@ show_param: bool in_plugin; lex->sql_command= SQLCOM_SHOW_GENERIC; ST_SCHEMA_TABLE *table= find_schema_table(thd, &$1, &in_plugin); - if (!table || !table->old_format || !in_plugin) + if (unlikely(!table || !table->old_format || !in_plugin)) { thd->parse_error(ER_SYNTAX_ERROR, $2); MYSQL_YYABORT; } - if (lex->wild && table->idx_field1 < 0) + if (unlikely(lex->wild && table->idx_field1 < 0)) { thd->parse_error(ER_SYNTAX_ERROR, $3); MYSQL_YYABORT; } - if (make_schema_select(thd, Lex->current_select, table)) + if (unlikely(make_schema_select(thd, Lex->current_select, table))) MYSQL_YYABORT; } ; @@ -14037,7 +14074,7 @@ wild_and_where: { Lex->wild= new (thd->mem_root) String($3.str, $3.length, system_charset_info); - if (Lex->wild == NULL) + if (unlikely(Lex->wild == NULL)) MYSQL_YYABORT; $$= $2; } @@ -14060,7 +14097,7 @@ describe: lex->sql_command= SQLCOM_SHOW_FIELDS; lex->select_lex.db= null_clex_str; lex->verbose= 0; - if (prepare_schema_table(thd, lex, $2, SCH_COLUMNS)) + if (unlikely(prepare_schema_table(thd, lex, $2, SCH_COLUMNS))) MYSQL_YYABORT; } opt_describe_column @@ -14124,7 +14161,7 @@ opt_describe_column: Lex->wild= new (thd->mem_root) String((const char*) $1.str, $1.length, system_charset_info); - if (Lex->wild == NULL) + if (unlikely(Lex->wild == NULL)) MYSQL_YYABORT; } ; @@ -14181,8 +14218,9 @@ flush_lock: { Lex->type|= REFRESH_READ_LOCK | $4; } | FOR_SYM { - if (Lex->query_tables == NULL) // Table list can't be empty + if (unlikely(Lex->query_tables == NULL)) { + // Table list can't be empty thd->parse_error(ER_NO_TABLES_USED); MYSQL_YYABORT; } @@ -14210,7 +14248,7 @@ flush_option: | RELAY LOGS_SYM optional_connection_name { LEX *lex= Lex; - if (lex->type & REFRESH_RELAY_LOG) + if (unlikely(lex->type & REFRESH_RELAY_LOG)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "FLUSH", "RELAY LOGS")); lex->type|= REFRESH_RELAY_LOG; lex->relay_log_connection_name= lex->mi.connection_name; @@ -14231,7 +14269,7 @@ flush_option: | SLAVE optional_connection_name { LEX *lex= Lex; - if (lex->type & REFRESH_SLAVE) + if (unlikely(lex->type & REFRESH_SLAVE)) my_yyabort_error((ER_WRONG_USAGE, MYF(0), "FLUSH","SLAVE")); lex->type|= REFRESH_SLAVE; lex->reset_slave_info.all= false; @@ -14246,14 +14284,15 @@ flush_option: { Lex->type|= REFRESH_GENERIC; ST_SCHEMA_TABLE *table= find_schema_table(thd, &$1); - if (!table || !table->reset_table) + if (unlikely(!table || !table->reset_table)) { thd->parse_error(ER_SYNTAX_ERROR, $2); MYSQL_YYABORT; } - Lex->view_list.push_back((LEX_CSTRING*) - thd->memdup(&$1, sizeof(LEX_CSTRING)), - thd->mem_root); + if (unlikely(Lex->view_list.push_back((LEX_CSTRING*) + thd->memdup(&$1, sizeof(LEX_CSTRING)), + thd->mem_root))) + MYSQL_YYABORT; } ; @@ -14422,7 +14461,7 @@ load: { LEX *lex= thd->lex; - if (lex->sphead) + if (unlikely(lex->sphead)) { my_error(ER_SP_BADSTATEMENT, MYF(0), $2 == FILETYPE_CSV ? "LOAD DATA" : "LOAD XML"); @@ -14436,14 +14475,17 @@ load: lex->local_file= $5; lex->duplicates= DUP_ERROR; lex->ignore= 0; - if (!(lex->exchange= new (thd->mem_root) sql_exchange($7.str, 0, $2))) + if (unlikely(!(lex->exchange= new (thd->mem_root) + sql_exchange($7.str, 0, $2)))) MYSQL_YYABORT; } opt_duplicate INTO TABLE_SYM table_ident opt_use_partition { LEX *lex=Lex; - if (!Select->add_table_to_list(thd, $12, NULL, TL_OPTION_UPDATING, - $4, MDL_SHARED_WRITE, NULL, $13)) + if (unlikely(!Select->add_table_to_list(thd, $12, NULL, + TL_OPTION_UPDATING, + $4, MDL_SHARED_WRITE, + NULL, $13))) MYSQL_YYABORT; lex->field_list.empty(); lex->update_list.empty(); @@ -14581,7 +14623,7 @@ field_or_var: | '@' ident_or_text { $$= new (thd->mem_root) Item_user_var_as_out_param(thd, &$2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -14600,8 +14642,8 @@ load_data_set_elem: simple_ident_nospvar equal remember_name expr_or_default remember_end { LEX *lex= Lex; - if (lex->update_list.push_back($1, thd->mem_root) || - lex->value_list.push_back($4, thd->mem_root)) + if (unlikely(lex->update_list.push_back($1, thd->mem_root)) || + unlikely(lex->value_list.push_back($4, thd->mem_root))) MYSQL_YYABORT; $4->set_name_no_truncate(thd, $3, (uint) ($5 - $3), thd->charset()); } @@ -14612,22 +14654,22 @@ load_data_set_elem: text_literal: TEXT_STRING { - if (!($$= thd->make_string_literal($1))) + if (unlikely(!($$= thd->make_string_literal($1)))) MYSQL_YYABORT; } | NCHAR_STRING { - if (!($$= thd->make_string_literal_nchar($1))) + if (unlikely(!($$= thd->make_string_literal_nchar($1)))) MYSQL_YYABORT; } | UNDERSCORE_CHARSET TEXT_STRING { - if (!($$= thd->make_string_literal_charset($2, $1))) + if (unlikely(!($$= thd->make_string_literal_charset($2, $1)))) MYSQL_YYABORT; } | text_literal TEXT_STRING_literal { - if (!($$= $1->make_string_literal_concat(thd, &$2))) + if (unlikely(!($$= $1->make_string_literal_concat(thd, &$2)))) MYSQL_YYABORT; } ; @@ -14638,7 +14680,7 @@ text_string: $$= new (thd->mem_root) String($1.str, $1.length, thd->variables.collation_connection); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | hex_or_bin_String { $$= $1; } @@ -14650,7 +14692,7 @@ hex_or_bin_String: { Item *tmp= new (thd->mem_root) Item_hex_hybrid(thd, $1.str, $1.length); - if (tmp == NULL) + if (unlikely(tmp == NULL)) MYSQL_YYABORT; /* it is OK only emulate fix_fields, because we need only @@ -14663,7 +14705,7 @@ hex_or_bin_String: { Item *tmp= new (thd->mem_root) Item_hex_string(thd, $1.str, $1.length); - if (tmp == NULL) + if (unlikely(tmp == NULL)) MYSQL_YYABORT; tmp->quick_fix_field(); $$= tmp->val_str((String*) 0); @@ -14672,7 +14714,7 @@ hex_or_bin_String: { Item *tmp= new (thd->mem_root) Item_bin_string(thd, $1.str, $1.length); - if (tmp == NULL) + if (unlikely(tmp == NULL)) MYSQL_YYABORT; /* it is OK only emulate fix_fields, because we need only @@ -14686,9 +14728,9 @@ hex_or_bin_String: param_marker: PARAM_MARKER { - if (!($$= Lex->add_placeholder(thd, ¶m_clex_str, - YYLIP->get_tok_start(), - YYLIP->get_tok_start() + 1))) + if (unlikely(!($$= Lex->add_placeholder(thd, ¶m_clex_str, + YYLIP->get_tok_start(), + YYLIP->get_tok_start() + 1)))) MYSQL_YYABORT; } ; @@ -14716,38 +14758,38 @@ literal: */ YYLIP->reduce_digest_token(TOK_GENERIC_VALUE, NULL_SYM); $$= new (thd->mem_root) Item_null(thd); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; YYLIP->next_state= MY_LEX_OPERATOR_OR_IDENT; } | FALSE_SYM { $$= new (thd->mem_root) Item_bool(thd, (char*) "FALSE",0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | TRUE_SYM { $$= new (thd->mem_root) Item_bool(thd, (char*) "TRUE",1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | HEX_NUM { $$= new (thd->mem_root) Item_hex_hybrid(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | HEX_STRING { $$= new (thd->mem_root) Item_hex_string(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | BIN_NUM { $$= new (thd->mem_root) Item_bin_string(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | UNDERSCORE_CHARSET hex_or_bin_String @@ -14760,7 +14802,8 @@ literal: item_str= new (thd->mem_root) Item_string_with_introducer(thd, NULL, $2->ptr(), $2->length(), $1); - if (!item_str || !item_str->check_well_formed_result(true)) + if (unlikely(!item_str || + !item_str->check_well_formed_result(true))) MYSQL_YYABORT; $$= item_str; @@ -14775,7 +14818,7 @@ NUM_literal: Item_int(thd, $1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | LONG_NUM @@ -14785,20 +14828,20 @@ NUM_literal: Item_int(thd, $1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ULONGLONG_NUM { $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | DECIMAL_NUM { $$= new (thd->mem_root) Item_decimal(thd, $1.str, $1.length, thd->charset()); - if (($$ == NULL) || (thd->is_error())) + if (unlikely($$ == NULL) || unlikely(thd->is_error())) { MYSQL_YYABORT; } @@ -14806,7 +14849,7 @@ NUM_literal: | FLOAT_NUM { $$= new (thd->mem_root) Item_float(thd, $1.str, $1.length); - if (($$ == NULL) || (thd->is_error())) + if (unlikely($$ == NULL) || unlikely(thd->is_error())) { MYSQL_YYABORT; } @@ -14817,20 +14860,26 @@ NUM_literal: temporal_literal: DATE_SYM TEXT_STRING { - if (!($$= create_temporal_literal(thd, $2.str, $2.length, YYCSCL, - MYSQL_TYPE_DATE, true))) + if (unlikely(!($$= create_temporal_literal(thd, $2.str, $2.length, + YYCSCL, + MYSQL_TYPE_DATE, + true)))) MYSQL_YYABORT; } | TIME_SYM TEXT_STRING { - if (!($$= create_temporal_literal(thd, $2.str, $2.length, YYCSCL, - MYSQL_TYPE_TIME, true))) + if (unlikely(!($$= create_temporal_literal(thd, $2.str, $2.length, + YYCSCL, + MYSQL_TYPE_TIME, + true)))) MYSQL_YYABORT; } | TIMESTAMP TEXT_STRING { - if (!($$= create_temporal_literal(thd, $2.str, $2.length, YYCSCL, - MYSQL_TYPE_DATETIME, true))) + if (unlikely(!($$= create_temporal_literal(thd, $2.str, $2.length, + YYCSCL, + MYSQL_TYPE_DATETIME, + true)))) MYSQL_YYABORT; } ; @@ -14850,7 +14899,7 @@ with_clause: { With_clause *with_clause= new With_clause($2, Lex->curr_with_clause); - if (with_clause == NULL) + if (unlikely(with_clause == NULL)) MYSQL_YYABORT; Lex->derived_tables|= DERIVED_WITH; Lex->curr_with_clause= with_clause; @@ -14881,16 +14930,17 @@ with_list_element: opt_with_column_list { $2= new List<LEX_CSTRING> (Lex->with_column_list); - if ($2 == NULL) + if (unlikely($2 == NULL)) MYSQL_YYABORT; Lex->with_column_list.empty(); } AS '(' remember_name subselect remember_end ')' { With_element *elem= new With_element($1, *$2, $7->master_unit()); - if (elem == NULL || Lex->curr_with_clause->add_with_element(elem)) + if (unlikely(elem == NULL) || + unlikely(Lex->curr_with_clause->add_with_element(elem))) MYSQL_YYABORT; - if (elem->set_unparsed_spec(thd, $6+1, $8)) + if (unlikely(elem->set_unparsed_spec(thd, $6+1, $8))) MYSQL_YYABORT; } ; @@ -14922,7 +14972,7 @@ query_name: ident { $$= (LEX_CSTRING *) thd->memdup(&$1, sizeof(LEX_CSTRING)); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -14941,12 +14991,12 @@ insert_ident: table_wild: ident '.' '*' { - if (!($$= Lex->create_item_qualified_asterisk(thd, &$1))) + if (unlikely(!($$= Lex->create_item_qualified_asterisk(thd, &$1)))) MYSQL_YYABORT; } | ident '.' ident '.' '*' { - if (!($$= Lex->create_item_qualified_asterisk(thd, &$1, &$3))) + if (unlikely(!($$= Lex->create_item_qualified_asterisk(thd, &$1, &$3)))) MYSQL_YYABORT; } ; @@ -14954,12 +15004,12 @@ table_wild: select_sublist_qualified_asterisk: ident_cli '.' '*' { - if (!($$= Lex->create_item_qualified_asterisk(thd, &$1))) + if (unlikely(!($$= Lex->create_item_qualified_asterisk(thd, &$1)))) MYSQL_YYABORT; } | ident_cli '.' ident_cli '.' '*' { - if (!($$= Lex->create_item_qualified_asterisk(thd, &$1, &$3))) + if (unlikely(!($$= Lex->create_item_qualified_asterisk(thd, &$1, &$3)))) MYSQL_YYABORT; } ; @@ -14972,23 +15022,23 @@ order_ident: simple_ident: ident_cli { - if (!($$= Lex->create_item_ident(thd, &$1))) + if (unlikely(!($$= Lex->create_item_ident(thd, &$1)))) MYSQL_YYABORT; } | ident_cli '.' ident_cli { - if (!($$= Lex->create_item_ident(thd, &$1, &$3))) + if (unlikely(!($$= Lex->create_item_ident(thd, &$1, &$3)))) MYSQL_YYABORT; } | '.' ident_cli '.' ident_cli { Lex_ident_cli empty($2.pos(), 0); - if (!($$= Lex->create_item_ident(thd, &empty, &$2, &$4))) + if (unlikely(!($$= Lex->create_item_ident(thd, &empty, &$2, &$4)))) MYSQL_YYABORT; } | ident_cli '.' ident_cli '.' ident_cli { - if (!($$= Lex->create_item_ident(thd, &$1, &$3, &$5))) + if (unlikely(!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))) MYSQL_YYABORT; } ; @@ -14996,7 +15046,7 @@ simple_ident: simple_ident_nospvar: ident { - if (!($$= Lex->create_item_ident_nosp(thd, &$1))) + if (unlikely(!($$= Lex->create_item_ident_nosp(thd, &$1)))) MYSQL_YYABORT; } | simple_ident_q { $$= $1; } @@ -15005,7 +15055,7 @@ simple_ident_nospvar: simple_ident_q: ident '.' ident { - if (!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3))) + if (unlikely(!($$= Lex->create_item_ident_nospvar(thd, &$1, &$3)))) MYSQL_YYABORT; } | simple_ident_q2 @@ -15015,12 +15065,12 @@ simple_ident_q2: '.' ident '.' ident { Lex_ident_sys none; - if (!($$= Lex->create_item_ident(thd, &none, &$2, &$4))) + if (unlikely(!($$= Lex->create_item_ident(thd, &none, &$2, &$4)))) MYSQL_YYABORT; } | ident '.' ident '.' ident { - if (!($$= Lex->create_item_ident(thd, &$1, &$3, &$5))) + if (unlikely(!($$= Lex->create_item_ident(thd, &$1, &$3, &$5)))) MYSQL_YYABORT; } ; @@ -15030,17 +15080,19 @@ field_ident: | ident '.' ident '.' ident { TABLE_LIST *table= Select->table_list.first; - if (my_strcasecmp(table_alias_charset, $1.str, table->db.str)) + if (unlikely(my_strcasecmp(table_alias_charset, $1.str, + table->db.str))) my_yyabort_error((ER_WRONG_DB_NAME, MYF(0), $1.str)); - if (my_strcasecmp(table_alias_charset, $3.str, - table->table_name.str)) + if (unlikely(my_strcasecmp(table_alias_charset, $3.str, + table->table_name.str))) my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $3.str)); $$=$5; } | ident '.' ident { TABLE_LIST *table= Select->table_list.first; - if (my_strcasecmp(table_alias_charset, $1.str, table->alias.str)) + if (unlikely(my_strcasecmp(table_alias_charset, $1.str, + table->alias.str))) my_yyabort_error((ER_WRONG_TABLE_NAME, MYF(0), $1.str)); $$=$3; } @@ -15051,20 +15103,20 @@ table_ident: ident { $$= new (thd->mem_root) Table_ident(&$1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ident '.' ident { $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | '.' ident { /* For Delphi */ $$= new (thd->mem_root) Table_ident(&$2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -15073,13 +15125,13 @@ table_ident_opt_wild: ident opt_wild { $$= new (thd->mem_root) Table_ident(&$1); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ident '.' ident opt_wild { $$= new (thd->mem_root) Table_ident(thd, &$1, &$3, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -15089,7 +15141,7 @@ table_ident_nodb: { LEX_CSTRING db={(char*) any_db,3}; $$= new (thd->mem_root) Table_ident(thd, &db, &$1, 0); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -15108,7 +15160,7 @@ ident_cli: IDENT_sys: IDENT_cli { - if (thd->to_ident_sys_alloc(&$$, &$1)) + if (unlikely(thd->to_ident_sys_alloc(&$$, &$1))) MYSQL_YYABORT; } ; @@ -15121,8 +15173,9 @@ TEXT_STRING_sys: else { LEX_STRING to; - if (thd->convert_string(&to, system_charset_info, - $1.str, $1.length, thd->charset())) + if (unlikely(thd->convert_string(&to, system_charset_info, + $1.str, $1.length, + thd->charset()))) MYSQL_YYABORT; $$.str= to.str; $$.length= to.length; @@ -15138,8 +15191,10 @@ TEXT_STRING_literal: else { LEX_STRING to; - if (thd->convert_string(&to, thd->variables.collation_connection, - $1.str, $1.length, thd->charset())) + if (unlikely(thd->convert_string(&to, + thd->variables.collation_connection, + $1.str, $1.length, + thd->charset()))) MYSQL_YYABORT; $$.str= to.str; $$.length= to.length; @@ -15155,9 +15210,10 @@ TEXT_STRING_filesystem: else { LEX_STRING to; - if (thd->convert_string(&to, - thd->variables.character_set_filesystem, - $1.str, $1.length, thd->charset())) + if (unlikely(thd->convert_string(&to, + thd->variables.character_set_filesystem, + $1.str, $1.length, + thd->charset()))) MYSQL_YYABORT; $$.str= to.str; $$.length= to.length; @@ -15169,7 +15225,7 @@ ident_table_alias: | keyword_alias { $$.str= thd->strmake($1.str, $1.length); - if ($$.str == NULL) + if (unlikely($$.str == NULL)) MYSQL_YYABORT; $$.length= $1.length; } @@ -15179,7 +15235,7 @@ ident: IDENT_sys | keyword { - if ($$.copy_keyword(thd, &$1)) + if (unlikely($$.copy_keyword(thd, &$1))) MYSQL_YYABORT; } ; @@ -15188,7 +15244,7 @@ label_ident: IDENT_sys | keyword_sp { - if ($$.copy_keyword(thd, &$1)) + if (unlikely($$.copy_keyword(thd, &$1))) MYSQL_YYABORT; } ; @@ -15202,28 +15258,28 @@ ident_or_text: user_maybe_role: ident_or_text { - if (!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER)))) + if (unlikely(!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user = $1; $$->host= null_clex_str; // User or Role, see get_current_user() $$->reset_auth(); - if (check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, - system_charset_info, 0)) + if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, + username_char_length, + system_charset_info, 0))) MYSQL_YYABORT; } | ident_or_text '@' ident_or_text { - if (!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER)))) + if (unlikely(!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user = $1; $$->host=$3; $$->reset_auth(); - if (check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, - system_charset_info, 0) || - check_host_name(&$$->host)) + if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, + username_char_length, + system_charset_info, 0)) || + unlikely(check_host_name(&$$->host))) MYSQL_YYABORT; if ($$->host.str[0]) { @@ -15245,7 +15301,7 @@ user_maybe_role: } | CURRENT_USER optional_braces { - if (!($$=(LEX_USER*)thd->calloc(sizeof(LEX_USER)))) + if (unlikely(!($$=(LEX_USER*)thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user= current_user; $$->plugin= empty_clex_str; @@ -15755,7 +15811,7 @@ set: set_stmt_option_value_following_option_type_list { LEX *lex= Lex; - if (lex->table_or_sp_used()) + if (unlikely(lex->table_or_sp_used())) my_yyabort_error((ER_SUBQUERIES_NOT_SUPPORTED, MYF(0), "SET STATEMENT")); lex->stmt_var_list= lex->var_list; lex->var_list.empty(); @@ -15778,7 +15834,7 @@ set_stmt_option_value_following_option_type_list: start_option_value_list: option_value_no_option_type { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } option_value_list_continued @@ -15788,7 +15844,7 @@ start_option_value_list: } transaction_characteristics { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } | option_type @@ -15803,13 +15859,13 @@ start_option_value_list: start_option_value_list_following_option_type: option_value_following_option_type { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } option_value_list_continued | TRANSACTION_SYM transaction_characteristics { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } ; @@ -15827,7 +15883,7 @@ option_value_list: } option_value { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } | option_value_list ',' @@ -15836,7 +15892,7 @@ option_value_list: } option_value { - if (sp_create_assignment_instr(thd, yychar == YYEMPTY)) + if (unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) MYSQL_YYABORT; } ; @@ -15875,17 +15931,17 @@ opt_var_ident_type: option_value_following_option_type: ident equal set_expr_or_default { - if (Lex->set_system_variable(Lex->option_type, &$1, $3)) + if (unlikely(Lex->set_system_variable(Lex->option_type, &$1, $3))) MYSQL_YYABORT; } | ident '.' ident equal set_expr_or_default { - if (Lex->set_system_variable(thd, Lex->option_type, &$1, &$3, $5)) + if (unlikely(Lex->set_system_variable(thd, Lex->option_type, &$1, &$3, $5))) MYSQL_YYABORT; } | DEFAULT '.' ident equal set_expr_or_default { - if (Lex->set_default_system_variable(Lex->option_type, &$3, $5)) + if (unlikely(Lex->set_default_system_variable(Lex->option_type, &$3, $5))) MYSQL_YYABORT; } ; @@ -15894,37 +15950,37 @@ option_value_following_option_type: option_value_no_option_type: ident equal set_expr_or_default { - if (Lex->set_variable(&$1, $3)) + if (unlikely(Lex->set_variable(&$1, $3))) MYSQL_YYABORT; } | ident '.' ident equal set_expr_or_default { - if (Lex->set_variable(&$1, &$3, $5)) + if (unlikely(Lex->set_variable(&$1, &$3, $5))) MYSQL_YYABORT; } | DEFAULT '.' ident equal set_expr_or_default { - if (Lex->set_default_system_variable(Lex->option_type, &$3, $5)) + if (unlikely(Lex->set_default_system_variable(Lex->option_type, &$3, $5))) MYSQL_YYABORT; } | '@' ident_or_text equal expr { - if (Lex->set_user_variable(thd, &$2, $4)) + if (unlikely(Lex->set_user_variable(thd, &$2, $4))) MYSQL_YYABORT; } | '@' '@' opt_var_ident_type ident equal set_expr_or_default { - if (Lex->set_system_variable($3, &$4, $6)) + if (unlikely(Lex->set_system_variable($3, &$4, $6))) MYSQL_YYABORT; } | '@' '@' opt_var_ident_type ident '.' ident equal set_expr_or_default { - if (Lex->set_system_variable(thd, $3, &$4, &$6, $8)) + if (unlikely(Lex->set_system_variable(thd, $3, &$4, &$6, $8))) MYSQL_YYABORT; } | '@' '@' opt_var_ident_type DEFAULT '.' ident equal set_expr_or_default { - if (Lex->set_default_system_variable($3, &$6, $8)) + if (unlikely(Lex->set_default_system_variable($3, &$6, $8))) MYSQL_YYABORT; } | charset old_or_new_charset_name_or_default @@ -15937,7 +15993,7 @@ option_value_no_option_type: set_var_collation_client(cs2, thd->variables.collation_database, cs2)); - if (var == NULL) + if (unlikely(var == NULL)) MYSQL_YYABORT; lex->var_list.push_back(var, thd->mem_root); } @@ -15959,7 +16015,7 @@ option_value_no_option_type: CHARSET_INFO *cs3; cs2= $2 ? $2 : global_system_variables.character_set_client; cs3= $3 ? $3 : cs2; - if (!my_charset_same(cs2, cs3)) + if (unlikely(!my_charset_same(cs2, cs3))) { my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), cs3->name, cs2->csname); @@ -15967,23 +16023,24 @@ option_value_no_option_type: } set_var_collation_client *var; var= new (thd->mem_root) set_var_collation_client(cs3, cs3, cs3); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); } | DEFAULT ROLE_SYM grant_role { LEX *lex = Lex; LEX_USER *user; - if (!(user=(LEX_USER *) thd->calloc(sizeof(LEX_USER)))) + if (unlikely(!(user=(LEX_USER *) thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; user->user= current_user; set_var_default_role *var= (new (thd->mem_root) set_var_default_role(user, $3->user)); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); + thd->lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -15993,9 +16050,9 @@ option_value_no_option_type: LEX *lex = Lex; set_var_default_role *var= (new (thd->mem_root) set_var_default_role($5, $3->user)); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); thd->lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -16004,18 +16061,18 @@ option_value_no_option_type: { LEX *lex = Lex; set_var_role *var= new (thd->mem_root) set_var_role($2); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); } | PASSWORD_SYM opt_for_user text_or_password { LEX *lex = Lex; set_var_password *var= (new (thd->mem_root) set_var_password(lex->definer)); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); lex->autocommit= TRUE; if (lex->sphead) lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; @@ -16034,16 +16091,17 @@ transaction_access_mode: { LEX *lex=Lex; Item *item= new (thd->mem_root) Item_int(thd, (int32) $1); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; set_var *var= (new (thd->mem_root) set_var(thd, lex->option_type, find_sys_var(thd, "tx_read_only"), &null_clex_str, item)); - if (var == NULL) + if (unlikely(var == NULL)) + MYSQL_YYABORT; + if (unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); } ; @@ -16052,16 +16110,16 @@ isolation_level: { LEX *lex=Lex; Item *item= new (thd->mem_root) Item_int(thd, (int32) $3); - if (item == NULL) + if (unlikely(item == NULL)) MYSQL_YYABORT; set_var *var= (new (thd->mem_root) set_var(thd, lex->option_type, find_sys_var(thd, "tx_isolation"), &null_clex_str, item)); - if (var == NULL) + if (unlikely(var == NULL) || + unlikely(lex->var_list.push_back(var, thd->mem_root))) MYSQL_YYABORT; - lex->var_list.push_back(var, thd->mem_root); } ; @@ -16084,9 +16142,10 @@ opt_for_user: sp_pcontext *spc= lex->spcont; LEX_CSTRING pw= { STRING_WITH_LEN("password") }; - if (spc && spc->find_variable(&pw, false)) + if (unlikely(spc && spc->find_variable(&pw, false))) my_yyabort_error((ER_SP_BAD_VAR_SHADOW, MYF(0), pw.str)); - if (!(lex->definer= (LEX_USER*) thd->calloc(sizeof(LEX_USER)))) + if (unlikely(!(lex->definer= (LEX_USER*) + thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; lex->definer->user= current_user; lex->definer->plugin= empty_clex_str; @@ -16113,19 +16172,19 @@ set_expr_or_default: | ON { $$=new (thd->mem_root) Item_string_sys(thd, "ON", 2); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | ALL { $$=new (thd->mem_root) Item_string_sys(thd, "ALL", 3); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } | BINARY { $$=new (thd->mem_root) Item_string_sys(thd, "binary", 6); - if ($$ == NULL) + if (unlikely($$ == NULL)) MYSQL_YYABORT; } ; @@ -16137,7 +16196,7 @@ lock: { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "LOCK")); lex->sql_command= SQLCOM_LOCK_TABLES; } @@ -16150,14 +16209,14 @@ opt_lock_wait_timeout: {} | WAIT_SYM ulong_num { - if (set_statement_var_if_exists(thd, STRING_WITH_LEN("lock_wait_timeout"), $2) || - set_statement_var_if_exists(thd, STRING_WITH_LEN("innodb_lock_wait_timeout"), $2)) + if (unlikely(set_statement_var_if_exists(thd, STRING_WITH_LEN("lock_wait_timeout"), $2)) || + unlikely(set_statement_var_if_exists(thd, STRING_WITH_LEN("innodb_lock_wait_timeout"), $2))) MYSQL_YYABORT; } | NOWAIT_SYM { - if (set_statement_var_if_exists(thd, STRING_WITH_LEN("lock_wait_timeout"), 0) || - set_statement_var_if_exists(thd, STRING_WITH_LEN("innodb_lock_wait_timeout"), 0)) + if (unlikely(set_statement_var_if_exists(thd, STRING_WITH_LEN("lock_wait_timeout"), 0)) || + unlikely(set_statement_var_if_exists(thd, STRING_WITH_LEN("innodb_lock_wait_timeout"), 0))) MYSQL_YYABORT; } ; @@ -16177,12 +16236,13 @@ table_lock: { thr_lock_type lock_type= (thr_lock_type) $3; bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE); - if (!Select->add_table_to_list(thd, $1, $2, 0, lock_type, + if (unlikely(!Select-> + add_table_to_list(thd, $1, $2, 0, lock_type, (lock_for_write ? lock_type == TL_WRITE_CONCURRENT_INSERT ? MDL_SHARED_WRITE : MDL_SHARED_NO_READ_WRITE : - MDL_SHARED_READ))) + MDL_SHARED_READ)))) MYSQL_YYABORT; } ; @@ -16204,7 +16264,7 @@ unlock: { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "UNLOCK")); lex->sql_command= SQLCOM_UNLOCK_TABLES; } @@ -16220,43 +16280,46 @@ handler: HANDLER_SYM table_ident OPEN_SYM opt_table_alias { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HANDLER")); lex->sql_command = SQLCOM_HA_OPEN; - if (!lex->current_select->add_table_to_list(thd, $2, $4, 0)) + if (unlikely(!lex->current_select->add_table_to_list(thd, $2, $4, + 0))) MYSQL_YYABORT; } | HANDLER_SYM table_ident_nodb CLOSE_SYM { LEX *lex= Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HANDLER")); lex->sql_command = SQLCOM_HA_CLOSE; - if (!lex->current_select->add_table_to_list(thd, $2, 0, 0)) + if (unlikely(!lex->current_select->add_table_to_list(thd, $2, 0, + 0))) MYSQL_YYABORT; } | HANDLER_SYM table_ident_nodb READ_SYM { LEX *lex=Lex; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_BADSTATEMENT, MYF(0), "HANDLER")); lex->expr_allows_subselect= FALSE; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); - if (one == NULL) + if (unlikely(one == NULL)) MYSQL_YYABORT; lex->current_select->select_limit= one; lex->current_select->offset_limit= 0; lex->limit_rows_examined= 0; - if (!lex->current_select->add_table_to_list(thd, $2, 0, 0)) + if (unlikely(!lex->current_select->add_table_to_list(thd, $2, 0, + 0))) MYSQL_YYABORT; } handler_read_or_scan opt_where_clause opt_limit_clause { Lex->expr_allows_subselect= TRUE; /* Stored functions are not supported for HANDLER READ. */ - if (Lex->uses_stored_routines()) + if (unlikely(Lex->uses_stored_routines())) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), "stored functions in HANDLER ... READ"); @@ -16285,7 +16348,7 @@ handler_rkey_function: LEX *lex=Lex; lex->ha_read_mode = RKEY; lex->ha_rkey_mode=$1; - if (!(lex->insert_list= new (thd->mem_root) List_item)) + if (unlikely(!(lex->insert_list= new (thd->mem_root) List_item))) MYSQL_YYABORT; } '(' values ')' @@ -16316,12 +16379,14 @@ revoke_command: } | grant_privileges ON FUNCTION_SYM grant_ident FROM user_and_role_list { - if (Lex->add_grant_command(thd, SQLCOM_REVOKE, TYPE_ENUM_FUNCTION)) + if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, + TYPE_ENUM_FUNCTION))) MYSQL_YYABORT; } | grant_privileges ON PROCEDURE_SYM grant_ident FROM user_and_role_list { - if (Lex->add_grant_command(thd, SQLCOM_REVOKE, TYPE_ENUM_PROCEDURE)) + if (unlikely(Lex->add_grant_command(thd, SQLCOM_REVOKE, + TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } | ALL opt_privileges ',' GRANT OPTION FROM user_and_role_list @@ -16338,7 +16403,7 @@ revoke_command: | admin_option_for_role FROM user_and_role_list { Lex->sql_command= SQLCOM_REVOKE_ROLE; - if (Lex->users_list.push_front($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_front($1, thd->mem_root))) MYSQL_YYABORT; } ; @@ -16366,13 +16431,15 @@ grant_command: | grant_privileges ON FUNCTION_SYM grant_ident TO_SYM grant_list opt_require_clause opt_grant_options { - if (Lex->add_grant_command(thd, SQLCOM_GRANT, TYPE_ENUM_FUNCTION)) + if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, + TYPE_ENUM_FUNCTION))) MYSQL_YYABORT; } | grant_privileges ON PROCEDURE_SYM grant_ident TO_SYM grant_list opt_require_clause opt_grant_options { - if (Lex->add_grant_command(thd, SQLCOM_GRANT, TYPE_ENUM_PROCEDURE)) + if (unlikely(Lex->add_grant_command(thd, SQLCOM_GRANT, + TYPE_ENUM_PROCEDURE))) MYSQL_YYABORT; } | PROXY_SYM ON user TO_SYM grant_list opt_grant_option @@ -16387,7 +16454,7 @@ grant_command: LEX *lex= Lex; lex->sql_command= SQLCOM_GRANT_ROLE; /* The first role is the one that is granted */ - if (Lex->users_list.push_front($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_front($1, thd->mem_root))) MYSQL_YYABORT; } @@ -16404,12 +16471,12 @@ opt_with_admin_option: role_list: grant_role { - if (Lex->users_list.push_back($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($1, thd->mem_root))) MYSQL_YYABORT; } | role_list ',' grant_role { - if (Lex->users_list.push_back($3, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -16417,7 +16484,7 @@ role_list: current_role: CURRENT_ROLE optional_braces { - if (!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER)))) + if (unlikely(!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user= current_role; $$->reset_auth(); @@ -16431,17 +16498,17 @@ grant_role: /* trim end spaces (as they'll be lost in mysql.user anyway) */ $1.length= cs->cset->lengthsp(cs, $1.str, $1.length); ((char*) $1.str)[$1.length] = '\0'; - if ($1.length == 0) + if (unlikely($1.length == 0)) my_yyabort_error((ER_INVALID_ROLE, MYF(0), "")); - if (!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER)))) + if (unlikely(!($$=(LEX_USER*) thd->alloc(sizeof(LEX_USER))))) MYSQL_YYABORT; $$->user= $1; $$->host= empty_clex_str; $$->reset_auth(); - if (check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, - cs, 0)) + if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, + username_char_length, + cs, 0))) MYSQL_YYABORT; } | current_role @@ -16527,21 +16594,21 @@ require_list_element: SUBJECT_SYM TEXT_STRING { LEX *lex=Lex; - if (lex->x509_subject) + if (unlikely(lex->x509_subject)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "SUBJECT")); lex->x509_subject=$2.str; } | ISSUER_SYM TEXT_STRING { LEX *lex=Lex; - if (lex->x509_issuer) + if (unlikely(lex->x509_issuer)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "ISSUER")); lex->x509_issuer=$2.str; } | CIPHER_SYM TEXT_STRING { LEX *lex=Lex; - if (lex->ssl_cipher) + if (unlikely(lex->ssl_cipher)) my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CIPHER")); lex->ssl_cipher=$2.str; } @@ -16551,11 +16618,11 @@ grant_ident: '*' { LEX *lex= Lex; - if (lex->copy_db_to(&lex->current_select->db)) + if (unlikely(lex->copy_db_to(&lex->current_select->db))) MYSQL_YYABORT; if (lex->grant == GLOBAL_ACLS) lex->grant = DB_ACLS & ~GRANT_ACL; - else if (lex->columns.elements) + else if (unlikely(lex->columns.elements)) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } | ident '.' '*' @@ -16564,7 +16631,7 @@ grant_ident: lex->current_select->db= $1; if (lex->grant == GLOBAL_ACLS) lex->grant = DB_ACLS & ~GRANT_ACL; - else if (lex->columns.elements) + else if (unlikely(lex->columns.elements)) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } | '*' '.' '*' @@ -16573,14 +16640,15 @@ grant_ident: lex->current_select->db= null_clex_str; if (lex->grant == GLOBAL_ACLS) lex->grant= GLOBAL_ACLS & ~GRANT_ACL; - else if (lex->columns.elements) + else if (unlikely(lex->columns.elements)) my_yyabort_error((ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0))); } | table_ident { LEX *lex=Lex; - if (!lex->current_select->add_table_to_list(thd, $1,NULL, - TL_OPTION_UPDATING)) + if (unlikely(!lex->current_select-> + add_table_to_list(thd, $1,NULL, + TL_OPTION_UPDATING))) MYSQL_YYABORT; if (lex->grant == GLOBAL_ACLS) lex->grant = TABLE_ACLS & ~GRANT_ACL; @@ -16590,12 +16658,12 @@ grant_ident: user_list: user { - if (Lex->users_list.push_back($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($1, thd->mem_root))) MYSQL_YYABORT; } | user_list ',' user { - if (Lex->users_list.push_back($3, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -16603,12 +16671,12 @@ user_list: grant_list: grant_user { - if (Lex->users_list.push_back($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($1, thd->mem_root))) MYSQL_YYABORT; } | grant_list ',' grant_user { - if (Lex->users_list.push_back($3, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -16616,12 +16684,12 @@ grant_list: user_and_role_list: user_or_role { - if (Lex->users_list.push_back($1, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($1, thd->mem_root))) MYSQL_YYABORT; } | user_and_role_list ',' user_or_role { - if (Lex->users_list.push_back($3, thd->mem_root)) + if (unlikely(Lex->users_list.push_back($3, thd->mem_root))) MYSQL_YYABORT; } ; @@ -16634,7 +16702,7 @@ grant_user: { $$= $1; $1->pwtext= $4; - if (Lex->sql_command == SQLCOM_REVOKE) + if (unlikely(Lex->sql_command == SQLCOM_REVOKE)) MYSQL_YYABORT; } | user IDENTIFIED_SYM BY PASSWORD_SYM TEXT_STRING @@ -16676,7 +16744,7 @@ column_list_id: ident { String *new_str= new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info); - if (new_str == NULL) + if (unlikely(new_str == NULL)) MYSQL_YYABORT; List_iterator <LEX_COLUMN> iter(Lex->columns); class LEX_COLUMN *point; @@ -16694,7 +16762,7 @@ column_list_id: { LEX_COLUMN *col= (new (thd->mem_root) LEX_COLUMN(*new_str,lex->which_columns)); - if (col == NULL) + if (unlikely(col == NULL)) MYSQL_YYABORT; lex->columns.push_back(col, thd->mem_root); } @@ -16903,7 +16971,7 @@ union_clause: union_list: unit_type_decl union_option { - if (Lex->add_select_to_union_list((bool)$2, $1, TRUE)) + if (unlikely(Lex->add_select_to_union_list((bool)$2, $1, TRUE))) MYSQL_YYABORT; } union_list_part2 @@ -16919,7 +16987,7 @@ union_list: union_list_view: unit_type_decl union_option { - if (Lex->add_select_to_union_list((bool)$2, $1, TRUE)) + if (unlikely(Lex->add_select_to_union_list((bool)$2, $1, TRUE))) MYSQL_YYABORT; } query_expression_body_view @@ -16960,7 +17028,7 @@ order_or_limit: union_head_non_top: unit_type_decl union_option { - if (Lex->add_select_to_union_list((bool)$2, $1, FALSE)) + if (unlikely(Lex->add_select_to_union_list((bool)$2, $1, FALSE))) MYSQL_YYABORT; } ; @@ -16989,8 +17057,10 @@ table_value_constructor: LEX *lex=Lex; $$= lex->current_select; mysql_init_select(Lex); - if (!($$->tvc= - new (lex->thd->mem_root) table_value_constr(lex->many_values, $$, $$->options))) + if (unlikely(!($$->tvc= + new (lex->thd->mem_root) + table_value_constr(lex->many_values, $$, + $$->options)))) MYSQL_YYABORT; lex->many_values.empty(); } @@ -17040,8 +17110,8 @@ subselect: subselect_start: { LEX *lex=Lex; - if (!lex->expr_allows_subselect || - lex->sql_command == (int)SQLCOM_PURGE) + if (unlikely(!lex->expr_allows_subselect || + lex->sql_command == (int)SQLCOM_PURGE)) { thd->parse_error(); MYSQL_YYABORT; @@ -17053,7 +17123,7 @@ subselect_start: (SELECT .. ) UNION ... becomes SELECT * FROM ((SELECT ...) UNION ...) */ - if (mysql_new_select(Lex, 1, NULL)) + if (unlikely(mysql_new_select(Lex, 1, NULL))) MYSQL_YYABORT; } ; @@ -17098,7 +17168,7 @@ query_expression_option: STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; } | HIGH_PRIORITY { - if (Lex->check_simple_select(&$1)) + if (unlikely(Lex->check_simple_select(&$1))) MYSQL_YYABORT; YYPS->m_lock_type= TL_READ_HIGH_PRIORITY; YYPS->m_mdl_type= MDL_SHARED_READ; @@ -17109,13 +17179,13 @@ query_expression_option: | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; } | SQL_BUFFER_RESULT { - if (Lex->check_simple_select(&$1)) + if (unlikely(Lex->check_simple_select(&$1))) MYSQL_YYABORT; Select->options|= OPTION_BUFFER_RESULT; } | SQL_CALC_FOUND_ROWS { - if (Lex->check_simple_select(&$1)) + if (unlikely(Lex->check_simple_select(&$1))) MYSQL_YYABORT; Select->options|= OPTION_FOUND_ROWS; } @@ -17274,7 +17344,7 @@ trigger_tail: remember_name opt_if_not_exists { - if (Lex->add_create_options_with_check($2)) + if (unlikely(Lex->add_create_options_with_check($2))) MYSQL_YYABORT; } sp_name @@ -17306,7 +17376,7 @@ trigger_tail: LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; - if (lex->sphead) + if (unlikely(lex->sphead)) my_yyabort_error((ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER")); lex->stmt_definition_begin= $1; @@ -17316,7 +17386,7 @@ trigger_tail: (*static_cast<st_trg_execution_order*>(&lex->trg_chistics))= ($17); lex->trg_chistics.ordering_clause_end= lip->get_cpp_ptr(); - if (!lex->make_sp_head(thd, $4, &sp_handler_trigger)) + if (unlikely(!lex->make_sp_head(thd, $4, &sp_handler_trigger))) MYSQL_YYABORT; lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); @@ -17330,7 +17400,7 @@ trigger_tail: sp->set_stmt_end(thd); sp->restore_thd_mem_root(thd); - if (sp->is_not_allowed_in_function("trigger")) + if (unlikely(sp->is_not_allowed_in_function("trigger"))) MYSQL_YYABORT; /* @@ -17338,11 +17408,11 @@ trigger_tail: sp_proc_stmt alternatives are not saving/restoring LEX, so lex->query_tables can be wiped out. */ - if (!lex->select_lex.add_table_to_list(thd, $10, - (LEX_CSTRING*) 0, - TL_OPTION_UPDATING, - TL_READ_NO_INSERT, - MDL_SHARED_NO_WRITE)) + if (unlikely(!lex->select_lex. + add_table_to_list(thd, $10, (LEX_CSTRING*) 0, + TL_OPTION_UPDATING, + TL_READ_NO_INSERT, + MDL_SHARED_NO_WRITE))) MYSQL_YYABORT; } ; @@ -17358,9 +17428,9 @@ udf_tail: RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys { LEX *lex= thd->lex; - if (lex->add_create_options_with_check($1)) + if (unlikely(lex->add_create_options_with_check($1))) MYSQL_YYABORT; - if (is_native_function(thd, & $2)) + if (unlikely(is_native_function(thd, & $2))) my_yyabort_error((ER_NATIVE_FCT_NAME_COLLISION, MYF(0), $2.str)); lex->sql_command= SQLCOM_CREATE_FUNCTION; lex->udf.name= $2; @@ -17380,7 +17450,8 @@ sf_return_type: } type_with_opt_collate { - if (Lex->sphead->fill_field_definition(thd, Lex->last_field)) + if (unlikely(Lex->sphead->fill_field_definition(thd, + Lex->last_field))) MYSQL_YYABORT; } ; @@ -17390,8 +17461,8 @@ sf_tail: sp_name { Lex->sql_command= SQLCOM_CREATE_SPFUNCTION; - if (!Lex->make_sp_head_no_recursive(thd, $1, $2, - &sp_handler_function)) + if (unlikely(!Lex->make_sp_head_no_recursive(thd, $1, $2, + &sp_handler_function))) MYSQL_YYABORT; } sp_parenthesized_fdparam_list @@ -17406,7 +17477,7 @@ sf_tail: } sp_proc_stmt_in_returns_clause { - if (Lex->sp_body_finalize_function(thd)) + if (unlikely(Lex->sp_body_finalize_function(thd))) MYSQL_YYABORT; } ; @@ -17415,8 +17486,8 @@ sp_tail: opt_if_not_exists sp_name { Lex->sql_command= SQLCOM_CREATE_PROCEDURE; - if (!Lex->make_sp_head_no_recursive(thd, $1, $2, - &sp_handler_procedure)) + if (unlikely(!Lex->make_sp_head_no_recursive(thd, $1, $2, + &sp_handler_procedure))) MYSQL_YYABORT; } sp_parenthesized_pdparam_list @@ -17427,7 +17498,7 @@ sp_tail: } sp_proc_stmt { - if (Lex->sp_body_finalize_procedure(thd)) + if (unlikely(Lex->sp_body_finalize_procedure(thd))) MYSQL_YYABORT; } ; @@ -17483,21 +17554,21 @@ xid: text_string { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE); - if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) + if (unlikely(!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))) MYSQL_YYABORT; Lex->xid->set(1L, $1->ptr(), $1->length(), 0, 0); } | text_string ',' text_string { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); - if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) + if (unlikely(!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))) MYSQL_YYABORT; Lex->xid->set(1L, $1->ptr(), $1->length(), $3->ptr(), $3->length()); } | text_string ',' text_string ',' ulong_num { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); - if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) + if (unlikely(!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))) MYSQL_YYABORT; Lex->xid->set($5, $1->ptr(), $1->length(), $3->ptr(), $3->length()); } |