diff options
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 4c1e2a51fbf..3318faf3f90 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2004, 2012, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -430,7 +431,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) /* We don't allow creating triggers on tables in the 'mysql' schema */ - if (create && !my_strcasecmp(system_charset_info, "mysql", tables->db.str)) + if (create && lex_string_eq(&tables->db, STRING_WITH_LEN("mysql"))) { my_error(ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA, MYF(0)); DBUG_RETURN(TRUE); @@ -588,7 +589,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) Ignore the return value for now. It's better to keep master/slave in consistent state. */ - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) thd->clear_error(); /* @@ -1240,6 +1241,7 @@ bool Table_triggers_list::prepare_record_accessors(TABLE *table) return 1; f->flags= (*fld)->flags; + f->invisible= (*fld)->invisible; f->null_ptr= null_ptr; f->null_bit= null_bit; if (null_bit == 128) @@ -1368,12 +1370,12 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, List_iterator_fast<LEX_CSTRING> it_connection_cl_name(trigger_list->connection_cl_names); List_iterator_fast<LEX_CSTRING> it_db_cl_name(trigger_list->db_cl_names); List_iterator_fast<ulonglong> it_create_times(trigger_list->create_times); - LEX *old_lex= thd->lex, *old_stmt_lex= thd->stmt_lex; + LEX *old_lex= thd->lex; LEX lex; sp_rcontext *save_spcont= thd->spcont; sql_mode_t save_sql_mode= thd->variables.sql_mode; - thd->lex= thd->stmt_lex= &lex; + thd->lex= &lex; save_db= thd->db; thd->reset_db(db); @@ -1475,7 +1477,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, &lex.trg_chistics.anchor_trigger_name, trigger); - if (parse_error) + if (unlikely(parse_error)) { LEX_CSTRING *name; @@ -1489,10 +1491,10 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, DBUG_ASSERT(lex.sphead == 0); lex_end(&lex); - if ((name= error_handler.get_trigger_name())) + if (likely((name= error_handler.get_trigger_name()))) { - if (!(make_lex_string(&trigger->name, name->str, - name->length, &table->mem_root))) + if (unlikely(!(make_lex_string(&trigger->name, name->str, + name->length, &table->mem_root)))) goto err_with_lex_cleanup; } trigger->definer= ((!trg_definer || !trg_definer->length) ? @@ -1590,7 +1592,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, } thd->reset_db(&save_db); thd->lex= old_lex; - thd->stmt_lex= old_stmt_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; @@ -1604,7 +1605,6 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, err_with_lex_cleanup: lex_end(&lex); thd->lex= old_lex; - thd->stmt_lex= old_stmt_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; thd->reset_db(&save_db); @@ -1613,7 +1613,7 @@ err_with_lex_cleanup: } error: - if (!thd->is_error()) + if (unlikely(!thd->is_error())) { /* We don't care about this error message much because .TRG files will @@ -1889,7 +1889,7 @@ change_table_name_in_triggers(THD *thd, thd->variables.sql_mode= save_sql_mode; - if (thd->is_fatal_error) + if (unlikely(thd->is_fatal_error)) return TRUE; /* OOM */ if (save_trigger_file(thd, new_db_name, new_table_name)) @@ -2101,9 +2101,9 @@ bool Table_triggers_list::change_table_name(THD *thd, const LEX_CSTRING *db, goto end; } } - if (table.triggers->change_table_name_in_triggers(thd, db, new_db, - old_alias, - new_table)) + if (unlikely(table.triggers->change_table_name_in_triggers(thd, db, new_db, + old_alias, + new_table))) { result= 1; goto end; @@ -2247,7 +2247,7 @@ add_tables_and_routines_for_triggers(THD *thd, { sp_head *trigger= triggers->body; - if (!triggers->body) // Parse error + if (unlikely(!triggers->body)) // Parse error continue; MDL_key key(MDL_key::TRIGGER, trigger->m_db.str, trigger->m_name.str); |