diff options
author | unknown <bell@sanja.is.com.ua> | 2004-11-12 14:34:00 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-11-12 14:34:00 +0200 |
commit | 9e921615a1c3147961dc4a8314ebb0e455ea105b (patch) | |
tree | 7591e416fa1685ed1e41707824091a5ca7f9c2c1 | |
parent | 17cf3c633eb1db29457cbd62c5fc022d07d5dd6d (diff) | |
download | mariadb-git-9e921615a1c3147961dc4a8314ebb0e455ea105b.tar.gz |
post-review fixes
mysql-test/r/rpl_rotate_logs.result:
removed host dependence in error messages
mysql-test/t/rpl_rotate_logs.test:
removed host dependence in error messages
mysys/my_error.c:
comment about using my_error family functions
sql/filesort.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/ha_innodb.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/handler.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item_cmpfunc.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item_func.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item_strfunc.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item_subselect.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/item_sum.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/lock.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/log.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/mysql_priv.h:
error check moved to fill_record
sql/mysqld.cc:
fixed error messages
sql/parse_file.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/protocol.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/protocol_cursor.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/repl_failsafe.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/set_var.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/slave.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sp.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sp_head.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sp_rcontext.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_acl.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_analyse.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_base.cc:
changing my_error on my_message and my_printf_error where if they are prefered
error check moved to fill_record
sql/sql_class.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_class.h:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_db.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_delete.cc:
changing my_error on my_message and my_printf_error where if they are prefered
error check moved to fill_record
sql/sql_handler.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_help.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_insert.cc:
changing my_error on my_message and my_printf_error where if they are prefered
error check moved to fill_record
sql/sql_lex.cc:
layout fixed
sql/sql_load.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_map.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_parse.cc:
error check moved to fill_record
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_prepare.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_rename.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_repl.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_select.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_show.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_table.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_trigger.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_udf.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_union.cc:
error check moved to fill_record
sql/sql_update.cc:
error check moved to fill_record
sql/sql_view.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/sql_yacc.yy:
changing my_error on my_message and my_printf_error where if they are prefered
sql/table.cc:
changing my_error on my_message and my_printf_error where if they are prefered
sql/unireg.cc:
changing my_error on my_message and my_printf_error where if they are prefered
53 files changed, 938 insertions, 593 deletions
diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 29dd1ead381..cfd296fd44b 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -1,7 +1,7 @@ drop table if exists t1, t2, t3, t4; drop table if exists t1, t2, t3, t4; start slave; -ERROR HY000: File '/home/bell/mysql/bk/work-error-5.0/mysql-test/var/slave-data/master.info' not found (Errcode: 13) +ERROR HY000: File 'TESTDIR/var/slave-data/master.info' not found (Errcode: 13) start slave; ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root'; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 4bb1acbf748..63ddf495347 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -23,6 +23,7 @@ drop table if exists t1, t2, t3, t4; # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) +--replace_result $MYSQL_TEST_DIR TESTDIR --error 1105 start slave; system chmod 600 var/slave-data/master.info; diff --git a/mysys/my_error.c b/mysys/my_error.c index 8a377f63c7e..75aa84efca0 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -22,6 +22,18 @@ /* Define some external variables for error handling */ +/* + WARNING! + my_error family functions have to be used according following rules: + - if message have not parameters use my_message(ER_CODE, ER(ER_CODE), MYF(N)) + - if message have only integer parameters, string constants (created + inside program) or string put (and cut if it is need) in some limited + length buffer before passing it as parameter then you can use + my_error(ER_CODE, MYF(N), ...). Never pass string get from user to + my_error. + - in all other cases use my_printf_error(ER_CODE, ER(ER_CODE), MYF(N), ...) +*/ + const char ** NEAR my_errmsg[MAXMAPS]={0,0,0,0}; char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; diff --git a/sql/filesort.cc b/sql/filesort.cc index ef8148616e5..09d51e31291 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -278,7 +278,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, } } if (error) - my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG)); + my_message(ER_FILSORT_ABORT, ER(ER_FILSORT_ABORT), + MYF(ME_ERROR+ME_WAITTANG)); else statistic_add(thd->status_var.filesort_rows, (ulong) records, &LOCK_status); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 547acb63766..c93edef0795 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -462,8 +462,10 @@ innobase_mysql_tmpfile(void) if (fd2 < 0) { DBUG_PRINT("error",("Got error %d on dup",fd2)); my_errno=errno; - my_error(EE_OUT_OF_FILERESOURCES, - MYF(ME_BELL+ME_WAITTANG), filename, my_errno); + my_printf_error(EE_OUT_OF_FILERESOURCES, + ER(EE_OUT_OF_FILERESOURCES), + MYF(ME_BELL+ME_WAITTANG), + filename, my_errno); } my_close(fd, MYF(MY_WME)); } diff --git a/sql/handler.cc b/sql/handler.cc index 5185e7f8921..62b6b591b3d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -515,7 +515,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) if ((error=ndbcluster_commit(thd,trans->ndb_tid))) { if (error == -1) - my_error(ER_ERROR_DURING_COMMIT, MYF(0)); + my_message_(ER_ERROR_DURING_COMMIT, ER(ER_ERROR_DURING_COMMIT), + MYF(0)); error=1; } if (trans == &thd->transaction.all) @@ -584,7 +585,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) if ((error=ndbcluster_rollback(thd, trans->ndb_tid))) { if (error == -1) - my_error(ER_ERROR_DURING_ROLLBACK, MYF(0)); + my_message(ER_ERROR_DURING_ROLLBACK, ER(ER_ERROR_DURING_ROLLBACK), + MYF(0)); error=1; } trans->ndb_tid = 0; @@ -1183,7 +1185,8 @@ void handler::print_error(int error, myf errflag) str.length(max_length-4); str.append("..."); } - my_error(ER_DUP_ENTRY,MYF(0),str.c_ptr(),key_nr+1); + my_printf_error(ER_DUP_ENTRY, ER(ER_DUP_ENTRY), MYF(0), + str.c_ptr(), key_nr+1); DBUG_VOID_RETURN; } textno=ER_DUP_KEY; @@ -1205,7 +1208,7 @@ void handler::print_error(int error, myf errflag) textno=ER_CRASHED_ON_REPAIR; break; case HA_ERR_OUT_OF_MEM: - my_error(ER_OUT_OF_RESOURCES,errflag); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), errflag); DBUG_VOID_RETURN; case HA_ERR_WRONG_COMMAND: textno=ER_ILLEGAL_HA; @@ -1251,9 +1254,13 @@ void handler::print_error(int error, myf errflag) { const char* engine= table_type(); if (temporary) - my_error(ER_GET_TEMPORARY_ERRMSG,MYF(0),error,str.ptr(),engine); + my_printf_error(ER_GET_TEMPORARY_ERRMSG, + ER(ER_GET_TEMPORARY_ERRMSG), MYF(0), + error, str.ptr(), engine); else - my_error(ER_GET_ERRMSG,MYF(0),error,str.ptr(),engine); + my_printf_error(ER_GET_ERRMSG, + ER(ER_GET_ERRMSG), MYF(0), + error, str.ptr(), engine); } else my_error(ER_GET_ERRNO,errflag,error); @@ -1381,7 +1388,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, error=table.file->create(name,&table,create_info); VOID(closefrm(&table)); if (error) - my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error); + my_printf_error(ER_CANT_CREATE_TABLE, ER(ER_CANT_CREATE_TABLE), + MYF(ME_BELL+ME_WAITTANG), + name,error); DBUG_RETURN(error != 0); } diff --git a/sql/item.cc b/sql/item.cc index 7279c18099b..ff6b74144a8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1512,8 +1512,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { if (!(*refer)->fixed) { - my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, - "forward reference in item list"); + my_printf_error(ER_ILLEGAL_REFERENCE, ER(ER_ILLEGAL_REFERENCE), + MYF(0), name, "forward reference in item list"); return TRUE; } @@ -2418,8 +2418,9 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) { if (!(*ref)->fixed) { - my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, - "forward reference in item list"); + my_printf_error(ER_ILLEGAL_REFERENCE, + ER(ER_ILLEGAL_REFERENCE), MYF(0), + name, "forward reference in item list"); return TRUE; } mark_as_dependent(thd, last, thd->lex->current_select, @@ -2433,8 +2434,9 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) { if (!(*ref)->fixed) { - my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, - "forward reference in item list"); + my_printf_error(ER_ILLEGAL_REFERENCE, + ER(ER_ILLEGAL_REFERENCE), MYF(0), + name, "forward reference in item list"); return TRUE; } ref= thd->lex->current_select->ref_pointer_array + counter; @@ -2454,10 +2456,11 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) thd->lex->current_select->having_fix_field))) || !(*ref)->fixed) { - my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, - ((*ref)->with_sum_func? - "reference on group function": - "forward reference in item list")); + my_printf_error(ER_ILLEGAL_REFERENCE, ER(ER_ILLEGAL_REFERENCE), MYF(0), + name, + ((*ref)->with_sum_func? + "reference on group function": + "forward reference in item list")); return TRUE; } max_length= (*ref)->max_length; @@ -3115,11 +3118,12 @@ bool Item_type_holder::join_types(THD *thd, Item *item) *old_derivation= collation.derivation_name(); if (item_type == STRING_RESULT && collation.aggregate(item->collation)) { - my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), - old_cs, old_derivation, - item->collation.collation->name, - item->collation.derivation_name(), - "UNION"); + my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS, + ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0), + old_cs, old_derivation, + item->collation.collation->name, + item->collation.derivation_name(), + "UNION"); return 1; } diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f680ab1f20f..59d21cdfc59 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -53,10 +53,11 @@ static void agg_cmp_type(Item_result *type, Item **items, uint nitems) static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) { - my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), - c1.collation->name,c1.derivation_name(), - c2.collation->name,c2.derivation_name(), - fname); + my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS, + ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0), + c1.collation->name,c1.derivation_name(), + c2.collation->name,c2.derivation_name(), + fname); } diff --git a/sql/item_func.cc b/sql/item_func.cc index b09824fb184..f9cf7341405 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -45,10 +45,11 @@ bool check_reserved_words(LEX_STRING *name) static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) { - my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), - c1.collation->name,c1.derivation_name(), - c2.collation->name,c2.derivation_name(), - fname); + my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS, + ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0), + c1.collation->name, c1.derivation_name(), + c2.collation->name, c2.derivation_name(), + fname); } static void my_coll_agg_error(DTCollation &c1, @@ -56,11 +57,12 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c3, const char *fname) { - my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0), - c1.collation->name,c1.derivation_name(), - c2.collation->name,c2.derivation_name(), - c3.collation->name,c3.derivation_name(), - fname); + my_printf_error(ER_CANT_AGGREGATE_3COLLATIONS, + ER(ER_CANT_AGGREGATE_3COLLATIONS), MYF(0), + c1.collation->name, c1.derivation_name(), + c2.collation->name, c2.derivation_name(), + c3.collation->name, c3.derivation_name(), + fname); } @@ -74,7 +76,8 @@ static void my_coll_agg_error(Item** args, uint count, const char *fname) args[2]->collation, fname); else - my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname); + my_printf_error(ER_CANT_AGGREGATE_NCOLLATIONS, + ER(ER_CANT_AGGREGATE_NCOLLATIONS), MYF(0),fname); } @@ -3112,7 +3115,8 @@ err: key=NO_SUCH_KEY; return 0; } - my_error(ER_FT_MATCHING_KEY_NOT_FOUND,MYF(0)); + my_message(ER_FT_MATCHING_KEY_NOT_FOUND, + ER(ER_FT_MATCHING_KEY_NOT_FOUND), MYF(0)); return 1; } @@ -3241,7 +3245,8 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, { if (!var->is_struct()) { - my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), base_name->str); + my_printf_error(ER_VARIABLE_IS_NOT_STRUCT, ER(ER_VARIABLE_IS_NOT_STRUCT), + MYF(0), base_name->str); return 0; } } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b3665edad39..6e9467a7a71 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -42,10 +42,11 @@ String my_empty_string("",default_charset_info); static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) { - my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), - c1.collation->name,c1.derivation_name(), - c2.collation->name,c2.derivation_name(), - fname); + my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS, + ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0), + c1.collation->name, c1.derivation_name(), + c2.collation->name, c2.derivation_name(), + fname); } uint nr_of_decimals(const char *str) @@ -2243,7 +2244,8 @@ void Item_func_set_collation::fix_length_and_dec() { if (!(set_collation= get_charset_by_name(colname,MYF(0)))) { - my_error(ER_UNKNOWN_COLLATION, MYF(0), colname); + my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0), + colname); return; } } @@ -2251,8 +2253,9 @@ void Item_func_set_collation::fix_length_and_dec() if (!set_collation || !my_charset_same(args[0]->collation.collation,set_collation)) { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - colname,args[0]->collation.collation->csname); + my_printf_error(ER_COLLATION_CHARSET_MISMATCH, + ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0), + colname, args[0]->collation.collation->csname); return; } collation.set(set_collation, DERIVATION_EXPLICIT); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 8fe6e5c81dd..d2d9aa8c8b6 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -167,7 +167,8 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) // We can't substitute aggregate functions like "SELECT (max(i))" if (substype() == SINGLEROW_SUBS && (*ref)->with_sum_func) { - my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); + my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), + MYF(0)); return TRUE; } return ret; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b355cc15806..8ec2e8fa9d9 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -220,7 +220,8 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (!thd->allow_sum_func) { - my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); + my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), + MYF(0)); return TRUE; } thd->allow_sum_func=0; // No included group funcs @@ -255,7 +256,8 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item *item= args[0]; if (!thd->allow_sum_func) { - my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); + my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), + MYF(0)); return TRUE; } thd->allow_sum_func=0; // No included group funcs @@ -2065,7 +2067,8 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (!thd->allow_sum_func) { - my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); + my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), + MYF(0)); return TRUE; } diff --git a/sql/lock.cc b/sql/lock.cc index debfb900c23..e11c48a7a7e 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -430,7 +430,8 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, *write_lock_used=table; if (table->db_stat & HA_READ_ONLY) { - my_error(ER_OPEN_AS_READONLY,MYF(0),table->table_name); + my_printf_error(ER_OPEN_AS_READONLY, ER(ER_OPEN_AS_READONLY), MYF(0), + table->table_name); my_free((gptr) sql_lock,MYF(0)); return 0; } @@ -794,7 +795,8 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, { if (thd->global_read_lock) // This thread had the read locks { - my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0)); + my_message(ER_CANT_UPDATE_WITH_READLOCK, + ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0)); (void) pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(1); } diff --git a/sql/log.cc b/sql/log.cc index ab080366f95..429ef8bd339 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1515,9 +1515,10 @@ err: if (error) { if (my_errno == EFBIG) - my_error(ER_TRANS_CACHE_FULL, MYF(0)); + my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0)); else - my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno); + my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0), + name, errno); write_error=1; } if (file == &log_file) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a8ca32f3d7e..aa6ce7ba888 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -608,8 +608,8 @@ bool mysql_rename_table(enum db_type base, bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys); bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info); -int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, - Item **conds, uint order_num, ORDER *order); +bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, + Item **conds, uint order_num, ORDER *order); bool mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, List<Item> &values,COND *conds, uint order_num, ORDER *order, ha_rows limit, @@ -813,8 +813,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table, bool return_if_owned_by_thd=0); bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables); void copy_field_from_tmp_record(Field *field,int offset); -int fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors); -int fill_record(Field **field,List<Item> &values, bool ignore_errors); +bool fill_record(THD *thd, List<Item> &fields, List<Item> &values, + bool ignore_errors); +bool fill_record(THD *thd, Field **field, List<Item> &values, + bool ignore_errors); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild); inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f2c235cac99..4a8c12b5d76 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1145,7 +1145,8 @@ static void server_init(void) WSADATA WsaData; if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) { - my_error(ER_WSAS_FAILED, MYF(0)); + /* errors are not read yet, so we use test here */ + my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0)); unireg_abort(1); } } diff --git a/sql/parse_file.cc b/sql/parse_file.cc index f548c16d808..61b5b301503 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -350,7 +350,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, if (stat_info.st_size > INT_MAX-1) { - my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str); + my_printf_error(ER_FPARSER_TOO_BIG_FILE, + ER(ER_FPARSER_TOO_BIG_FILE), MYF(0), file_name->str); DBUG_RETURN(0); } @@ -412,7 +413,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, frm_error: if (bad_format_errors) { - my_error(ER_FPARSER_BAD_HEADER, MYF(0), file_name->str); + my_printf_error(ER_FPARSER_BAD_HEADER, ER(ER_FPARSER_BAD_HEADER), MYF(0), + file_name->str); DBUG_RETURN(0); } else @@ -627,7 +629,8 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, // it is comment if (!(ptr= strchr(ptr, '\n'))) { - my_error(ER_FPARSER_EOF_IN_COMMENT, MYF(0), line); + my_printf_error(ER_FPARSER_EOF_IN_COMMENT, + ER(ER_FPARSER_EOF_IN_COMMENT), MYF(0), line); DBUG_RETURN(TRUE); } ptr++; @@ -669,8 +672,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, (LEX_STRING *)(base + parameter->offset)))) { - my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), - parameter->name.str, line); + my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER, + ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0), + parameter->name.str, line); DBUG_RETURN(TRUE); } break; @@ -681,8 +685,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, (LEX_STRING *) (base + parameter->offset)))) { - my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), - parameter->name.str, line); + my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER, + ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0), + parameter->name.str, line); DBUG_RETURN(TRUE); } break; @@ -691,8 +696,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, case FILE_OPTIONS_REV: if (!(eol= strchr(ptr, '\n'))) { - my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), - parameter->name.str, line); + my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER, + ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0), + parameter->name.str, line); DBUG_RETURN(TRUE); } { @@ -709,8 +715,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, /* yyyy-mm-dd HH:MM:SS = 19(PARSE_FILE_TIMESTAMPLENGTH) characters */ if (ptr[PARSE_FILE_TIMESTAMPLENGTH] != '\n') { - my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), - parameter->name.str, line); + my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER, + ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0), + parameter->name.str, line); DBUG_RETURN(TRUE); } memcpy(val->str, ptr, PARSE_FILE_TIMESTAMPLENGTH); @@ -763,8 +770,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, break; list_err_w_message: - my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), - parameter->name.str, line); + my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER, + ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0), + parameter->name.str, line); list_err: if (change_mem) my_pthread_setspecific_ptr(THR_MALLOC, sql_mem); @@ -779,8 +787,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, // skip unknown parameter if (!(ptr= strchr(ptr, '\n'))) { - my_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, MYF(0), - line); + my_printf_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, + ER(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER), MYF(0), + line); DBUG_RETURN(TRUE); } ptr++; diff --git a/sql/protocol.cc b/sql/protocol.cc index b8414e45c97..710618b0647 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -611,7 +611,8 @@ bool Protocol::send_fields(List<Item> *list, int flags) DBUG_RETURN(prepare_for_send(list)); err: - my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */ + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), + MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 0954bb5466f..3106420a0e5 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -85,7 +85,8 @@ bool Protocol_cursor::send_fields(List<Item> *list, int flags) DBUG_RETURN(FALSE); err: - my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */ + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), + MYF(0)); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */ } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 6ba1ce6267f..0d6ed33e952 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -451,8 +451,9 @@ bool show_new_master(THD* thd) if (translate_master(thd, lex_mi, errmsg)) { if (errmsg[0]) - my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), - "SHOW NEW MASTER", errmsg); + my_printf_error(ER_ERROR_WHEN_EXECUTING_COMMAND, + ER(ER_ERROR_WHEN_EXECUTING_COMMAND), MYF(0), + "SHOW NEW MASTER", errmsg); DBUG_RETURN(TRUE); } else @@ -783,7 +784,7 @@ bool load_master_data(THD* thd) (error=terminate_slave_threads(active_mi,restart_thread_mask, 1 /*skip lock*/))) { - my_error(error, MYF(0)); + my_message(error, ER(error), MYF(0)); unlock_slave_threads(active_mi); pthread_mutex_unlock(&LOCK_active_mi); return TRUE; @@ -791,7 +792,8 @@ bool load_master_data(THD* thd) if (connect_to_master(thd, &mysql, active_mi)) { - my_error(error= ER_CONNECT_TO_MASTER, MYF(0), mysql_error(&mysql)); + my_printf_error(error= ER_CONNECT_TO_MASTER, + ER(ER_CONNECT_TO_MASTER), MYF(0), mysql_error(&mysql)); goto err; } @@ -803,7 +805,8 @@ bool load_master_data(THD* thd) if (mysql_real_query(&mysql, "SHOW DATABASES", 14) || !(db_res = mysql_store_result(&mysql))) { - my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); + my_printf_error(error = ER_QUERY_ON_MASTER, + ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql)); goto err; } @@ -816,7 +819,7 @@ bool load_master_data(THD* thd) if (!(table_res = (MYSQL_RES**)thd->alloc(num_dbs * sizeof(MYSQL_RES*)))) { - my_error(error = ER_OUTOFMEMORY, MYF(0)); + my_message(error = ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0)); goto err; } @@ -830,7 +833,8 @@ bool load_master_data(THD* thd) mysql_real_query(&mysql, "SHOW MASTER STATUS",18) || !(master_status_res = mysql_store_result(&mysql))) { - my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); + my_printf_error(error = ER_QUERY_ON_MASTER, + ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql)); goto err; } @@ -883,7 +887,8 @@ bool load_master_data(THD* thd) mysql_real_query(&mysql, "SHOW TABLES", 11) || !(*cur_table_res = mysql_store_result(&mysql))) { - my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); + my_printf_error(error = ER_QUERY_ON_MASTER, + ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql)); cleanup_mysql_results(db_res, cur_table_res - 1, table_res); goto err; } @@ -921,7 +926,7 @@ bool load_master_data(THD* thd) if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0)) - my_error(ER_MASTER_INFO, MYF(0)); + my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0)); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error); @@ -940,7 +945,8 @@ bool load_master_data(THD* thd) if (mysql_real_query(&mysql, "UNLOCK TABLES", 13)) { - my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); + my_printf_error(error = ER_QUERY_ON_MASTER, + ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql)); goto err; } } @@ -949,7 +955,7 @@ bool load_master_data(THD* thd) 0 /* not only reset, but also reinit */, &errmsg)) { - my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg); + my_printf_error(ER_RELAY_LOG_FAIL, ER(ER_RELAY_LOG_FAIL), MYF(0), errmsg); unlock_slave_threads(active_mi); pthread_mutex_unlock(&LOCK_active_mi); return TRUE; diff --git a/sql/set_var.cc b/sql/set_var.cc index 8195792419e..59ca464182d 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -884,8 +884,8 @@ bool sys_var_str::check(THD *thd, set_var *var) return 0; if ((res=(*check_func)(thd, var)) < 0) - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, - var->value->str_value.ptr()); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0), + name, var->value->str_value.ptr()); return res; } @@ -1159,7 +1159,8 @@ static int check_max_delayed_threads(THD *thd, set_var *var) val != (longlong) global_system_variables.max_insert_delayed_threads) { char buf[64]; - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, llstr(val, buf)); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), + MYF(0), var->var->name, llstr(val, buf)); return 1; } return 0; @@ -1457,7 +1458,8 @@ bool sys_var::check_enum(THD *thd, set_var *var, TYPELIB *enum_names) return 0; err: - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, value); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0), + name, value); return 1; } @@ -1496,7 +1498,8 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names) return 0; err: - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), + MYF(0), name, buff); return 1; } @@ -1520,8 +1523,9 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) { if (var_type != OPT_DEFAULT) { - my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), - name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); + my_printf_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, + ER(ER_INCORRECT_GLOBAL_LOCAL_VAR), MYF(0), + name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); return 0; } /* As there was no local variable, return the global value */ @@ -1564,7 +1568,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) return tmp; } default: - my_error(ER_VAR_CANT_BE_READ, MYF(0), name); + my_printf_error(ER_VAR_CANT_BE_READ, ER(ER_VAR_CANT_BE_READ), MYF(0), + name); } return 0; } @@ -1676,7 +1681,8 @@ bool sys_var_thd_date_time_format::check(THD *thd, set_var *var) if (!(format= date_time_format_make(date_time_type, res->ptr(), res->length()))) { - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr()); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0), + name, res->c_ptr()); return 1; } @@ -1774,12 +1780,14 @@ bool sys_var_collation::check(THD *thd, set_var *var) String str(buff,sizeof(buff), system_charset_info), *res; if (!(res=var->value->val_str(&str))) { - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), + MYF(0), name, "NULL"); return 1; } if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) { - my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); + my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0), + res->c_ptr()); return 1; } } @@ -1789,7 +1797,8 @@ bool sys_var_collation::check(THD *thd, set_var *var) { char buf[20]; int10_to_str((int) var->value->val_int(), buf, -10); - my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); + my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0), + buf); return 1; } } @@ -1810,7 +1819,8 @@ bool sys_var_character_set::check(THD *thd, set_var *var) { if (!nullable) { - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + my_printf_error(ER_WRONG_VALUE_FOR_VAR, + ER(ER_WRONG_VALUE_FOR_VAR), MYF(0), name, "NULL"); return 1; } tmp= NULL; @@ -1818,7 +1828,8 @@ bool sys_var_character_set::check(THD *thd, set_var *var) else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) && !(tmp=get_old_charset_by_name(res->c_ptr()))) { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); + my_printf_error(ER_UNKNOWN_CHARACTER_SET, ER(ER_UNKNOWN_CHARACTER_SET), + MYF(0), res->c_ptr()); return 1; } } @@ -2336,7 +2347,7 @@ bool sys_var_slave_skip_counter::check(THD *thd, set_var *var) pthread_mutex_lock(&active_mi->rli.run_lock); if (active_mi->rli.slave_running) { - my_error(ER_SLAVE_MUST_STOP, MYF(0)); + my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0)); result=1; } pthread_mutex_unlock(&active_mi->rli.run_lock); @@ -2415,7 +2426,8 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var) if (!(var->save_result.time_zone= my_tz_find(res, thd->lex->time_zone_tables_used))) { - my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL"); + my_printf_error(ER_UNKNOWN_TIME_ZONE, ER(ER_UNKNOWN_TIME_ZONE), MYF(0), + res ? res->c_ptr() : "NULL"); return 1; } return 0; @@ -2697,7 +2709,8 @@ sys_var *find_sys_var(const char *str, uint length) length ? length : strlen(str)); if (!var) - my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); + my_printf_error(ER_UNKNOWN_SYSTEM_VARIABLE, ER(ER_UNKNOWN_SYSTEM_VARIABLE), + MYF(0), (char*) str); return var; } @@ -2783,9 +2796,8 @@ int set_var::check(THD *thd) { if (var->check_type(type)) { - my_error(type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE, - MYF(0), - var->name); + int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; + my_printf_error(err, ER(err), MYF(0), var->name); return -1; } if ((type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL))) @@ -2795,7 +2807,7 @@ int set_var::check(THD *thd) { if (var->check_default(type)) { - my_error(ER_NO_DEFAULT, MYF(0), var->name); + my_printf_error(ER_NO_DEFAULT, ER(ER_NO_DEFAULT), MYF(0), var->name); return -1; } return 0; @@ -2805,7 +2817,8 @@ int set_var::check(THD *thd) return -1; if (var->check_update_type(value->result_type())) { - my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name); + my_printf_error(ER_WRONG_TYPE_FOR_VAR, ER(ER_WRONG_TYPE_FOR_VAR), MYF(0), + var->name); return -1; } return var->check(thd, this) ? -1 : 0; @@ -2828,9 +2841,8 @@ int set_var::light_check(THD *thd) { if (var->check_type(type)) { - my_error(type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE, - MYF(0), - var->name); + int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; + my_printf_error(err, ER(err), MYF(0), var->name); return -1; } if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)) @@ -2896,7 +2908,7 @@ int set_var_user::update(THD *thd) if (user_var_item->update()) { /* Give an error if it's not given already */ - my_error(ER_SET_CONSTANTS_ONLY, MYF(0)); + my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0)); return -1; } return 0; @@ -2957,8 +2969,9 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var) value= "unknown"; err: - my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value); - return 1; + my_printf_error(ER_UNKNOWN_STORAGE_ENGINE, ER(ER_UNKNOWN_STORAGE_ENGINE), + MYF(0), value); + return 1; } diff --git a/sql/slave.cc b/sql/slave.cc index 2ed554e65c8..68e51eacc1e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1489,7 +1489,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, packet_len= my_net_read(net); // read create table statement if (packet_len == packet_error) { - my_error(ER_MASTER_NET_READ, MYF(0)); + my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0)); DBUG_RETURN(1); } if (net->read_pos[0] == 255) // error from master @@ -1498,7 +1498,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, err_msg= (char*) net->read_pos + ((mysql->server_capabilities & CLIENT_PROTOCOL_41) ? 3+SQLSTATE_LENGTH+1 : 3); - my_error(ER_MASTER, MYF(0), err_msg); + my_printf_error(ER_MASTER, ER(ER_MASTER), MYF(0), err_msg); DBUG_RETURN(1); } thd->command = COM_TABLE_DUMP; @@ -1507,7 +1507,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, if (!(query = thd->strmake((char*) net->read_pos, packet_len))) { sql_print_error("create_table_from_dump: out of memory"); - my_error(ER_GET_ERRNO, MYF(0), "Out of memory"); + my_message(ER_GET_ERRNO, "Out of memory", MYF(0)); DBUG_RETURN(1); } thd->query= query; @@ -1552,7 +1552,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, /* Copy the data file */ if (file->net_read_dump(net)) { - my_error(ER_MASTER_NET_READ, MYF(0)); + my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0)); sql_print_error("create_table_from_dump: failed in\ handler::net_read_dump()"); goto err; @@ -1572,7 +1572,8 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, error=file->repair(thd,&check_opt) != 0; thd->net.vio = save_vio; if (error) - my_error(ER_INDEX_REBUILD, MYF(0), tables.table->real_name); + my_printf_error(ER_INDEX_REBUILD, ER(ER_INDEX_REBUILD), MYF(0), + tables.table->real_name); err: close_thread_tables(thd); @@ -1599,7 +1600,8 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, } if (connect_to_master(thd, mysql, mi)) { - my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql)); + my_printf_error(ER_CONNECT_TO_MASTER, ER(ER_CONNECT_TO_MASTER), MYF(0), + mysql_error(mysql)); mysql_close(mysql); DBUG_RETURN(1); } diff --git a/sql/sp.cc b/sql/sp.cc index db03900f44a..4f937e0ad8e 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1001,7 +1001,8 @@ sp_cache_functions(THD *thd, LEX *lex) { delete newlex; thd->lex= oldlex; - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", ls->str); + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0), + "FUNCTION", ls->str); ret= 1; break; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 30c7524032f..9ca986a0f6a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -623,7 +623,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (args->elements != params) { - my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), + my_printf_error(ER_SP_WRONG_NO_OF_ARGS, ER(ER_SP_WRONG_NO_OF_ARGS), MYF(0), "PROCEDURE", m_name.str, params, args->elements); DBUG_RETURN(-1); } @@ -893,7 +893,8 @@ sp_head::check_backpatch(THD *thd) { if (bp->lab->type == SP_LAB_REF) { - my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name); + my_printf_error(ER_SP_LILABEL_MISMATCH, ER(ER_SP_LILABEL_MISMATCH), + MYF(0), "GOTO", bp->lab->name); return -1; } } @@ -1786,7 +1787,7 @@ sp_instr_error::execute(THD *thd, uint *nextp) { DBUG_ENTER("sp_instr_error::execute"); - my_error(m_errcode, MYF(0)); + my_message(m_errcode, ER(m_errcode), MYF(0)); *nextp= m_ip+1; DBUG_RETURN(-1); } diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index db298974c45..609882b84c6 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -153,7 +153,8 @@ sp_cursor::pre_open(THD *thd) { if (m_isopen) { - my_error(ER_SP_CURSOR_ALREADY_OPEN, MYF(0)); + my_message(ER_SP_CURSOR_ALREADY_OPEN, ER(ER_SP_CURSOR_ALREADY_OPEN), + MYF(0)); return NULL; } @@ -187,7 +188,7 @@ sp_cursor::close(THD *thd) { if (! m_isopen) { - my_error(ER_SP_CURSOR_NOT_OPEN, MYF(0)); + my_message(ER_SP_CURSOR_NOT_OPEN, ER(ER_SP_CURSOR_NOT_OPEN), MYF(0)); return -1; } destroy(); @@ -217,12 +218,12 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) if (! m_isopen) { - my_error(ER_SP_CURSOR_NOT_OPEN, MYF(0)); + my_message(ER_SP_CURSOR_NOT_OPEN, ER(ER_SP_CURSOR_NOT_OPEN), MYF(0)); return -1; } if (m_current_row == NULL) { - my_error(ER_SP_FETCH_NO_DATA, MYF(0)); + my_message(ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA), MYF(0)); return -1; } @@ -234,7 +235,8 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) if (fldcount >= m_prot->get_field_count()) { - my_error(ER_SP_WRONG_NO_OF_FETCH_ARGS, MYF(0)); + my_message(ER_SP_WRONG_NO_OF_FETCH_ARGS, + ER(ER_SP_WRONG_NO_OF_FETCH_ARGS), MYF(0)); return -1; } s= row[fldcount]; @@ -260,7 +262,8 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) } if (fldcount < m_prot->get_field_count()) { - my_error(ER_SP_WRONG_NO_OF_FETCH_ARGS, MYF(0)); + my_message(ER_SP_WRONG_NO_OF_FETCH_ARGS, + ER(ER_SP_WRONG_NO_OF_FETCH_ARGS), MYF(0)); return -1; } m_current_row= m_current_row->next; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5a419746b5d..8092c93c11e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1237,7 +1237,8 @@ bool check_change_password(THD *thd, const char *host, const char *user, } if (!thd->slave_thread && !thd->user[0]) { - my_error(ER_PASSWORD_ANONYMOUS_USER, MYF(0)); + my_message(ER_PASSWORD_ANONYMOUS_USER, ER(ER_PASSWORD_ANONYMOUS_USER), + MYF(0)); return(1); } uint len=strlen(new_password); @@ -1282,7 +1283,7 @@ bool change_password(THD *thd, const char *host, const char *user, if (!(acl_user= find_acl_user(host, user))) { VOID(pthread_mutex_unlock(&acl_cache->lock)); - my_error(ER_PASSWORD_NO_MATCH, MYF(0)); + my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0)); DBUG_RETURN(1); } /* update loaded acl entry: */ @@ -1467,7 +1468,8 @@ static bool update_user_table(THD *thd, const char *host, const char *user, (byte*) table->field[0]->ptr,0, HA_READ_KEY_EXACT)) { - my_error(ER_PASSWORD_NO_MATCH,MYF(0)); /* purecov: deadcode */ + my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), + MYF(0)); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */ } store_record(table,record[1]); @@ -1549,10 +1551,12 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, if (!create_user) { if (what == 'N') - my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str); + my_printf_error(ER_NONEXISTING_GRANT, ER(ER_NONEXISTING_GRANT), + MYF(0), combo.user.str, combo.host.str); else - my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0), - thd->user, thd->host_or_ip); + my_printf_error(ER_NO_PERMISSION_TO_CREATE_USER, + ER(ER_NO_PERMISSION_TO_CREATE_USER), MYF(0), + thd->user, thd->host_or_ip); goto end; } old_row_exists = 0; @@ -1717,7 +1721,7 @@ static int replace_db_table(TABLE *table, const char *db, /* Check if there is such a user in user table in memory? */ if (!find_acl_user(combo.host.str,combo.user.str)) { - my_error(ER_PASSWORD_NO_MATCH,MYF(0)); + my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0)); DBUG_RETURN(-1); } @@ -1729,7 +1733,8 @@ static int replace_db_table(TABLE *table, const char *db, { if (what == 'N') { // no row, no revoke - my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str); + my_printf_error(ER_NONEXISTING_GRANT, ER(ER_NONEXISTING_GRANT), MYF(0), + combo.user.str, combo.host.str); goto abort; } old_row_exists = 0; @@ -2036,8 +2041,10 @@ static int replace_column_table(GRANT_TABLE *g_t, { if (revoke_grant) { - my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), - combo.user.str, combo.host.str, table_name); /* purecov: inspected */ + my_printf_error(ER_NONEXISTING_TABLE_GRANT, + ER(ER_NONEXISTING_TABLE_GRANT), MYF(0), + combo.user.str, combo.host.str, + table_name); /* purecov: inspected */ result= -1; /* purecov: inspected */ continue; /* purecov: inspected */ } @@ -2180,7 +2187,8 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, */ if (!find_acl_user(combo.host.str,combo.user.str)) { - my_error(ER_PASSWORD_NO_MATCH,MYF(0)); /* purecov: deadcode */ + my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), + MYF(0)); /* purecov: deadcode */ DBUG_RETURN(-1); /* purecov: deadcode */ } @@ -2202,9 +2210,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, */ if (revoke_grant) { // no row, no revoke - my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), - combo.user.str, combo.host.str, - table_name); /* purecov: deadcode */ + my_printf_error(ER_NONEXISTING_TABLE_GRANT, + ER(ER_NONEXISTING_TABLE_GRANT), MYF(0), + combo.user.str, combo.host.str, + table_name); /* purecov: deadcode */ DBUG_RETURN(-1); /* purecov: deadcode */ } old_row_exists = 0; @@ -2311,7 +2320,8 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, } if (rights & ~TABLE_ACLS) { - my_error(ER_ILLEGAL_GRANT_FOR_TABLE,MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), + MYF(0)); DBUG_RETURN(TRUE); } @@ -2332,8 +2342,8 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, column->column.length(), 0, 0, 0, 0, &unused_field_idx)) { - my_error(ER_BAD_FIELD_ERROR, MYF(0), - column->column.c_ptr(), table_list->alias); + my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0), + column->column.c_ptr(), table_list->alias); DBUG_RETURN(TRUE); } column_priv|= column->rights; @@ -2348,7 +2358,8 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, fn_format(buf,buf,"","",4+16+32); if (access(buf,F_OK)) { - my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias); + my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0), + table_list->db, table_list->alias); DBUG_RETURN(TRUE); } } @@ -2406,7 +2417,8 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (Str->host.length > HOSTNAME_LENGTH || Str->user.length > USERNAME_LENGTH) { - my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0)); + my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), + MYF(0)); result= TRUE; continue; } @@ -2435,8 +2447,9 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, { if (revoke_grant) { - my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), - Str->user.str, Str->host.str, table_list->real_name); + my_printf_error(ER_NONEXISTING_TABLE_GRANT, + ER(ER_NONEXISTING_TABLE_GRANT), MYF(0), + Str->user.str, Str->host.str, table_list->real_name); result= TRUE; continue; } @@ -2581,7 +2594,8 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, if (Str->host.length > HOSTNAME_LENGTH || Str->user.length > USERNAME_LENGTH) { - my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0)); + my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), + MYF(0)); result= -1; continue; } @@ -2876,11 +2890,12 @@ err: command= "create view"; else if (want_access & SHOW_VIEW_ACL) command= "show create view"; - my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), - command, - thd->priv_user, - thd->host_or_ip, - table ? table->real_name : "unknown"); + my_printf_error(ER_TABLEACCESS_DENIED_ERROR, + ER(ER_TABLEACCESS_DENIED_ERROR), MYF(0), + command, + thd->priv_user, + thd->host_or_ip, + table ? table->real_name : "unknown"); } DBUG_RETURN(1); } @@ -3168,7 +3183,8 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (lex_user->host.length > HOSTNAME_LENGTH || lex_user->user.length > USERNAME_LENGTH) { - my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0)); + my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER), + MYF(0)); DBUG_RETURN(TRUE); } @@ -3186,8 +3202,9 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) } if (counter == acl_users.elements) { - my_error(ER_NONEXISTING_GRANT, MYF(0), - lex_user->user.str, lex_user->host.str); + my_printf_error(ER_NONEXISTING_GRANT, + ER(ER_NONEXISTING_GRANT), MYF(0), + lex_user->user.str, lex_user->host.str); DBUG_RETURN(TRUE); } @@ -3700,7 +3717,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) rw_unlock(&LOCK_grant); close_thread_tables(thd); if (result) - my_error(ER_DROP_USER, MYF(0)); + my_message(ER_DROP_USER, ER(ER_DROP_USER), MYF(0)); DBUG_RETURN(result); } @@ -3804,7 +3821,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) /* when this code is deleted, the error slot (error 1268) can be reused, as this error code was not present in any MySQL release */ if (result) - my_error(ER_REVOKE_GRANTS, MYF(0)); + my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0)); DBUG_RETURN(result); } diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 3f75dadb6f0..c83bd978bfe 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -81,14 +81,18 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, (*param->item)->val() < 0) { delete pc; - my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); + my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, + ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0), + proc_name); DBUG_RETURN(0); } pc->max_tree_elements = (uint) (*param->item)->val_int(); param = param->next; if (param->next) // no third parameter possible { - my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name); + my_printf_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, + ER(ER_WRONG_PARAMCOUNT_TO_PROCEDURE), MYF(0), + proc_name); DBUG_RETURN(0); } // second parameter @@ -96,7 +100,9 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, (*param->item)->val() < 0) { delete pc; - my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); + my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, + ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0), + proc_name); DBUG_RETURN(0); } pc->max_treemem = (uint) (*param->item)->val_int(); @@ -105,7 +111,8 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, (*param->item)->val() < 0) { delete pc; - my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); + my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, + ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0), proc_name); DBUG_RETURN(0); } // if only one parameter was given, it will be the value of max_tree_elements diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1f52c532737..a6a7e99ecec 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1224,7 +1224,8 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) next=table->next; if (!tables || (!db_stat && reopen_table(table,1))) { - my_error(ER_CANT_REOPEN_TABLE,MYF(0),table->table_name); + my_printf_error(ER_CANT_REOPEN_TABLE, ER(ER_CANT_REOPEN_TABLE), + MYF(0),table->table_name); VOID(hash_delete(&open_cache,(byte*) table)); error=1; } @@ -1509,7 +1510,8 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, { /* Give right error message */ thd->clear_error(); - my_error(ER_NOT_KEYFILE, MYF(0), name, my_errno); + my_printf_error(ER_NOT_KEYFILE, ER(ER_NOT_KEYFILE), MYF(0), + name, my_errno); sql_print_error("Error: Couldn't repair table: %s.%s",db,name); if (entry->file) closefrm(entry); @@ -1574,7 +1576,8 @@ err: { TABLE_LIST * view= table_desc->belong_to_view; thd->clear_error(); - my_error(ER_VIEW_INVALID, MYF(0), view->view_db.str, view->view_name.str); + my_printf_error(ER_VIEW_INVALID, ER(ER_VIEW_INVALID), MYF(0), + view->view_db.str, view->view_name.str); } DBUG_RETURN(1); } @@ -2738,8 +2741,9 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table, (pos= find_type(&table->keynames, name->ptr(), name->length(), 1)) <= 0) { - my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr(), - table->real_name); + my_printf_error(ER_KEY_COLUMN_DOES_NOT_EXITS, + ER(ER_KEY_COLUMN_DOES_NOT_EXITS), MYF(0), + name->c_ptr(), table->real_name); map->set_all(); return 1; } @@ -2954,9 +2958,10 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name, DBUG_RETURN(0); if (!table_name) - my_error(ER_NO_TABLES_USED, MYF(0)); + my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0)); else - my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + table_name); err: DBUG_RETURN(1); @@ -3176,8 +3181,25 @@ err_no_arena: ** Returns : 1 if some field has wrong type ******************************************************************************/ -int -fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors) + +/* + Fill fields with given items. + + SYNOPSIS + fill_record() + thd thread handler + fields Item_fields list to be filled + values values to fill with + ignore_errors TRUE if we should ignore errors + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record(THD * thd, List<Item> &fields, List<Item> &values, + bool ignore_errors) { List_iterator_fast<Item> f(fields),v(values); Item *value; @@ -3192,14 +3214,32 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors) if (rfield == table->next_number_field) table->auto_increment_field_not_null= TRUE; if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors) - DBUG_RETURN(1); + { + my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0)); + DBUG_RETURN(TRUE); + } } - DBUG_RETURN(0); + DBUG_RETURN(thd->net.report_error); } -int -fill_record(Field **ptr,List<Item> &values, bool ignore_errors) +/* + Fill field buffer with values from Field list + + SYNOPSIS + fill_record() + thd thread handler + ptr pointer on pointer to record + values list of fields + ignore_errors TRUE if we should ignore errors + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors) { List_iterator_fast<Item> v(values); Item *value; @@ -3213,9 +3253,12 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors) if (field == table->next_number_field) table->auto_increment_field_not_null= TRUE; if ((value->save_in_field(field, 0) < 0) && !ignore_errors) - DBUG_RETURN(1); + { + my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0)); + DBUG_RETURN(TRUE); + } } - DBUG_RETURN(0); + DBUG_RETURN(thd->net.report_error); } @@ -3439,7 +3482,8 @@ open_new_frm(const char *path, const char *alias, { if (table_desc == 0 || table_desc->required_type == FRMTYPE_TABLE) { - my_error(ER_WRONG_OBJECT, MYF(0), db, table_name, "BASE TABLE"); + my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0), + db, table_name, "BASE TABLE"); goto err; } if (mysql_make_view(parser, table_desc)) @@ -3448,7 +3492,8 @@ open_new_frm(const char *path, const char *alias, else { /* only VIEWs are supported now */ - my_error(ER_FRM_UNKNOWN_TYPE, MYF(0), path, parser->type()->str); + my_printf_error(ER_FRM_UNKNOWN_TYPE, ER(ER_FRM_UNKNOWN_TYPE), MYF(0), + path, parser->type()->str); goto err; } DBUG_RETURN(0); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a543222a4a1..966b7de6712 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -695,8 +695,8 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length) key_length + 1); if (!new_table) { - my_error(EE_OUTOFMEMORY, MYF(ME_BELL), - ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1); + my_printf_error(EE_OUTOFMEMORY, ER(EE_OUTOFMEMORY), MYF(ME_BELL), + ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1); killed= KILL_CONNECTION; return 0; } @@ -953,7 +953,8 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange, (void) fn_format(path, exchange->file_name, path, "", option); if (!access(path, F_OK)) { - my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); + my_printf_error(ER_FILE_EXISTS_ERROR, ER(ER_FILE_EXISTS_ERROR), MYF(0), + exchange->file_name); return -1; } /* Create the file world readable */ @@ -1184,7 +1185,7 @@ bool select_dump::send_data(List<Item> &items) } if (row_count++ > 1) { - my_error(ER_TOO_MANY_ROWS, MYF(0)); + my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0)); goto err; } while ((item=li++)) @@ -1197,7 +1198,8 @@ bool select_dump::send_data(List<Item> &items) } else if (my_b_write(&cache,(byte*) res->ptr(),res->length())) { - my_error(ER_ERROR_ON_WRITE,MYF(0), path, my_errno); + my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0), + path, my_errno); goto err; } } @@ -1356,7 +1358,8 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) if (var_list.elements != list.elements) { - my_error(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, MYF(0)); + my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, + ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0)); return 1; } while ((item=li++)) @@ -1626,7 +1629,7 @@ bool select_dumpvar::send_data(List<Item> &items) } if (row_count++) { - my_error(ER_TOO_MANY_ROWS, MYF(0)); + my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0)); DBUG_RETURN(1); } while ((zz=my_li++) && (item=it++)) diff --git a/sql/sql_class.h b/sql/sql_class.h index 46cf8ca4899..8de38782d3e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -41,6 +41,7 @@ enum enum_check_fields { CHECK_FIELD_IGNORE, CHECK_FIELD_WARN, CHECK_FIELD_ERROR_FOR_NULL }; extern char internal_table_name[2]; +extern const char **errmesg; /* log info errors */ #define LOG_INFO_EOF -1 @@ -1133,7 +1134,8 @@ public: } inline void send_kill_message() const { - my_error(killed_errno(), MYF(0)); + int err= killed_errno(); + my_message(err, ER(err), MYF(0)); } /* return TRUE if we will abort query if we make a warning now */ inline bool really_abort_on_warning() diff --git a/sql/sql_db.cc b/sql/sql_db.cc index df3c27b9b72..e3a19ea32a7 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -413,7 +413,8 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, { if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) { - my_error(ER_DB_CREATE_EXISTS,MYF(0),db); + my_printf_error(ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), MYF(0), + db); error= -1; goto exit; } @@ -423,12 +424,13 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, { if (my_errno != ENOENT) { - my_error(EE_STAT, MYF(0),path,my_errno); + my_printf_error(EE_STAT, ER(EE_STAT), MYF(0), path, my_errno); goto exit; } if (my_mkdir(path,0777,MYF(0)) < 0) { - my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno); + my_printf_error(ER_CANT_CREATE_DB, ER(ER_CANT_CREATE_DB), + MYF(0), db, my_errno); error= -1; goto exit; } @@ -582,7 +584,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) if (!if_exists) { error= -1; - my_error(ER_DB_DROP_EXISTS,MYF(0),db); + my_printf_error(ER_DB_DROP_EXISTS, ER(ER_DB_DROP_EXISTS), MYF(0), db); goto exit; } else @@ -806,7 +808,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, */ if (found_other_files) { - my_error(ER_DB_DROP_RMDIR, MYF(0), org_path, EEXIST); + my_printf_error(ER_DB_DROP_RMDIR, ER(ER_DB_DROP_RMDIR), MYF(0), + org_path, EEXIST); DBUG_RETURN(-1); } else @@ -869,7 +872,8 @@ static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error) *--pos=0; if (rmdir(path) < 0 && send_error) { - my_error(ER_DB_DROP_RMDIR, MYF(0), path, errno); + my_printf_error(ER_DB_DROP_RMDIR, ER(ER_DB_DROP_RMDIR), MYF(0), + path, errno); DBUG_RETURN(-1); } DBUG_RETURN(0); @@ -985,12 +989,13 @@ bool mysql_change_db(THD *thd, const char *name) if (!dbname || !(db_length= strlen(dbname))) { x_free(dbname); /* purecov: inspected */ - my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: inspected */ + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), + MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } if (check_db_name(dbname)) { - my_error(ER_WRONG_DB_NAME, MYF(0), dbname); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), dbname); x_free(dbname); DBUG_RETURN(1); } @@ -1003,10 +1008,11 @@ bool mysql_change_db(THD *thd, const char *name) thd->master_access); if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) { - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->priv_user, - thd->priv_host, - dbname); + my_printf_error(ER_DBACCESS_DENIED_ERROR, + ER(ER_DBACCESS_DENIED_ERROR), MYF(0), + thd->priv_user, + thd->priv_host, + dbname); mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR), thd->priv_user, thd->priv_host, @@ -1021,7 +1027,7 @@ bool mysql_change_db(THD *thd, const char *name) path[length-1]=0; // remove ending '\' if (access(path,F_OK)) { - my_error(ER_BAD_DB_ERROR, MYF(0), dbname); + my_printf_error(ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR), MYF(0), dbname); my_free(dbname,MYF(0)); DBUG_RETURN(1); } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 54c6cd1ebc5..26b37efb773 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -55,7 +55,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, safe_update=test(thd->options & OPTION_SAFE_UPDATES); if (safe_update && const_cond) { - my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); + my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, + ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0)); DBUG_RETURN(TRUE); } @@ -103,7 +104,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { delete select; free_underlaid_joins(thd, &thd->lex->select_lex); - my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); + my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, + ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0)); DBUG_RETURN(TRUE); } } @@ -259,7 +261,7 @@ cleanup: send_ok(thd,deleted); DBUG_PRINT("info",("%d records deleted",deleted)); } - DBUG_RETURN(FALSE); + DBUG_RETURN(error >= 0 || thd->net.report_error); } @@ -287,12 +289,14 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) DBUG_RETURN(TRUE); if (!table_list->updatable || check_key_in_view(thd, table_list)) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), MYF(0), + table_list->alias, "DELETE"); DBUG_RETURN(TRUE); } if (unique_table(table_list, table_list->next_independent())) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), MYF(0), + table_list->real_name); DBUG_RETURN(TRUE); } select_lex->fix_prepare_information(thd, conds); @@ -349,8 +353,8 @@ bool mysql_multi_delete_prepare(THD *thd) if (!target_tbl->correspondent_table->updatable || check_key_in_view(thd, target_tbl->correspondent_table)) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), target_tbl->real_name, - "DELETE"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), target_tbl->real_name, "DELETE"); DBUG_RETURN(TRUE); } /* @@ -367,8 +371,8 @@ bool mysql_multi_delete_prepare(THD *thd) un->check_updateable(target_tbl->correspondent_table->db, target_tbl->correspondent_table->real_name)) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), - target_tbl->correspondent_table->real_name); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), + MYF(0), target_tbl->correspondent_table->real_name); DBUG_RETURN(TRUE); } } @@ -729,8 +733,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) db_type table_type; if ((table_type=get_table_type(path)) == DB_TYPE_UNKNOWN) { - my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, - table_list->real_name); + my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0), + table_list->db, table_list->real_name); DBUG_RETURN(TRUE); } if (!ha_supports_generate(table_type)) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 6bab90a786e..37079fbc856 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -341,7 +341,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, break; } default: - my_error(ER_ILLEGAL_HA, MYF(0)); + my_message(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0)); goto err; } @@ -370,7 +370,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, if (item->send(thd->protocol, &buffer)) { protocol->free(); // Free used - my_error(ER_OUT_OF_RESOURCES,MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); goto err; } } diff --git a/sql/sql_help.cc b/sql/sql_help.cc index d108f6f69b4..cfa3325be8a 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -276,7 +276,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, (iindex_relations= find_type((char*) primary_key_name, &relations->keynames, 1+2)-1)<0) { - my_error(ER_CORRUPT_HELP_DB, 0); + my_message(ER_CORRUPT_HELP_DB, ER(ER_CORRUPT_HELP_DB), MYF(0)); DBUG_RETURN(-1); } rtopic_id= find_fields[help_relation_help_topic_id].field; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 81f80378763..4ba09e12811 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -100,7 +100,8 @@ check_insert_fields(THD *thd, TABLE_LIST *table_list, List<Item> &fields, if (check_unique && thd->dupp_field) { - my_error(ER_FIELD_SPECIFIED_TWICE,MYF(0), thd->dupp_field->field_name); + my_printf_error(ER_FIELD_SPECIFIED_TWICE, ER(ER_FIELD_SPECIFIED_TWICE), + MYF(0), thd->dupp_field->field_name); return -1; } if (table->timestamp_field && // Don't set timestamp if used @@ -291,7 +292,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (fields.elements || !value_count) { restore_record(table,default_values); // Get empty record - if (fill_record(fields, *values, 0)|| thd->net.report_error) + if (fill_record(thd, fields, *values, 0)) { if (values_list.elements != 1 && !thd->net.report_error) { @@ -299,14 +300,10 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, continue; } /* - Field::store methods can't send errors - TODO: set thd->abort_on_warning if values_list.elements == 1 and check that all items return warning in case of problem with storing field. */ - if (!thd->net.report_error) - my_error(ER_UNKNOWN_ERROR, MYF(0)); error=1; break; } @@ -317,16 +314,13 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, restore_record(table,default_values); // Get empty record else table->record[0][0]=table->default_values[0]; // Fix delete marker - if (fill_record(table->field,*values, 0) || thd->net.report_error) + if (fill_record(thd, table->field, *values, 0)) { if (values_list.elements != 1 && ! thd->net.report_error) { info.records++; continue; } - /* Field::store methods can't send errors */ - if (!thd->net.report_error) - my_error(ER_UNKNOWN_ERROR, MYF(0)); error=1; break; } @@ -608,7 +602,8 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, (insert_into_view && check_view_insertability(table_list, thd->query_id))) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "INSERT"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), table_list->alias, "INSERT"); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -655,7 +650,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, if (unique_table(table_list, table_list->next_independent())) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), + MYF(0), table_list->real_name); DBUG_RETURN(TRUE); } thd->lex->select_lex.first_execution= 0; @@ -751,13 +747,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) */ store_record(table,insert_values); restore_record(table,record[1]); - if (fill_record(*info->update_fields, *info->update_values, 0)) - { - /* Field::store methods can't send errors */ - if (!thd->net.report_error) - my_error(ER_UNKNOWN_ERROR, MYF(0)); + if (fill_record(thd, *info->update_fields, *info->update_values, 0)) goto err; - } /* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */ if (info->view && @@ -1018,7 +1009,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) { delete tmp; thd->fatal_error(); - my_error(ER_OUT_OF_RESOURCES,MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); pthread_mutex_unlock(&LOCK_delayed_create); DBUG_RETURN(0); } @@ -1335,7 +1326,8 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg) if (!(di->table->file->table_flags() & HA_CAN_INSERT_DELAYED)) { thd->fatal_error(); - my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name); + my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0), + di->table_list.real_name); goto end; } di->table->copy_blobs=1; @@ -1761,9 +1753,9 @@ bool select_insert::send_data(List<Item> &values) DBUG_RETURN(0); } if (fields->elements) - fill_record(*fields, values, 1); + fill_record(thd, *fields, values, 1); else - fill_record(table->field, values, 1); + fill_record(thd, table->field, values, 1); switch (table_list->view_check_option(thd, thd->lex->duplicates == DUP_IGNORE)) { @@ -1934,7 +1926,7 @@ bool select_create::send_data(List<Item> &values) unit->offset_limit_cnt--; return 0; } - fill_record(field, values, 1); + fill_record(thd, field, values, 1); if (thd->net.report_error || write_record(thd, table, &info)) return 1; if (table->next_number_field) // Clear for next record diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 73f99d0dd68..145ef84d57a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1273,7 +1273,7 @@ bool st_select_lex::test_limit() if (select_limit != HA_POS_ERROR) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), - "LIMIT & IN/ALL/ANY/SOME subquery"); + "LIMIT & IN/ALL/ANY/SOME subquery"); return(1); } // We need only 1 row to determinate existence diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0be4d9ecdc1..70fa097c8f8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -125,7 +125,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_RETURN(-1); if (!table_list->updatable || check_key_in_view(thd, table_list)) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), table_list->alias, "LOAD"); DBUG_RETURN(TRUE); } table= table_list->table; @@ -148,7 +149,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_RETURN(TRUE); if (thd->dupp_field) { - my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dupp_field->field_name); + my_printf_error(ER_FIELD_SPECIFIED_TWICE, ER(ER_FIELD_SPECIFIED_TWICE), + MYF(0), thd->dupp_field->field_name); DBUG_RETURN(TRUE); } if (check_that_all_fields_are_given_values(thd, table)) @@ -222,7 +224,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ((stat_info.st_mode & S_IFREG) == S_IFREG || (stat_info.st_mode & S_IFIFO) == S_IFIFO))) { - my_error(ER_TEXTFILE_NOT_READABLE,MYF(0),name); + my_printf_error(ER_TEXTFILE_NOT_READABLE, + ER(ER_TEXTFILE_NOT_READABLE), MYF(0), name); DBUG_RETURN(TRUE); } if ((stat_info.st_mode & S_IFIFO) == S_IFIFO) diff --git a/sql/sql_map.cc b/sql/sql_map.cc index c6637474908..917a8f2c30f 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -47,12 +47,13 @@ mapped_files::mapped_files(const my_string filename,byte *magic,uint magic_lengt 0L))) { error=errno; - my_error(ER_NO_FILE_MAPPING,MYF(0), (my_string) name, error); + my_printf_error(ER_NO_FILE_MAPPING, ER(ER_NO_FILE_MAPPING), MYF(0), + (my_string) name, error); } } if (map && memcmp(map,magic,magic_length)) { - my_error(ER_WRONG_MAGIC, MYF(0), name); + my_printf_error(ER_WRONG_MAGIC, ER(ER_WRONG_MAGIC), MYF(0), name); VOID(munmap(map,size)); map=0; } @@ -111,7 +112,8 @@ mapped_files *map_file(const my_string name,byte *magic,uint magic_length) { map->use_count++; if (!map->map) - my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error); + my_printf_error(ER_NO_FILE_MAPPING, ER(ER_NO_FILE_MAPPING), MYF(0), + path, map->error); } VOID(pthread_mutex_unlock(&LOCK_mapped_file)); return map; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 316f5ebdf60..5156d1e0d33 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1115,7 +1115,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) if (buff[length-1]!='\n' && !feof(file)) { net_send_error(thd, ER_NET_PACKET_TOO_LARGE, NullS); - thd->is_fatal_error= 1; + thd->fatal_error(); break; } while (length && (my_isspace(thd->charset(), buff[length-1]) || @@ -1192,7 +1192,8 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) if (!db || check_db_name(db)) { - my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + db ? db : "NULL"); goto err; } if (lower_case_table_names) @@ -1396,7 +1397,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Small check for incoming packet */ if ((uint) ((uchar*) db - net->read_pos) > packet_length) { - my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } #endif @@ -1418,7 +1419,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (!(thd->user= my_strdup(user, MYF(0)))) { thd->user= save_user; - my_error(ER_OUT_OF_RESOURCES, MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); break; } @@ -1430,7 +1431,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { /* authentication failure, we shall restore old user */ if (res > 0) - my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); x_free(thd->user); thd->user= save_user; thd->priv_user= save_priv_user; @@ -1538,7 +1539,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } case COM_FIELD_LIST: // This isn't actually needed #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ break; #else { @@ -1551,7 +1553,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, bzero((char*) &table_list,sizeof(table_list)); if (!(table_list.db=thd->db)) { - my_error(ER_NO_DB_ERROR, MYF(0)); + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); break; } pend= strend(packet); @@ -1604,7 +1606,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, // null test to handle EOM if (!db || !(alias= thd->strdup(db)) || check_db_name(db)) { - my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + db ? db : "NULL"); break; } if (check_access(thd,CREATE_ACL,db,0,1,0)) @@ -1621,14 +1624,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* null test to handle EOM */ if (!db || !(alias= thd->strdup(db)) || check_db_name(db)) { - my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), + MYF(0), db ? db : "NULL"); break; } if (check_access(thd,DROP_ACL,db,0,1,0)) break; if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); break; } mysql_log.write(thd,command,db); @@ -1777,7 +1782,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, send_eof(thd); break; default: - my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } break; @@ -1796,7 +1801,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_DELAYED_INSERT: case COM_END: default: - my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); break; } if (thd->lock || thd->open_tables || thd->derived_tables) @@ -1808,7 +1813,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* report error issued during command execution */ if (thd->killed_errno() && !thd->net.report_error) thd->send_kill_message(); - if (thd->is_fatal_error || thd->net.report_error) + if (thd->net.report_error) net_send_error(thd); time_t start_of_query=thd->start_time; @@ -1958,7 +1963,7 @@ mysql_execute_command(THD *thd) if (all_tables_not_ok(thd, all_tables)) { /* we warn the slave SQL thread */ - my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); DBUG_RETURN(0); } #ifndef TO_BE_DELETED @@ -2159,9 +2164,11 @@ mysql_execute_command(THD *thd) } else { - my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), - lex->prepared_stmt_name.length, lex->prepared_stmt_name.str, - "DEALLOCATE PREPARE"); + my_printf_error(ER_UNKNOWN_STMT_HANDLER, ER(ER_UNKNOWN_STMT_HANDLER), + MYF(0), + lex->prepared_stmt_name.length, + lex->prepared_stmt_name.str, + "DEALLOCATE PREPARE"); goto error; } break; @@ -2354,7 +2361,8 @@ mysql_execute_command(THD *thd) } if (strlen(first_table->real_name) > NAME_LEN) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), first_table->real_name); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0), + first_table->real_name); break; } pthread_mutex_lock(&LOCK_active_mi); @@ -2425,7 +2433,8 @@ mysql_execute_command(THD *thd) if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && unique_table(create_table, select_tables)) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->real_name); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), + MYF(0), create_table->real_name); goto create_error; } /* If we create merge table, we have to test tables in merge, too */ @@ -2438,7 +2447,8 @@ mysql_execute_command(THD *thd) { if (unique_table(tab, select_tables)) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->real_name); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), + MYF(0), tab->real_name); goto create_error; } } @@ -2524,7 +2534,8 @@ create_error: */ if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), + MYF(0)); goto error; } { @@ -2538,14 +2549,16 @@ create_error: case SQLCOM_ALTER_TABLE: DBUG_ASSERT(first_table == all_tables && first_table != 0); #if defined(DONT_ALLOW_SHOW_COMMANDS) - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { ulong priv=0; if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN)) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), lex->name); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0), + lex->name); goto error; } if (!select_lex->db) @@ -2629,7 +2642,8 @@ create_error: #ifndef EMBEDDED_LIBRARY case SQLCOM_SHOW_BINLOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { @@ -2643,7 +2657,8 @@ create_error: case SQLCOM_SHOW_CREATE: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { @@ -2841,7 +2856,8 @@ create_error: */ if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } @@ -2939,7 +2955,8 @@ create_error: break; case SQLCOM_SHOW_DATABASES: #if defined(DONT_ALLOW_SHOW_COMMANDS) - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else if ((specialflag & SPECIAL_SKIP_SHOW_DB) && @@ -2985,7 +3002,8 @@ create_error: break; case SQLCOM_SHOW_LOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { @@ -2998,30 +3016,33 @@ create_error: case SQLCOM_SHOW_TABLES: /* FALL THROUGH */ #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { char *db=select_lex->db ? select_lex->db : thd->db; if (!db) { - my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: inspected */ + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), + MYF(0)); /* purecov: inspected */ goto error; /* purecov: inspected */ } remove_escape(db); // Fix escaped '_' if (check_db_name(db)) { - my_error(ER_WRONG_DB_NAME, MYF(0), db); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), db); goto error; } if (check_access(thd,SELECT_ACL,db,&thd->col_access,0,0)) goto error; /* purecov: inspected */ if (!thd->col_access && check_grant_db(thd,db)) { - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->priv_user, - thd->priv_host, - db); + my_printf_error(ER_DBACCESS_DENIED_ERROR, + ER(ER_DBACCESS_DENIED_ERROR), MYF(0), + thd->priv_user, + thd->priv_host, + db); goto error; } /* grant is checked in mysqld_show_tables */ @@ -3047,7 +3068,8 @@ create_error: case SQLCOM_SHOW_FIELDS: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { @@ -3068,7 +3090,8 @@ create_error: case SQLCOM_SHOW_KEYS: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), + MYF(0)); /* purecov: inspected */ goto error; #else { @@ -3104,7 +3127,7 @@ create_error: if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) || ! opt_local_infile) { - my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); + my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); goto error; } if (check_one_table_access(thd, privilege, all_tables)) @@ -3179,7 +3202,8 @@ create_error: char *alias; if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name)) { - my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + lex->name); break; } /* @@ -3194,7 +3218,7 @@ create_error: (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) { - my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } #endif @@ -3209,7 +3233,8 @@ create_error: char *alias; if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name)) { - my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + lex->name); break; } /* @@ -3224,7 +3249,7 @@ create_error: (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) { - my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } #endif @@ -3232,7 +3257,8 @@ create_error: break; if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } res=mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : lex->name), @@ -3243,7 +3269,8 @@ create_error: { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + lex->name); break; } /* @@ -3258,7 +3285,7 @@ create_error: (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) { - my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } #endif @@ -3266,7 +3293,8 @@ create_error: break; if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } res=mysql_alter_db(thd,lex->name,&lex->create_info); @@ -3276,14 +3304,16 @@ create_error: { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), + lex->name); break; } if (check_access(thd,SELECT_ACL,lex->name,0,1,0)) break; if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); goto error; } res=mysqld_show_create_db(thd,lex->name,&lex->create_info); @@ -3297,7 +3327,8 @@ create_error: #ifdef HAVE_DLOPEN if ((sph= sp_find_function(thd, lex->spname))) { - my_error(ER_UDF_EXISTS, MYF(0), lex->spname->m_name.str); + my_printf_error(ER_UDF_EXISTS, ER(ER_UDF_EXISTS), MYF(0), + lex->spname->m_name.str); goto error; } if (!(res = mysql_create_function(thd,&lex->udf))) @@ -3405,7 +3436,8 @@ create_error: { if (lex->columns.elements) { - my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), + MYF(0)); goto error; } else @@ -3588,7 +3620,7 @@ create_error: if (! lex->sphead->m_db.str) { - my_error(ER_NO_DB_ERROR, MYF(0)); + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); delete lex->sphead; lex->sphead= 0; goto error; @@ -3602,7 +3634,7 @@ create_error: if (udf) { - my_error(ER_UDF_EXISTS, MYF(0), name); + my_printf_error(ER_UDF_EXISTS, ER(ER_UDF_EXISTS), MYF(0), name); delete lex->sphead; lex->sphead= 0; goto error; @@ -3612,7 +3644,7 @@ create_error: if (lex->sphead->m_type == TYPE_ENUM_FUNCTION && !lex->sphead->m_has_return) { - my_error(ER_SP_NORETURN, MYF(0), name); + my_printf_error(ER_SP_NORETURN, ER(ER_SP_NORETURN), MYF(0), name); delete lex->sphead; lex->sphead= 0; goto error; @@ -3627,19 +3659,22 @@ create_error: lex->sphead= 0; break; case SP_WRITE_ROW_FAILED: - my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); + my_printf_error(ER_SP_ALREADY_EXISTS, ER(ER_SP_ALREADY_EXISTS), MYF(0), + SP_TYPE_STRING(lex), name); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; goto error; case SP_NO_DB_ERROR: - my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); + my_printf_error(ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR), MYF(0), + lex->sphead->m_db.str); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; goto error; default: - my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); + my_printf_error(ER_SP_STORE_FAILED, ER(ER_SP_STORE_FAILED), MYF(0), + SP_TYPE_STRING(lex), name); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; @@ -3653,7 +3688,8 @@ create_error: if (!(sp= sp_find_procedure(thd, lex->spname))) { - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PROCEDURE", + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), + MYF(0), "PROCEDURE", lex->spname->m_qname.str); goto error; } @@ -3680,7 +3716,7 @@ create_error: { if (! (thd->client_capabilities & CLIENT_MULTI_RESULTS)) { - my_error(ER_SP_BADSELECT, MYF(0)); + my_message(ER_SP_BADSELECT, ER(ER_SP_BADSELECT), MYF(0)); #ifndef EMBEDDED_LIBRARY thd->net.no_send_ok= nsok; #endif @@ -3751,12 +3787,12 @@ create_error: send_ok(thd); break; case SP_KEY_NOT_FOUND: - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0), + SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; default: - my_error(ER_SP_CANT_ALTER, MYF(0), SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_printf_error(ER_SP_CANT_ALTER, ER(ER_SP_CANT_ALTER), MYF(0), + SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; } break; @@ -3818,12 +3854,12 @@ create_error: send_ok(thd); break; } - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0), + SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; default: - my_error(ER_SP_DROP_FAILED, MYF(0), SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_printf_error(ER_SP_DROP_FAILED, ER(ER_SP_DROP_FAILED), MYF(0), + SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; } break; @@ -3832,13 +3868,14 @@ create_error: { if (lex->spname->m_name.length > NAME_LEN) { - my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str); + my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0), + lex->spname->m_name.str); goto error; } if (sp_show_create_procedure(thd, lex->spname) != SP_OK) { /* We don't distinguish between errors for now */ - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), - SP_COM_STRING(lex), lex->spname->m_name.str); + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0), + SP_COM_STRING(lex), lex->spname->m_name.str); goto error; } break; @@ -3847,13 +3884,14 @@ create_error: { if (lex->spname->m_name.length > NAME_LEN) { - my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str); + my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0), + lex->spname->m_name.str); goto error; } if (sp_show_create_function(thd, lex->spname) != SP_OK) { /* We don't distinguish between errors for now */ - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), - SP_COM_STRING(lex), lex->spname->m_name.str); + my_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0), + SP_COM_STRING(lex), lex->spname->m_name.str); goto error; } break; @@ -4029,7 +4067,8 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, { DBUG_PRINT("error",("No database")); if (!no_errors) - my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: tested */ + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), + MYF(0)); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } @@ -4056,10 +4095,13 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, { // We can never grant this DBUG_PRINT("error",("No possible access")); if (!no_errors) - my_error(ER_ACCESS_DENIED_ERROR, MYF(0), - thd->priv_user, - thd->priv_host, - thd->password ? ER(ER_YES) : ER(ER_NO));/* purecov: tested */ + my_printf_error(ER_ACCESS_DENIED_ERROR, + ER(ER_ACCESS_DENIED_ERROR), MYF(0), + thd->priv_user, + thd->priv_host, + (thd->password ? + ER(ER_YES) : + ER(ER_NO)));/* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } @@ -4085,10 +4127,13 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, DBUG_PRINT("error",("Access denied")); if (!no_errors) - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->priv_user, - thd->priv_host, - db ? db : thd->db ? thd->db : "unknown"); /* purecov: tested */ + my_printf_error(ER_DBACCESS_DENIED_ERROR, + ER(ER_DBACCESS_DENIED_ERROR), MYF(0), + thd->priv_user, + thd->priv_host, + (db ? db : (thd->db ? + thd->db : + "unknown"))); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ #endif /* NO_EMBEDDED_ACCESS_CHECKS */ } @@ -4122,7 +4167,8 @@ bool check_global_access(THD *thd, ulong want_access) if ((thd->master_access & want_access)) return 0; get_privilege_desc(command, sizeof(command), want_access); - my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command); + my_printf_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, + ER(ER_SPECIFIC_ACCESS_DENIED_ERROR), MYF(0), command); return 1; #endif /* NO_EMBEDDED_ACCESS_CHECKS */ } @@ -4234,7 +4280,8 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables) { if (!(tables->db=thd->db)) { - my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: tested */ + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), + MYF(0)); /* purecov: tested */ return TRUE; /* purecov: tested */ } } @@ -4272,7 +4319,8 @@ check_sp_definer_access(THD *thd, sp_head *sp) strncmp(thd->priv_host, hst->str, hst->length) == 0) return FALSE; /* Both user and host must match */ - my_error(ER_SP_ACCESS_DENIED_ERROR, MYF(0), sp->m_qname.str); + my_printf_error(ER_SP_ACCESS_DENIED_ERROR, ER(ER_SP_ACCESS_DENIED_ERROR), + MYF(0), sp->m_qname.str); return TRUE; /* Not definer or root */ } @@ -4636,7 +4684,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if (strlen(field_name) > NAME_LEN) { - my_error(ER_TOO_LONG_IDENT, MYF(0), field_name); /* purecov: inspected */ + my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0), + field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } if (type_modifier & PRI_KEY_FLAG) @@ -4667,7 +4716,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, !(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC && type == FIELD_TYPE_TIMESTAMP)) { - my_error(ER_INVALID_DEFAULT, MYF(0), field_name); + my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0), + field_name); DBUG_RETURN(1); } else if (default_value->type() == Item::NULL_ITEM) @@ -4676,20 +4726,23 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) { - my_error(ER_INVALID_DEFAULT, MYF(0), field_name); + my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0), + field_name); DBUG_RETURN(1); } } else if (type_modifier & AUTO_INCREMENT_FLAG) { - my_error(ER_INVALID_DEFAULT, MYF(0), field_name); + my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0), + field_name); DBUG_RETURN(1); } } if (on_update_value && type != FIELD_TYPE_TIMESTAMP) { - my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name); + my_printf_error(ER_INVALID_ON_UPDATE, ER(ER_INVALID_ON_UPDATE), MYF(0), + field_name); DBUG_RETURN(1); } @@ -4815,8 +4868,9 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, res=default_value->val_str(&str); if (res->length()) { - my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), - field_name); /* purecov: inspected */ + my_printf_error(ER_BLOB_CANT_HAVE_DEFAULT, + ER(ER_BLOB_CANT_HAVE_DEFAULT), MYF(0), + field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } new_field->def=0; @@ -4836,7 +4890,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, uint tmp_length=new_field->length; if (tmp_length > PRECISION_FOR_DOUBLE) { - my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name); + my_printf_error(ER_WRONG_FIELD_SPEC, ER(ER_WRONG_FIELD_SPEC), MYF(0), + field_name); DBUG_RETURN(1); } else if (tmp_length > PRECISION_FOR_FLOAT) @@ -4922,7 +4977,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, { if (interval->count > sizeof(longlong)*8) { - my_error(ER_TOO_BIG_SET, MYF(0), field_name); /* purecov: inspected */ + my_printf_error(ER_TOO_BIG_SET, ER(ER_TOO_BIG_SET), MYF(0), + field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } new_field->pack_length=(interval->count+7)/8; @@ -4952,7 +5008,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, ¬_used2, ¬_used3); if (thd->cuted_fields) { - my_error(ER_INVALID_DEFAULT, MYF(0), field_name); + my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0), + field_name); DBUG_RETURN(1); } } @@ -4978,7 +5035,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, res->strip_sp(); if (!find_type(interval, res->ptr(), res->length(), 0)) { - my_error(ER_INVALID_DEFAULT, MYF(0), field_name); + my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0), + field_name); DBUG_RETURN(1); } } @@ -4992,14 +5050,15 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING && type != FIELD_TYPE_GEOMETRY)) { - my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name, - MAX_FIELD_CHARLENGTH); /* purecov: inspected */ + my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH), MYF(0), + field_name, MAX_FIELD_CHARLENGTH);/* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } type_modifier&= AUTO_INCREMENT_FLAG; if ((~allowed_type_modifier) & type_modifier) { - my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name); + my_printf_error(ER_WRONG_FIELD_SPEC, ER(ER_WRONG_FIELD_SPEC), MYF(0), + field_name); DBUG_RETURN(1); } if (!new_field->pack_length) @@ -5129,7 +5188,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (check_table_name(table->table.str,table->table.length) || table->db.str && check_db_name(table->db.str)) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0), + table->table.str); DBUG_RETURN(0); } @@ -5137,7 +5197,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, { if (table->sel) { - my_error(ER_DERIVED_MUST_HAVE_ALIAS, MYF(0)); + my_message(ER_DERIVED_MUST_HAVE_ALIAS, + ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0)); DBUG_RETURN(0); } if (!(alias_str=thd->memdup(alias_str,table->table.length+1))) @@ -5191,7 +5252,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) && !strcmp(ptr->db, tables->db)) { - my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */ + my_printf_error(ER_NONUNIQ_TABLE, ER(ER_NONUNIQ_TABLE), MYF(0), + alias_str); /* purecov: tested */ DBUG_RETURN(0); /* purecov: tested */ } } @@ -5735,7 +5797,8 @@ static bool append_file_to_dir(THD *thd, const char **filename_ptr, if (strlen(*filename_ptr)+strlen(table_name) >= FN_REFLEN-1 || !test_if_hard_path(*filename_ptr)) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), *filename_ptr); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0), + *filename_ptr); return 1; } /* Fix is using unix filename format on dos */ @@ -5768,7 +5831,8 @@ bool check_simple_select() char command[80]; strmake(command, thd->lex->yylval->symbol.str, min(thd->lex->yylval->symbol.length, sizeof(command)-1)); - my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command); + my_printf_error(ER_CANT_USE_OPTION_HERE, ER(ER_CANT_USE_OPTION_HERE), + MYF(0), command); return 1; } return 0; @@ -5916,7 +5980,7 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables) if (select_lex->item_list.elements != lex->value_list.elements) { - my_error(ER_WRONG_VALUE_COUNT, MYF(0)); + my_printf_error(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0)); DBUG_RETURN(TRUE); } /* @@ -5997,7 +6061,8 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) DBUG_RETURN(TRUE); if ((thd->options & OPTION_SAFE_UPDATES) && !select_lex->where) { - my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); + my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, + ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0)); DBUG_RETURN(TRUE); } for (target_tbl= aux_tables; target_tbl; target_tbl= target_tbl->next_local) @@ -6014,8 +6079,8 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } if (!walk) { - my_error(ER_UNKNOWN_TABLE, MYF(0), target_tbl->real_name, - "MULTI DELETE"); + my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0), + target_tbl->real_name, "MULTI DELETE"); DBUG_RETURN(TRUE); } walk->lock_type= target_tbl->lock_type; @@ -6069,7 +6134,7 @@ bool update_precheck(THD *thd, TABLE_LIST *tables) DBUG_ENTER("update_precheck"); if (thd->lex->select_lex.item_list.elements != thd->lex->value_list.elements) { - my_error(ER_WRONG_VALUE_COUNT, MYF(0)); + my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0)); DBUG_RETURN(TRUE); } DBUG_RETURN(check_db_used(thd, tables) || @@ -6127,7 +6192,7 @@ bool insert_precheck(THD *thd, TABLE_LIST *tables, bool update) if (lex->select_lex.item_list.elements != lex->value_list.elements) { - my_error(ER_WRONG_VALUE_COUNT, MYF(0)); + my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0)); DBUG_RETURN(TRUE); } DBUG_RETURN(FALSE); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index aa5da98f56f..17f1b0eacfd 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1451,7 +1451,7 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) All other is not supported yet */ res= -1; - my_error(ER_UNSUPPORTED_PS, MYF(0)); + my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0)); goto error; } if (res == 0) diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 3298eb68a91..25874e1335a 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -44,7 +44,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) if (thd->locked_tables || thd->active_transaction()) { - my_error(ER_LOCK_OR_ACTIVE_TRANSACTION,MYF(0)); + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); DBUG_RETURN(1); } @@ -156,7 +157,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) unpack_filename(name, name); if (!access(name,F_OK)) { - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_alias); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), new_alias); DBUG_RETURN(ren_table); // This can't be skipped } sprintf(name,"%s/%s/%s%s",mysql_data_home, @@ -165,7 +167,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) unpack_filename(name, name); if ((table_type=get_table_type(name)) == DB_TYPE_UNKNOWN) { - my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); + my_printf_error(ER_FILE_NOT_FOUND, ER(ER_FILE_NOT_FOUND), MYF(0), + name, my_errno); if (!skip_error) DBUG_RETURN(ren_table); } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 16daba09954..aea65d13386 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -296,7 +296,7 @@ bool purge_error_message(THD* thd, int res) if (errmsg) { - my_error(errmsg, MYF(0)); + my_message(errmsg, ER(errmsg), MYF(0)); return TRUE; } send_ok(thd); @@ -867,7 +867,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) if (slave_errno) { if (net_report) - my_error(slave_errno, MYF(0)); + my_message(slave_errno, ER(slave_errno), MYF(0)); DBUG_RETURN(1); } else if (net_report) @@ -917,7 +917,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report ) if (slave_errno) { if (net_report) - my_error(slave_errno, MYF(0)); + my_message(slave_errno, ER(slave_errno), MYF(0)); return 1; } else if (net_report) @@ -998,8 +998,8 @@ int reset_slave(THD *thd, MASTER_INFO* mi) err: unlock_slave_threads(mi); - if (error) - my_error(sql_errno, MYF(0), errmsg); + if (error) + my_printf_error(sql_errno, ER(sql_errno), MYF(0), errmsg); DBUG_RETURN(error); } @@ -1063,7 +1063,7 @@ bool change_master(THD* thd, MASTER_INFO* mi) init_thread_mask(&thread_mask,mi,0 /*not inverse*/); if (thread_mask) // We refuse if any slave thread is running { - my_error(ER_SLAVE_MUST_STOP, MYF(0)); + my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0)); unlock_slave_threads(mi); DBUG_RETURN(TRUE); } @@ -1073,7 +1073,7 @@ bool change_master(THD* thd, MASTER_INFO* mi) // TODO: see if needs re-write if (init_master_info(mi, master_info_file, relay_log_info_file, 0)) { - my_error(ER_MASTER_INFO, MYF(0)); + my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0)); unlock_slave_threads(mi); DBUG_RETURN(TRUE); } @@ -1192,7 +1192,8 @@ bool change_master(THD* thd, MASTER_INFO* mi) 0 /* not only reset, but also reinit */, &errmsg)) { - my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg); + my_printf_error(ER_RELAY_LOG_FAIL, ER(ER_RELAY_LOG_FAIL), MYF(0), + errmsg); unlock_slave_threads(mi); DBUG_RETURN(TRUE); } @@ -1208,7 +1209,7 @@ bool change_master(THD* thd, MASTER_INFO* mi) 0 /*no data lock*/, &msg, 0)) { - my_error(ER_RELAY_LOG_INIT, MYF(0), msg); + my_printf_error(ER_RELAY_LOG_INIT, ER(ER_RELAY_LOG_INIT), MYF(0), msg); unlock_slave_threads(mi); DBUG_RETURN(TRUE); } @@ -1259,7 +1260,8 @@ int reset_master(THD* thd) { if (!mysql_bin_log.is_open()) { - my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG)); + my_message(ER_FLUSH_MASTER_BINLOG_CLOSED, + ER(ER_FLUSH_MASTER_BINLOG_CLOSED), MYF(ME_BELL+ME_WAITTANG)); return 1; } return mysql_bin_log.reset_logs(thd); @@ -1401,8 +1403,9 @@ err: if (errmsg) { - my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), - "SHOW BINLOG EVENTS", errmsg); + my_printf_error(ER_ERROR_WHEN_EXECUTING_COMMAND, + ER(ER_ERROR_WHEN_EXECUTING_COMMAND), MYF(0), + "SHOW BINLOG EVENTS", errmsg); DBUG_RETURN(TRUE); } @@ -1470,7 +1473,7 @@ bool show_binlogs(THD* thd) if (!mysql_bin_log.is_open()) { - my_error(ER_NO_BINARY_LOGGING, MYF(0)); + my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0)); return 1; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index df7e943d1f6..eed16be059a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -377,7 +377,8 @@ JOIN::prepare(Item ***rref_pointer_array, } if (flag == 3) { - my_error(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,MYF(0)); + my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, + ER(ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0)); DBUG_RETURN(-1); } } @@ -404,7 +405,8 @@ JOIN::prepare(Item ***rref_pointer_array, { if (!test_if_subpart(procedure->group,group_list)) { /* purecov: inspected */ - my_error(ER_DIFF_GROUPS_PROC, MYF(0)); /* purecov: inspected */ + my_message(ER_DIFF_GROUPS_PROC, ER(ER_DIFF_GROUPS_PROC), + MYF(0)); /* purecov: inspected */ goto err; /* purecov: inspected */ } } @@ -417,7 +419,8 @@ JOIN::prepare(Item ***rref_pointer_array, #endif if (order && (procedure->flags & PROC_NO_SORT)) { /* purecov: inspected */ - my_error(ER_ORDER_WITH_PROC, MYF(0)); /* purecov: inspected */ + my_message(ER_ORDER_WITH_PROC, ER(ER_ORDER_WITH_PROC), + MYF(0)); /* purecov: inspected */ goto err; /* purecov: inspected */ } } @@ -1805,7 +1808,7 @@ Cursor::fetch(ulong num_rows) if (thd->killed) /* Aborted by user */ { - my_error(ER_SERVER_SHUTDOWN,MYF(0)); + my_message(ER_SERVER_SHUTDOWN, ER(ER_SERVER_SHUTDOWN), MYF(0)); return -1; } @@ -2209,7 +2212,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, if (s->dependent & s->table->map) { join->tables=0; // Don't use join->table - my_error(ER_WRONG_OUTER_JOIN,MYF(0)); + my_message(ER_WRONG_OUTER_JOIN, ER(ER_WRONG_OUTER_JOIN), MYF(0)); DBUG_RETURN(1); } s->key_dependent= s->dependent; @@ -5622,7 +5625,8 @@ bool error_if_full_join(JOIN *join) { if (tab->type == JT_ALL && (!tab->select || !tab->select->quick)) { - my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,MYF(0)); + my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, + ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0)); return(1); } } @@ -10664,7 +10668,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, } if (copy_blobs(first_field)) { - my_error(ER_OUTOFMEMORY,MYF(0)); + my_message(ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0)); error=0; goto err; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 17e1a77645a..f8243e8568e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -866,8 +866,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) /* TODO: add environment variables show when it become possible */ if (thd->lex->only_view && !table_list->view) { - my_error(ER_WRONG_OBJECT, MYF(0), table_list->db, - table_list->real_name, "VIEW"); + my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0), + table_list->db, table_list->real_name, "VIEW"); DBUG_RETURN(TRUE); } @@ -936,7 +936,7 @@ bool mysqld_show_create_db(THD *thd, char *dbname, if (check_db_name(dbname)) { - my_error(ER_WRONG_DB_NAME, MYF(0), dbname); + my_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), dbname); DBUG_RETURN(TRUE); } @@ -948,8 +948,9 @@ bool mysqld_show_create_db(THD *thd, char *dbname, thd->master_access); if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) { - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->priv_user, thd->host_or_ip, dbname); + my_printf_error(ER_DBACCESS_DENIED_ERROR, + ER(ER_DBACCESS_DENIED_ERROR), MYF(0), + thd->priv_user, thd->host_or_ip, dbname); mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR), thd->priv_user, thd->host_or_ip, dbname); DBUG_RETURN(TRUE); @@ -966,7 +967,7 @@ bool mysqld_show_create_db(THD *thd, char *dbname, } if (access(path,F_OK)) { - my_error(ER_BAD_DB_ERROR, MYF(0), dbname); + my_printf_error(ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR), MYF(0), dbname); DBUG_RETURN(TRUE); } if (found_libchar) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d84611ae496..77a5ab340b3 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -78,8 +78,9 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, { if (thd->global_read_lock) { - my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), - tables->real_name); + my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, + ER(ER_TABLE_NOT_LOCKED_FOR_WRITE), MYF(0), + tables->real_name); error= TRUE; goto err; } @@ -261,9 +262,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (wrong_tables.length()) { if (!foreign_key_error) - my_error(ER_BAD_TABLE_ERROR,MYF(0), wrong_tables.c_ptr()); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + wrong_tables.c_ptr()); else - my_error(ER_ROW_IS_REFERENCED, MYF(0)); + my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0)); error= 1; } @@ -463,7 +465,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if (check_column_name(sql_field->field_name)) { - my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name); + my_printf_error(ER_WRONG_COLUMN_NAME, ER(ER_WRONG_COLUMN_NAME), MYF(0), + sql_field->field_name); DBUG_RETURN(-1); } @@ -480,7 +483,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, */ if (field_no < select_field_pos || dup_no >= select_field_pos) { - my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name); + my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME), MYF(0), + sql_field->field_name); DBUG_RETURN(-1); } else @@ -619,24 +623,27 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (timestamps_with_niladic > 1) { - my_error(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,MYF(0)); + my_message(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS, + ER(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS), MYF(0)); DBUG_RETURN(-1); } if (auto_increment > 1) { - my_error(ER_WRONG_AUTO_KEY,MYF(0)); + my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0)); DBUG_RETURN(-1); } if (auto_increment && (file->table_flags() & HA_NO_AUTO_INCREMENT)) { - my_error(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,MYF(0)); + my_message(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT, + ER(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT), MYF(0)); DBUG_RETURN(-1); } if (blob_columns && (file->table_flags() & HA_NO_BLOBS)) { - my_error(ER_TABLE_CANT_HANDLE_BLOB,MYF(0)); + my_message(ER_TABLE_CANT_HANDLE_BLOB, ER(ER_TABLE_CANT_HANDLE_BLOB), + MYF(0)); DBUG_RETURN(-1); } @@ -662,9 +669,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if (fk_key->ref_columns.elements && fk_key->ref_columns.elements != fk_key->columns.elements) { - my_error(ER_WRONG_FK_DEF, MYF(0), fk_key->name ? fk_key->name : - "foreign key without name", - ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF)); + my_printf_error(ER_WRONG_FK_DEF, ER(ER_WRONG_FK_DEF), MYF(0), + (fk_key->name ? + fk_key->name : + "foreign key without name"), + ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF)); DBUG_RETURN(-1); } continue; @@ -678,7 +687,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (key->name && strlen(key->name) > NAME_LEN) { - my_error(ER_TOO_LONG_IDENT, MYF(0), key->name); + my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0), + key->name); DBUG_RETURN(-1); } key_iterator2.rewind (); @@ -718,7 +728,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if (key->name && !tmp_table && !my_strcasecmp(system_charset_info,key->name,primary_key_name)) { - my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name); + my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX), + MYF(0), key->name); DBUG_RETURN(-1); } } @@ -786,7 +797,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { if (!(file->table_flags() & HA_CAN_FULLTEXT)) { - my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0)); + my_message(ER_TABLE_CANT_HANDLE_FT, ER(ER_TABLE_CANT_HANDLE_FT), + MYF(0)); DBUG_RETURN(-1); } } @@ -927,7 +939,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (key->type == Key::SPATIAL) { - my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0)); + my_message(ER_SPATIAL_CANT_HAVE_NULL, + ER(ER_SPATIAL_CANT_HAVE_NULL), MYF(0)); DBUG_RETURN(-1); } } @@ -973,7 +986,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, (key_info->flags & HA_NOSAME))) && column->length != length))) { - my_error(ER_WRONG_SUB_KEY,MYF(0)); + my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0)); DBUG_RETURN(-1); } else if (!(file->table_flags() & HA_NO_PREFIX_CHAR_KEYS)) @@ -1026,7 +1039,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { if (primary_key) { - my_error(ER_MULTIPLE_PRI_KEY,MYF(0)); + my_message(ER_MULTIPLE_PRI_KEY, ER(ER_MULTIPLE_PRI_KEY), + MYF(0)); DBUG_RETURN(-1); } key_name=primary_key_name; @@ -1037,7 +1051,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, key_info_buffer,key_info); if (check_if_keyname_exists(key_name,key_info_buffer,key_info)) { - my_error(ER_DUP_KEYNAME,MYF(0),key_name); + my_printf_error(ER_DUP_KEYNAME, ER(ER_DUP_KEYNAME), MYF(0), + key_name); DBUG_RETURN(-1); } key_info->name=(char*) key_name; @@ -1045,7 +1060,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } if (!key_info->name || check_column_name(key_info->name)) { - my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name); + my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX), + MYF(0), key_info->name); DBUG_RETURN(-1); } if (!(key_info->flags & HA_NULL_PART_KEY)) @@ -1062,12 +1078,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if (!unique_key && !primary_key && (file->table_flags() & HA_REQUIRE_PRIMARY_KEY)) { - my_error(ER_REQUIRES_PRIMARY_KEY,MYF(0)); + my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0)); DBUG_RETURN(-1); } if (auto_increment > 0) { - my_error(ER_WRONG_AUTO_KEY,MYF(0)); + my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0)); DBUG_RETURN(-1); } /* Sort keys in optimized order */ @@ -1123,7 +1139,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, /* Check for duplicate fields and check type of table to create */ if (!fields.elements) { - my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0)); + my_message(ER_TABLE_MUST_HAVE_COLUMNS, ER(ER_TABLE_MUST_HAVE_COLUMNS), + MYF(0)); DBUG_RETURN(TRUE); } if ((new_db_type= ha_checktype(create_info->db_type)) != @@ -1153,7 +1170,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && (file->table_flags() & HA_NO_TEMP_TABLES)) { - my_error(ER_ILLEGAL_HA,MYF(0),table_name); + my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0), table_name); DBUG_RETURN(TRUE); } #endif @@ -1204,7 +1221,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->table_existed= 1; // Mark that table existed DBUG_RETURN(FALSE); } - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0), + alias); DBUG_RETURN(TRUE); } if (wait_if_global_read_lock(thd, 0, 1)) @@ -1220,7 +1238,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, error= FALSE; } else - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + my_printf_error(ER_TABLE_EXISTS_ERROR, + ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name); goto end; } } @@ -1249,7 +1268,8 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, error= FALSE; } else - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + my_printf_error(ER_TABLE_EXISTS_ERROR, + ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name); goto end; } } @@ -1457,7 +1477,8 @@ mysql_rename_table(enum db_type base, } delete file; if (error) - my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error); + my_printf_error(ER_ERROR_ON_RENAME, ER(ER_ERROR_ON_RENAME), + MYF(0), from, to, error); DBUG_RETURN(error != 0); } @@ -1999,7 +2020,8 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, if (!(key_cache= get_key_cache(key_cache_name))) { pthread_mutex_unlock(&LOCK_global_system_variables); - my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str); + my_printf_error(ER_UNKNOWN_KEY_CACHE, ER(ER_UNKNOWN_KEY_CACHE), MYF(0), + key_cache_name->str); DBUG_RETURN(TRUE); } pthread_mutex_unlock(&LOCK_global_system_variables); @@ -2109,7 +2131,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, check_table_name(src_table,table_ident->table.length)) || table_ident->db.str && check_db_name((src_db= table_ident->db.str))) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0), + src_table); DBUG_RETURN(TRUE); } @@ -2128,7 +2151,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, reg_ext, NullS); if (access(src_path, F_OK)) { - my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + src_table); goto err; } } @@ -2211,7 +2235,8 @@ table_exists: res= FALSE; } else - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0), + table_name); err: pthread_mutex_lock(&LOCK_open); @@ -2467,7 +2492,8 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, } if (idx>= table->keys) { - my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop_key->name); + my_printf_error(ER_CANT_DROP_FIELD_OR_KEY, ER(ER_CANT_DROP_FIELD_OR_KEY), + MYF(0), drop_key->name); /*don't need to free((gptr) key_numbers);*/ DBUG_RETURN(-1); } @@ -2590,7 +2616,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { if (find_temporary_table(thd,new_db,new_name_buff)) { - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), new_name_buff); DBUG_RETURN(TRUE); } } @@ -2600,7 +2627,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, F_OK)) { /* Table will be closed in do_command() */ - my_error(ER_TABLE_EXISTS_ERROR,MYF(0), new_alias); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), new_alias); DBUG_RETURN(TRUE); } } @@ -2640,7 +2668,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, error=0; if (!access(new_name_buff,F_OK)) { - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), new_name); error= -1; } else @@ -2783,7 +2812,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { if (def->sql_type == FIELD_TYPE_BLOB) { - my_error(ER_BLOB_CANT_HAVE_DEFAULT,MYF(0),def->change); + my_printf_error(ER_BLOB_CANT_HAVE_DEFAULT, + ER(ER_BLOB_CANT_HAVE_DEFAULT), MYF(0), def->change); DBUG_RETURN(TRUE); } def->def=alter->def; // Use new default @@ -2797,7 +2827,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { if (def->change && ! def->field) { - my_error(ER_BAD_FIELD_ERROR,MYF(0),def->change,table_name); + my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0), + def->change, table_name); DBUG_RETURN(TRUE); } if (!def->after) @@ -2815,7 +2846,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } if (!find) { - my_error(ER_BAD_FIELD_ERROR,MYF(0),def->after,table_name); + my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), + MYF(0), def->after, table_name); DBUG_RETURN(TRUE); } find_it.after(def); // Put element after this @@ -2823,13 +2855,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } if (alter_info->alter_list.elements) { - my_error(ER_BAD_FIELD_ERROR,MYF(0),alter_info->alter_list.head()->name, - table_name); + my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0), + alter_info->alter_list.head()->name, table_name); DBUG_RETURN(TRUE); } if (!create_list.elements) { - my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0)); + my_message(ER_CANT_REMOVE_ALL_FIELDS, ER(ER_CANT_REMOVE_ALL_FIELDS), + MYF(0)); DBUG_RETURN(TRUE); } @@ -2918,7 +2951,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (key->name && !my_strcasecmp(system_charset_info,key->name,primary_key_name)) { - my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name); + my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX), + MYF(0), key->name); DBUG_RETURN(TRUE); } } @@ -2926,14 +2960,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (alter_info->drop_list.elements) { - my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0), - alter_info->drop_list.head()->name); + my_printf_error(ER_CANT_DROP_FIELD_OR_KEY, + ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0), + alter_info->drop_list.head()->name); goto err; } if (alter_info->alter_list.elements) { - my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0), - alter_info->alter_list.head()->name); + my_printf_error(ER_CANT_DROP_FIELD_OR_KEY, + ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0), + alter_info->alter_list.head()->name); goto err; } @@ -3121,7 +3157,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (!access(new_name_buff,F_OK)) { error=1; - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), new_name_buff); VOID(quick_rm_table(new_db_type,new_db,tmp_name)); VOID(pthread_mutex_unlock(&LOCK_open)); goto err; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index b71bb4ba42a..13f127cc54b 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -74,7 +74,8 @@ bool 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); + 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); } @@ -82,7 +83,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { if (!create) { - my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); + my_message(ER_TRG_DOES_NOT_EXIST, ER(ER_TRG_DOES_NOT_EXIST), MYF(0)); DBUG_RETURN(TRUE); } @@ -142,7 +143,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; } @@ -152,7 +153,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; } } @@ -266,7 +267,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; } @@ -433,7 +434,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); } diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index d27b72c02a7..903b80e6949 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -369,7 +369,7 @@ int mysql_create_function(THD *thd,udf_func *udf) if (!initialized) { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); DBUG_RETURN(1); } @@ -380,19 +380,20 @@ int mysql_create_function(THD *thd,udf_func *udf) */ if (strchr(udf->dl, '/')) { - my_error(ER_UDF_NO_PATHS, MYF(0)); + my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0)); DBUG_RETURN(1); } if (udf->name.length > NAME_LEN) { - my_error(ER_TOO_LONG_IDENT, MYF(0), udf->name); + my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0), + udf->name); DBUG_RETURN(1); } rw_wrlock(&THR_LOCK_udf); if ((hash_search(&udf_hash,(byte*) udf->name.str, udf->name.length))) { - my_error(ER_UDF_EXISTS, MYF(0), udf->name); + my_printf_error(ER_UDF_EXISTS, ER(ER_UDF_EXISTS), MYF(0), udf->name); goto err; } if (!(dl = find_udf_dl(udf->dl))) @@ -401,7 +402,8 @@ int mysql_create_function(THD *thd,udf_func *udf) { DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)", udf->dl,errno,dlerror())); - my_error(ER_CANT_OPEN_LIBRARY, MYF(0), udf->dl, errno, dlerror()); + my_printf_error(ER_CANT_OPEN_LIBRARY, ER(ER_CANT_OPEN_LIBRARY), MYF(0), + udf->dl, errno, dlerror()); goto err; } new_dl=1; @@ -411,7 +413,8 @@ int mysql_create_function(THD *thd,udf_func *udf) if (udf->func == NULL) { - my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), udf->name); + my_printf_error(ER_CANT_FIND_DL_ENTRY, ER(ER_CANT_FIND_DL_ENTRY), MYF(0), + udf->name); goto err; } udf->name.str=strdup_root(&mem,udf->name.str); @@ -445,7 +448,8 @@ int mysql_create_function(THD *thd,udf_func *udf) close_thread_tables(thd); if (error) { - my_error(ER_ERROR_ON_WRITE, MYF(0), "func@mysql", error); + my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0), + "func@mysql", error); del_udf(u_d); goto err; } @@ -468,14 +472,15 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) DBUG_ENTER("mysql_drop_function"); if (!initialized) { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); DBUG_RETURN(1); } rw_wrlock(&THR_LOCK_udf); if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name->str, (uint) udf_name->length))) { - my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str); + my_printf_error(ER_FUNCTION_NOT_DEFINED, ER(ER_FUNCTION_NOT_DEFINED), + MYF(0), udf_name->str); goto err; } del_udf(udf); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 6a2d11ba7f5..5969f1ce3fa 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -75,7 +75,7 @@ bool select_union::send_data(List<Item> &values) unit->offset_limit_cnt--; return 0; } - fill_record(table->field, values, 1); + fill_record(thd, table->field, values, 1); if (thd->net.report_error || write_record(thd, table,&info)) { if (thd->net.last_errno == ER_RECORD_FILE_FULL) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8d64d30a9e0..ccdc64638bb 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -73,7 +73,8 @@ static bool check_fields(THD *thd, List<Item> &items) if (!(field= item->filed_for_view_update())) { /* item has name, because it comes from VIEW SELECT list */ - my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name); + my_printf_error(ER_NONUPDATEABLE_COLUMN, ER(ER_NONUPDATEABLE_COLUMN), + MYF(0), item->name); return TRUE; } /* @@ -164,7 +165,8 @@ bool mysql_update(THD *thd, } if (!table_list->updatable || check_key_in_view(thd, table_list)) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), table_list->alias, "UPDATE"); DBUG_RETURN(TRUE); } if (table->timestamp_field) @@ -362,16 +364,9 @@ bool mysql_update(THD *thd, if (!(select && select->skip_record())) { store_record(table,record[1]); - if (fill_record(fields,values, 0) || thd->net.report_error) - { - /* Field::store methods can't send errors */ - if (!thd->net.report_error) - { - /* TODO: convert last warning to error */ - my_error(ER_UNKNOWN_ERROR, MYF(0)); - } + if (fill_record(thd, fields, values, 0)) break; /* purecov: inspected */ - } + found++; if (table->triggers) @@ -478,7 +473,7 @@ bool mysql_update(THD *thd, thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ thd->abort_on_warning= 0; free_io_cache(table); - DBUG_RETURN(FALSE); + DBUG_RETURN(error >= 0 || thd->net.report_error); err: delete select; @@ -504,11 +499,10 @@ err: order - ORDER BY clause list RETURN VALUE - 0 - OK - 1 - error (message is sent to user) - -1 - error (message is not sent to user) + FALSE OK + TRUE error */ -int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, +bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, Item **conds, uint order_num, ORDER *order) { TABLE *table= table_list->table; @@ -532,16 +526,17 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, setup_order(thd, select_lex->ref_pointer_array, table_list, all_fields, all_fields, order) || setup_ftfuncs(select_lex)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* Check that we are not using table that we are updating in a sub select */ if (unique_table(table_list, table_list->next_independent())) { - my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); - DBUG_RETURN(-1); + my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), MYF(0), + table_list->real_name); + DBUG_RETURN(TRUE); } select_lex->fix_prepare_information(thd, conds); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -655,7 +650,8 @@ bool mysql_multi_update_prepare(THD *thd) if ((readonly_tables & tl->table->map) && (tables_for_update & tl->table->map)) { - my_error(ER_NON_UPDATABLE_TABLE, MYF(0), tl->alias, "UPDATE"); + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), tl->alias, "UPDATE"); DBUG_RETURN(TRUE); } } @@ -741,7 +737,7 @@ int multi_update::prepare(List<Item> ¬_used_values, if (!tables_to_update) { - my_error(ER_NO_TABLES_USED, MYF(0)); + my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0)); DBUG_RETURN(1); } @@ -1028,16 +1024,10 @@ bool multi_update::send_data(List<Item> ¬_used_values) { table->status|= STATUS_UPDATED; store_record(table,record[1]); - if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0)) - { - /* Field::store methods can't send errors */ - if (!thd->net.report_error) - { - /* TODO: convert last warning to error */ - my_error(ER_UNKNOWN_ERROR, MYF(0)); - } + if (fill_record(thd, *fields_for_table[offset], + *values_for_table[offset], 0)) DBUG_RETURN(1); - } + found++; if (compare_record(table, thd->query_id)) { @@ -1075,7 +1065,7 @@ bool multi_update::send_data(List<Item> ¬_used_values) { int error; TABLE *tmp_table= tmp_tables[offset]; - fill_record(tmp_table->field+1, *values_for_table[offset], 1); + fill_record(thd, tmp_table->field+1, *values_for_table[offset], 1); found++; /* Store pointer to row */ memcpy((char*) tmp_table->field[0]->ptr, diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 7894287aee4..296d6c16590 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -71,9 +71,10 @@ bool mysql_create_view(THD *thd, if (lex->derived_tables || lex->variables_used || lex->param_list.elements) { - my_error((lex->derived_tables ? + int err= (lex->derived_tables ? ER_VIEW_SELECT_DERIVED : - ER_VIEW_SELECT_VARIABLE), MYF(0)); + ER_VIEW_SELECT_VARIABLE); + my_message(err, ER(err), MYF(0)); res= TRUE; goto err; } @@ -188,7 +189,8 @@ bool mysql_create_view(THD *thd, /* is this table temporary and is not view? */ if (tbl->table->tmp_table != NO_TMP_TABLE && !tbl->view) { - my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias); + my_printf_error(ER_VIEW_SELECT_TMPTABLE, + ER(ER_VIEW_SELECT_TMPTABLE), MYF(0), tbl->alias); res= TRUE; goto err; } @@ -198,7 +200,8 @@ bool mysql_create_view(THD *thd, strcmp(tbl->view_db.str, view->db) == 0 && strcmp(tbl->view_name.str, view->real_name) == 0) { - my_error(ER_NO_SUCH_TABLE, MYF(0), tbl->view_db.str, tbl->view_name.str); + my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0), + tbl->view_db.str, tbl->view_name.str); res= TRUE; goto err; } @@ -253,7 +256,8 @@ bool mysql_create_view(THD *thd, { if (strcmp(item->name, check->name) == 0) { - my_error(ER_DUP_FIELDNAME, MYF(0), item->name); + my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME), + MYF(0), item->name); DBUG_RETURN(TRUE); } } @@ -426,7 +430,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, { if (mode == VIEW_CREATE_NEW) { - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), view->alias); + my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + MYF(0), view->alias); DBUG_RETURN(-1); } @@ -436,8 +441,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, if (!parser->ok() || strncmp("VIEW", parser->type()->str, parser->type()->length)) { - my_error(ER_WRONG_OBJECT, MYF(0), (view->db ? view->db : thd->db), - view->real_name, "VIEW"); + my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0), + (view->db ? view->db : thd->db), + view->real_name, "VIEW"); DBUG_RETURN(-1); } @@ -457,7 +463,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, { if (mode == VIEW_ALTER) { - my_error(ER_NO_SUCH_TABLE, MYF(0), view->db, view->alias); + my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0), + view->db, view->alias); DBUG_RETURN(-1); } } @@ -500,7 +507,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, if (view->with_check != VIEW_CHECK_NONE && !view->updatable_view) { - my_error(ER_VIEW_NONUPD_CHECK, MYF(0), view->db, view->real_name); + my_printf_error(ER_VIEW_NONUPD_CHECK, ER(ER_VIEW_NONUPD_CHECK), MYF(0), + view->db, view->real_name); DBUG_RETURN(-1); } @@ -671,7 +679,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) if (check_table_access(thd, SELECT_ACL, view_tables, 1) && check_table_access(thd, SHOW_VIEW_ACL, table, 1)) { - my_error(ER_VIEW_NO_EXPLAIN, MYF(0)); + my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0)); goto err; } } @@ -851,9 +859,11 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) continue; } if (type) - my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->real_name, "VIEW"); + my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0), + view->db, view->real_name, "VIEW"); else - my_error(ER_BAD_TABLE_ERROR, MYF(0), name); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + name); goto err; } if (my_delete(path, MYF(MY_WME))) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bdeb5a7d98d..ccffefc4b8e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -813,7 +813,7 @@ query: if (!thd->bootstrap && (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) { - my_error(ER_EMPTY_QUERY, MYF(0)); + my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0)); YYABORT; } else @@ -1463,7 +1463,8 @@ sp_fdparam: if (spc->find_pvar(&$1, TRUE)) { - my_error(ER_SP_DUP_PARAM, MYF(0), $1.str); + my_printf_error(ER_SP_DUP_PARAM, ER(ER_SP_DUP_PARAM), MYF(0), + $1.str); YYABORT; } spc->push_pvar(&$1, (enum enum_field_types)$2, sp_param_in); @@ -1489,7 +1490,8 @@ sp_pdparam: if (spc->find_pvar(&$2, TRUE)) { - my_error(ER_SP_DUP_PARAM, MYF(0), $2.str); + my_printf_error(ER_SP_DUP_PARAM, ER(ER_SP_DUP_PARAM), MYF(0), + $2.str); YYABORT; } spc->push_pvar(&$2, (enum enum_field_types)$3, @@ -1523,12 +1525,14 @@ sp_decls: better error handling this way.) */ if (($2.vars || $2.conds) && ($1.curs || $1.hndlrs)) { /* Variable or condition following cursor or handler */ - my_error(ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0)); + my_message(ER_SP_VARCOND_AFTER_CURSHNDLR, + ER(ER_SP_VARCOND_AFTER_CURSHNDLR), MYF(0)); YYABORT; } if ($2.curs && $1.hndlrs) { /* Cursor following handler */ - my_error(ER_SP_CURSOR_AFTER_HANDLER, MYF(0)); + my_message(ER_SP_CURSOR_AFTER_HANDLER, + ER(ER_SP_CURSOR_AFTER_HANDLER), MYF(0)); YYABORT; } $$.vars= $1.vars + $2.vars; @@ -1576,7 +1580,8 @@ sp_decl: if (spc->find_cond(&$2, TRUE)) { - my_error(ER_SP_DUP_COND, MYF(0), $2.str); + my_printf_error(ER_SP_DUP_COND, ER(ER_SP_DUP_COND), MYF(0), + $2.str); YYABORT; } YYTHD->lex->spcont->push_cond(&$2, $5); @@ -1633,7 +1638,8 @@ sp_decl: if (ctx->find_cursor(&$2, &offp, TRUE)) { - my_error(ER_SP_DUP_CURS, MYF(0), $2.str); + my_printf_error(ER_SP_DUP_CURS, ER(ER_SP_DUP_CURS), MYF(0), + $2.str); delete $5; YYABORT; } @@ -1660,12 +1666,14 @@ sp_cursor_stmt: if (lex->sql_command != SQLCOM_SELECT) { - my_error(ER_SP_BAD_CURSOR_QUERY, MYF(0)); + my_message(ER_SP_BAD_CURSOR_QUERY, ER(ER_SP_BAD_CURSOR_QUERY), + MYF(0)); YYABORT; } if (lex->result) { - my_error(ER_SP_BAD_CURSOR_SELECT, MYF(0)); + my_message(ER_SP_BAD_CURSOR_SELECT, ER(ER_SP_BAD_CURSOR_SELECT), + MYF(0)); YYABORT; } lex->sp_lex_in_use= TRUE; @@ -1735,7 +1743,8 @@ sp_hcond: $$= Lex->spcont->find_cond(&$1); if ($$ == NULL) { - my_error(ER_SP_COND_MISMATCH, MYF(0), $1.str); + my_printf_error(ER_SP_COND_MISMATCH, ER(ER_SP_COND_MISMATCH), + MYF(0), $1.str); YYABORT; } } @@ -1764,7 +1773,8 @@ sp_decl_idents: if (spc->find_pvar(&$1, TRUE)) { - my_error(ER_SP_DUP_VAR, MYF(0), $1.str); + my_printf_error(ER_SP_DUP_VAR, ER(ER_SP_DUP_VAR), MYF(0), + $1.str); YYABORT; } spc->push_pvar(&$1, (enum_field_types)0, sp_param_in); @@ -1777,7 +1787,8 @@ sp_decl_idents: if (spc->find_pvar(&$3, TRUE)) { - my_error(ER_SP_DUP_VAR, MYF(0), $3.str); + my_printf_error(ER_SP_DUP_VAR, ER(ER_SP_DUP_VAR), MYF(0), + $3.str); YYABORT; } spc->push_pvar(&$3, (enum_field_types)0, sp_param_in); @@ -1810,7 +1821,7 @@ sp_proc_stmt: } if (lex->sql_command == SQLCOM_CHANGE_DB) { /* "USE db" doesn't work in a procedure */ - my_error(ER_SP_NO_USE, MYF(0)); + my_message(ER_SP_NO_USE, ER(ER_SP_NO_USE), MYF(0)); YYABORT; } /* Don't add an instruction for empty SET statements. @@ -1829,7 +1840,7 @@ sp_proc_stmt: */ if (sp->m_type != TYPE_ENUM_PROCEDURE) { - my_error(ER_SP_BADSTATEMENT, MYF(0)); + my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0)); YYABORT; } else @@ -1859,7 +1870,7 @@ sp_proc_stmt: if (lex->sphead->m_type == TYPE_ENUM_PROCEDURE) { - my_error(ER_SP_BADRETURN, MYF(0)); + my_message(ER_SP_BADRETURN, ER(ER_SP_BADRETURN), MYF(0)); YYABORT; } else @@ -1868,7 +1879,7 @@ sp_proc_stmt: if ($2->type() == Item::SUBSELECT_ITEM) { /* QQ For now, just disallow subselects as values */ - my_error(ER_SP_BADSTATEMENT, MYF(0)); + my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0)); YYABORT; } i= new sp_instr_freturn(lex->sphead->instructions(), @@ -1931,7 +1942,9 @@ sp_proc_stmt: if (! lab) { - my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "LEAVE", $2.str); + my_printf_error(ER_SP_LILABEL_MISMATCH, + ER(ER_SP_LILABEL_MISMATCH), MYF(0), + "LEAVE", $2.str); YYABORT; } else @@ -1961,7 +1974,9 @@ sp_proc_stmt: if (! lab || lab->type != SP_LAB_ITER) { - my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "ITERATE", $2.str); + my_printf_error(ER_SP_LILABEL_MISMATCH, + ER(ER_SP_LILABEL_MISMATCH), MYF(0), + "ITERATE", $2.str); YYABORT; } else @@ -1989,7 +2004,8 @@ sp_proc_stmt: if (lab) { - my_error(ER_SP_LABEL_REDEFINE, MYF(0), $2.str); + my_printf_error(ER_SP_LABEL_REDEFINE, + ER(ER_SP_LABEL_REDEFINE), MYF(0), $2.str); YYABORT; } else @@ -2013,7 +2029,7 @@ sp_proc_stmt: if (sp->m_in_handler) { - my_error(ER_SP_GOTO_IN_HNDLR, MYF(0)); + my_message(ER_SP_GOTO_IN_HNDLR, ER(ER_SP_GOTO_IN_HNDLR), MYF(0)); YYABORT; } lab= ctx->find_label($2.str); @@ -2064,7 +2080,8 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); + my_printf_error(ER_SP_CURSOR_MISMATCH, + ER(ER_SP_CURSOR_MISMATCH), MYF(0), $2.str); YYABORT; } i= new sp_instr_copen(sp->instructions(), lex->spcont, offset); @@ -2079,7 +2096,8 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); + my_printf_error(ER_SP_CURSOR_MISMATCH, + ER(ER_SP_CURSOR_MISMATCH), MYF(0), $2.str); YYABORT; } i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset); @@ -2096,7 +2114,8 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); + my_printf_error(ER_SP_CURSOR_MISMATCH, + ER(ER_SP_CURSOR_MISMATCH), MYF(0), $2.str); YYABORT; } i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset); @@ -2114,7 +2133,8 @@ sp_fetch_list: if (!spc || !(spv = spc->find_pvar(&$1))) { - my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); + my_printf_error(ER_SP_UNDECLARED_VAR, + ER(ER_SP_UNDECLARED_VAR), MYF(0), $1.str); YYABORT; } else @@ -2136,7 +2156,8 @@ sp_fetch_list: if (!spc || !(spv = spc->find_pvar(&$3))) { - my_error(ER_SP_UNDECLARED_VAR, MYF(0), $3.str); + my_printf_error(ER_SP_UNDECLARED_VAR, + ER(ER_SP_UNDECLARED_VAR), MYF(0), $3.str); YYABORT; } else @@ -2260,7 +2281,8 @@ sp_labeled_control: if (lab) { - my_error(ER_SP_LABEL_REDEFINE, MYF(0), $1.str); + my_printf_error(ER_SP_LABEL_REDEFINE, + ER(ER_SP_LABEL_REDEFINE), MYF(0), $1.str); YYABORT; } else @@ -2281,7 +2303,8 @@ sp_labeled_control: if (!lab || my_strcasecmp(system_charset_info, $5.str, lab->name) != 0) { - my_error(ER_SP_LABEL_MISMATCH, MYF(0), $5.str); + my_printf_error(ER_SP_LABEL_MISMATCH, + ER(ER_SP_LABEL_MISMATCH), MYF(0), $5.str); YYABORT; } } @@ -2539,9 +2562,11 @@ default_charset: cinfo->default_table_charset && $4 && !my_charset_same(cinfo->default_table_charset,$4)) { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "CHARACTER SET ", cinfo->default_table_charset->csname, - "CHARACTER SET ", $4->csname); + my_printf_error(ER_CONFLICTING_DECLARATIONS, + ER(ER_CONFLICTING_DECLARATIONS), MYF(0), + "CHARACTER SET ", + cinfo->default_table_charset->csname, + "CHARACTER SET ", $4->csname); YYABORT; } Lex->create_info.default_table_charset= $4; @@ -2556,8 +2581,9 @@ default_collation: cinfo->default_table_charset && $4 && !my_charset_same(cinfo->default_table_charset,$4)) { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $4->name, cinfo->default_table_charset->csname); + my_printf_error(ER_COLLATION_CHARSET_MISMATCH, + ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0), + $4->name, cinfo->default_table_charset->csname); YYABORT; } Lex->create_info.default_table_charset= $4; @@ -2569,7 +2595,8 @@ storage_engines: { $$ = ha_resolve_by_name($1.str,$1.length); if ($$ == DB_TYPE_UNKNOWN) { - my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); + my_printf_error(ER_UNKNOWN_STORAGE_ENGINE, + ER(ER_UNKNOWN_STORAGE_ENGINE), MYF(0), $1.str); YYABORT; } }; @@ -2755,9 +2782,10 @@ type: Lex->uint_geom_type= (uint)$1; $$=FIELD_TYPE_GEOMETRY; #else - my_error(ER_FEATURE_DISABLED, MYF(0) - sym_group_geom.name, - sym_group_geom.needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0) + sym_group_geom.name, + sym_group_geom.needed_define); YYABORT; #endif } @@ -2924,8 +2952,9 @@ attribute: { if (Lex->charset && !my_charset_same(Lex->charset,$2)) { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $2->name,Lex->charset->csname); + my_printf_error(ER_COLLATION_CHARSET_MISMATCH, + ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0), + $2->name,Lex->charset->csname); YYABORT; } else @@ -2950,7 +2979,8 @@ charset_name: { if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0)))) { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str); + my_printf_error(ER_UNKNOWN_CHARACTER_SET, + ER(ER_UNKNOWN_CHARACTER_SET), MYF(0), $1.str); YYABORT; } } @@ -2968,7 +2998,8 @@ old_or_new_charset_name: if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) && !($$=get_old_charset_by_name($1.str))) { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str); + my_printf_error(ER_UNKNOWN_CHARACTER_SET, + ER(ER_UNKNOWN_CHARACTER_SET), MYF(0), $1.str); YYABORT; } } @@ -2984,7 +3015,8 @@ collation_name: { if (!($$=get_charset_by_name($1.str,MYF(0)))) { - my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str); + my_printf_error(ER_UNKNOWN_COLLATION, + ER(ER_UNKNOWN_COLLATION), MYF(0), $1.str); YYABORT; } }; @@ -3073,8 +3105,9 @@ key_type: #ifdef HAVE_SPATIAL $$= Key::SPATIAL; #else - my_error(ER_FEATURE_DISABLED, MYF(0), - sym_group_geom.name, sym_group_geom.needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif }; @@ -3106,7 +3139,7 @@ opt_unique_or_fulltext: #ifdef HAVE_SPATIAL $$= Key::SPATIAL; #else - my_error(ER_FEATURE_DISABLED, MYF(0), + my_message(ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), MYF(0), sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif @@ -3332,7 +3365,8 @@ alter_list_item: if (check_table_name($3->table.str,$3->table.length) || $3->db.str && check_db_name($3->db.str)) { - my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str); + my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), + MYF(0), $3->table.str); YYABORT; } lex->alter_info.flags|= ALTER_RENAME; @@ -3347,8 +3381,9 @@ alter_list_item: $5= $5 ? $5 : $4; if (!my_charset_same($4,$5)) { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $5->name, $4->csname); + my_printf_error(ER_COLLATION_CHARSET_MISMATCH, + ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0), + $5->name, $4->csname); YYABORT; } LEX *lex= Lex; @@ -3470,7 +3505,8 @@ slave_until: !((lex->mi.log_file_name && lex->mi.pos) || (lex->mi.relay_log_name && lex->mi.relay_log_pos))) { - my_error(ER_BAD_SLAVE_UNTIL_COND, MYF(0)); + my_message(ER_BAD_SLAVE_UNTIL_COND, + ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0)); YYABORT; } @@ -4183,9 +4219,10 @@ simple_expr: { if (!$1.symbol->create_func) { - my_error(ER_FEATURE_DISABLED, MYF(0), - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(void))($1.symbol->create_func))(); @@ -4194,9 +4231,10 @@ simple_expr: { if (!$1.symbol->create_func) { - my_error(ER_FEATURE_DISABLED, MYF(0), - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*))($1.symbol->create_func))($3); @@ -4205,9 +4243,10 @@ simple_expr: { if (!$1.symbol->create_func) { - my_error(ER_FEATURE_DISABLED, MYF(0), - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*,Item*))($1.symbol->create_func))($3,$5); @@ -4216,9 +4255,10 @@ simple_expr: { if (!$1.symbol->create_func) { - my_error(ER_FEATURE_DISABLED, MYF(0), - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*,Item*,Item*))($1.symbol->create_func))($3,$5,$7); @@ -4321,8 +4361,9 @@ simple_expr: #ifdef HAVE_SPATIAL $$= $1; #else - my_error(ER_FEATURE_DISABLED, MYF(0), - sym_group_geom.name, sym_group_geom.needed_define); + my_printf_error(ER_FEATURE_DISABLED, + ER(ER_FEATURE_DISABLED), MYF(0), + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif } @@ -5378,7 +5419,8 @@ select_var_ident: if (!lex->spcont || !(t=lex->spcont->find_pvar(&$1))) { - my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); + my_printf_error(ER_SP_UNDECLARED_VAR, + ER(ER_SP_UNDECLARED_VAR), MYF(0), $1.str); YYABORT; } if (! lex->result) @@ -5733,8 +5775,9 @@ update: else if (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), - lex->select_lex.get_table_list()->alias, "UPDATE"); + my_printf_error(ER_NON_UPDATABLE_TABLE, + ER(ER_NON_UPDATABLE_TABLE), MYF(0), + lex->select_lex.get_table_list()->alias, "UPDATE"); YYABORT; } } @@ -6241,7 +6284,8 @@ kill: LEX *lex=Lex; if ($3->fix_fields(lex->thd, 0, &$3) || $3->check_cols(1)) { - my_error(ER_SET_CONSTANTS_ONLY, MYF(0)); + my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), + MYF(0)); YYABORT; } lex->sql_command=SQLCOM_KILL; @@ -6388,7 +6432,7 @@ param_marker: (uchar *) thd->query)); if (!($$= item) || lex->param_list.push_back(item)) { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); YYABORT; } } @@ -6564,8 +6608,9 @@ simple_ident_q: FIXME. Far from perfect solution. See comment for "SET NEW.field_name:=..." for more info. */ - my_error(ER_BAD_FIELD_ERROR, MYF(0), $3.str, - new_row ? "NEW": "OLD"); + my_printf_error(ER_BAD_FIELD_ERROR, + ER(ER_BAD_FIELD_ERROR), MYF(0), + $3.str, new_row ? "NEW": "OLD"); YYABORT; } @@ -6652,8 +6697,9 @@ IDENT_sys: $1.length); if (wlen < $1.length) { - my_error(ER_INVALID_CHARACTER_STRING, MYF(0), cs->csname, - $1.str + wlen); + my_printf_error(ER_INVALID_CHARACTER_STRING, + ER(ER_INVALID_CHARACTER_STRING), MYF(0), + cs->csname, $1.str + wlen); YYABORT; } $$= $1; @@ -7032,7 +7078,8 @@ option_value: */ if (lex->query_tables) { - my_error(ER_SP_SUBSELECT_NYI, MYF(0)); + my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI), + MYF(0)); YYABORT; } sp_instr_set_user_var *i= @@ -7055,7 +7102,8 @@ option_value: sp_instr_set_trigger_field *i; if (lex->query_tables) { - my_error(ER_SP_SUBSELECT_NYI, MYF(0)); + my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI), + MYF(0)); YYABORT; } if ($3) @@ -7084,7 +7132,8 @@ option_value: Error message also should be improved. */ - my_error(ER_BAD_FIELD_ERROR, MYF(0), $1.base_name, "NEW"); + my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), + MYF(0), $1.base_name, "NEW"); YYABORT; } lex->sphead->add_instr(i); @@ -7150,8 +7199,9 @@ option_value: $3= $3 ? $3 : $2; if (!my_charset_same($2,$3)) { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $3->name, $2->csname); + my_printf_error(ER_COLLATION_CHARSET_MISMATCH, + ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0), + $3->name, $2->csname); YYABORT; } lex->var_list.push_back(new set_var_collation_client($3,$3,$3)); @@ -7241,7 +7291,8 @@ internal_variable_name: if (!tmp) YYABORT; if (!tmp->is_struct()) - my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str); + my_printf_error(ER_VARIABLE_IS_NOT_STRUCT, + ER(ER_VARIABLE_IS_NOT_STRUCT), MYF(0), $3.str); $$.var= tmp; $$.base_name= $1; } @@ -7252,7 +7303,8 @@ internal_variable_name: if (!tmp) YYABORT; if (!tmp->is_struct()) - my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str); + my_printf_error(ER_VARIABLE_IS_NOT_STRUCT, + ER(ER_VARIABLE_IS_NOT_STRUCT), MYF(0), $3.str); $$.var= tmp; $$.base_name.str= (char*) "default"; $$.base_name.length= 7; @@ -7533,7 +7585,8 @@ opt_table: lex->grant = DB_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, + ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0)); YYABORT; } } @@ -7545,7 +7598,8 @@ opt_table: lex->grant = DB_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, + ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0)); YYABORT; } } @@ -7557,7 +7611,8 @@ opt_table: lex->grant= GLOBAL_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, + ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0)); YYABORT; } } diff --git a/sql/table.cc b/sql/table.cc index e372de57177..97b5a420279 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -957,11 +957,12 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype) uint length=dirname_part(buff,name); buff[length-1]=0; db=buff+dirname_length(buff); - my_error(ER_NO_SUCH_TABLE,MYF(0),db,form->real_name); + my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0), + db, form->real_name); } else - my_error(ER_FILE_NOT_FOUND,errortype, - fn_format(buff,name,form_dev,reg_ext,0),my_errno); + my_printf_error(ER_FILE_NOT_FOUND, ER(ER_FILE_NOT_FOUND), errortype, + fn_format(buff, name, form_dev, reg_ext, 0), my_errno); break; case 2: { @@ -969,14 +970,15 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype) datext= datext==NullS ? "" : datext; err_no= (my_errno == ENOENT) ? ER_FILE_NOT_FOUND : (my_errno == EAGAIN) ? ER_FILE_USED : ER_CANT_OPEN_FILE; - my_error(err_no,errortype, - fn_format(buff,form->real_name,form_dev,datext,2),my_errno); + my_printf_error(err_no, ER(err_no), errortype, + fn_format(buff, form->real_name, form_dev, datext, 2), + my_errno); break; } default: /* Better wrong error than none */ case 4: - my_error(ER_NOT_FORM_FILE,errortype, - fn_format(buff,name,form_dev,reg_ext,0)); + my_printf_error(ER_NOT_FORM_FILE, ER(ER_NOT_FORM_FILE), errortype, + fn_format(buff, name, form_dev, reg_ext, 0)); break; } DBUG_VOID_RETURN; @@ -1694,7 +1696,8 @@ err: if (thd->net.last_errno == ER_BAD_FIELD_ERROR) { thd->clear_error(); - my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str); + my_printf_error(ER_VIEW_INVALID, ER(ER_VIEW_INVALID), MYF(0), + view_db.str, view_name.str); } thd->lex->select_lex.no_wrap_view_item= save_wrapper; thd->lex->current_select= current_select_save; @@ -1730,7 +1733,8 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure) } else { - my_error(ER_VIEW_CHECK_FAILED, MYF(0), view_db.str, view_name.str); + my_printf_error(ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED), MYF(0), + view_db.str, view_name.str); return(VIEW_CHECK_ERROR); } } diff --git a/sql/unireg.cc b/sql/unireg.cc index 2a6abdb1cfd..8988c847476 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -383,7 +383,7 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, if (create_fields.elements > MAX_FIELDS) { - my_error(ER_TOO_MANY_FIELDS,MYF(0)); + my_message(ER_TOO_MANY_FIELDS, ER(ER_TOO_MANY_FIELDS), MYF(0)); DBUG_RETURN(1); } @@ -448,7 +448,7 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, if (info_length+(ulong) create_fields.elements*FCOMP+288+ n_length+int_length+com_length > 65535L || int_count > 255) { - my_error(ER_TOO_MANY_FIELDS,MYF(0)); + my_message(ER_TOO_MANY_FIELDS, ER(ER_TOO_MANY_FIELDS), MYF(0)); DBUG_RETURN(1); } |