diff options
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 5d175be74e1..4a99296a7a5 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -38,12 +38,13 @@ static File_option triggers_file_parameters[]= methods. RETURN VALUE - 0 - Success, non-0 in case of error. + FALSE Success + TRUE error */ -int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) +bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { TABLE *table; - int result= 0; + bool result= 0; DBUG_ENTER("mysql_create_or_drop_trigger"); @@ -53,7 +54,7 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) */ if (open_and_lock_tables(thd, tables)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* TODO: We should check if user has TRIGGER privilege for table here. @@ -61,7 +62,7 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) we don't have proper privilege checking for triggers in place yet. */ if (check_global_access(thd, SUPER_ACL)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); table= tables->table; @@ -73,20 +74,21 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) */ if (tables->view || table->tmp_table != NO_TMP_TABLE) { - my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias); - DBUG_RETURN(-1); + my_printf_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, + ER(ER_TRG_ON_VIEW_OR_TEMP_TABLE), MYF(0), tables->alias); + DBUG_RETURN(TRUE); } if (!table->triggers) { if (!create) { - my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); - DBUG_RETURN(-1); + my_message(ER_TRG_DOES_NOT_EXIST, ER(ER_TRG_DOES_NOT_EXIST), MYF(0)); + DBUG_RETURN(TRUE); } if (!(table->triggers= new (&table->mem_root) Table_triggers_list())) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* @@ -96,12 +98,12 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) global read lock is held without helding LOCK_open). */ if (wait_if_global_read_lock(thd, 0, 0)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); VOID(pthread_mutex_lock(&LOCK_open)); - if ((create ? table->triggers->create_trigger(thd, tables): - table->triggers->drop_trigger(thd, tables))) - result= -1; + result= (create ? + table->triggers->create_trigger(thd, tables): + table->triggers->drop_trigger(thd, tables)); /* It is sensible to invalidate table in any case */ close_cached_table(thd, table); @@ -140,7 +142,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) /* We don't allow creation of several triggers of the same type yet */ if (bodies[lex->trg_chistics.event][lex->trg_chistics.action_time]) { - my_error(ER_TRG_ALREADY_EXISTS, MYF(0)); + my_message(ER_TRG_ALREADY_EXISTS, ER(ER_TRG_ALREADY_EXISTS), MYF(0)); return 1; } @@ -150,7 +152,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) if (my_strcasecmp(system_charset_info, lex->name_and_length.str, name->str) == 0) { - my_error(ER_TRG_ALREADY_EXISTS, MYF(0)); + my_message(ER_TRG_ALREADY_EXISTS, ER(ER_TRG_ALREADY_EXISTS), MYF(0)); return 1; } } @@ -256,7 +258,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables) } } - my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); + my_message(ER_TRG_DOES_NOT_EXIST, ER(ER_TRG_DOES_NOT_EXIST), MYF(0)); return 1; } @@ -416,8 +418,8 @@ err_with_lex_cleanup: We don't care about this error message much because .TRG files will be merged into .FRM anyway. */ - my_error(ER_WRONG_OBJECT, MYF(0), table_name, triggers_file_ext, - "TRIGGER"); + my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0), + table_name, triggers_file_ext, "TRIGGER"); DBUG_RETURN(1); } |