Skip to content

Commit 31f7811

Browse files
author
bell@sanja.is.com.ua
committed
post-review fixes
1 parent 5bf7a8c commit 31f7811

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+938
-593
lines changed

mysql-test/r/rpl_rotate_logs.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
drop table if exists t1, t2, t3, t4;
22
drop table if exists t1, t2, t3, t4;
33
start slave;
4-
ERROR HY000: File '/home/bell/mysql/bk/work-error-5.0/mysql-test/var/slave-data/master.info' not found (Errcode: 13)
4+
ERROR HY000: File 'TESTDIR/var/slave-data/master.info' not found (Errcode: 13)
55
start slave;
66
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
77
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';

mysql-test/t/rpl_rotate_logs.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ drop table if exists t1, t2, t3, t4;
2323

2424
# START SLAVE will fail because it can't read the file (mode 000)
2525
# (system error 13)
26+
--replace_result $MYSQL_TEST_DIR TESTDIR
2627
--error 1105
2728
start slave;
2829
system chmod 600 var/slave-data/master.info;

mysys/my_error.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222

2323
/* Define some external variables for error handling */
2424

25+
/*
26+
WARNING!
27+
my_error family functions have to be used according following rules:
28+
- if message have not parameters use my_message(ER_CODE, ER(ER_CODE), MYF(N))
29+
- if message have only integer parameters, string constants (created
30+
inside program) or string put (and cut if it is need) in some limited
31+
length buffer before passing it as parameter then you can use
32+
my_error(ER_CODE, MYF(N), ...). Never pass string get from user to
33+
my_error.
34+
- in all other cases use my_printf_error(ER_CODE, ER(ER_CODE), MYF(N), ...)
35+
*/
36+
2537
const char ** NEAR my_errmsg[MAXMAPS]={0,0,0,0};
2638
char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
2739

sql/filesort.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
278278
}
279279
}
280280
if (error)
281-
my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG));
281+
my_message(ER_FILSORT_ABORT, ER(ER_FILSORT_ABORT),
282+
MYF(ME_ERROR+ME_WAITTANG));
282283
else
283284
statistic_add(thd->status_var.filesort_rows,
284285
(ulong) records, &LOCK_status);

sql/ha_innodb.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,10 @@ innobase_mysql_tmpfile(void)
462462
if (fd2 < 0) {
463463
DBUG_PRINT("error",("Got error %d on dup",fd2));
464464
my_errno=errno;
465-
my_error(EE_OUT_OF_FILERESOURCES,
466-
MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
465+
my_printf_error(EE_OUT_OF_FILERESOURCES,
466+
ER(EE_OUT_OF_FILERESOURCES),
467+
MYF(ME_BELL+ME_WAITTANG),
468+
filename, my_errno);
467469
}
468470
my_close(fd, MYF(MY_WME));
469471
}

sql/handler.cc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
515515
if ((error=ndbcluster_commit(thd,trans->ndb_tid)))
516516
{
517517
if (error == -1)
518-
my_error(ER_ERROR_DURING_COMMIT, MYF(0));
518+
my_message_(ER_ERROR_DURING_COMMIT, ER(ER_ERROR_DURING_COMMIT),
519+
MYF(0));
519520
error=1;
520521
}
521522
if (trans == &thd->transaction.all)
@@ -584,7 +585,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
584585
if ((error=ndbcluster_rollback(thd, trans->ndb_tid)))
585586
{
586587
if (error == -1)
587-
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0));
588+
my_message(ER_ERROR_DURING_ROLLBACK, ER(ER_ERROR_DURING_ROLLBACK),
589+
MYF(0));
588590
error=1;
589591
}
590592
trans->ndb_tid = 0;
@@ -1183,7 +1185,8 @@ void handler::print_error(int error, myf errflag)
11831185
str.length(max_length-4);
11841186
str.append("...");
11851187
}
1186-
my_error(ER_DUP_ENTRY,MYF(0),str.c_ptr(),key_nr+1);
1188+
my_printf_error(ER_DUP_ENTRY, ER(ER_DUP_ENTRY), MYF(0),
1189+
str.c_ptr(), key_nr+1);
11871190
DBUG_VOID_RETURN;
11881191
}
11891192
textno=ER_DUP_KEY;
@@ -1205,7 +1208,7 @@ void handler::print_error(int error, myf errflag)
12051208
textno=ER_CRASHED_ON_REPAIR;
12061209
break;
12071210
case HA_ERR_OUT_OF_MEM:
1208-
my_error(ER_OUT_OF_RESOURCES,errflag);
1211+
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), errflag);
12091212
DBUG_VOID_RETURN;
12101213
case HA_ERR_WRONG_COMMAND:
12111214
textno=ER_ILLEGAL_HA;
@@ -1251,9 +1254,13 @@ void handler::print_error(int error, myf errflag)
12511254
{
12521255
const char* engine= table_type();
12531256
if (temporary)
1254-
my_error(ER_GET_TEMPORARY_ERRMSG,MYF(0),error,str.ptr(),engine);
1257+
my_printf_error(ER_GET_TEMPORARY_ERRMSG,
1258+
ER(ER_GET_TEMPORARY_ERRMSG), MYF(0),
1259+
error, str.ptr(), engine);
12551260
else
1256-
my_error(ER_GET_ERRMSG,MYF(0),error,str.ptr(),engine);
1261+
my_printf_error(ER_GET_ERRMSG,
1262+
ER(ER_GET_ERRMSG), MYF(0),
1263+
error, str.ptr(), engine);
12571264
}
12581265
else
12591266
my_error(ER_GET_ERRNO,errflag,error);
@@ -1381,7 +1388,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
13811388
error=table.file->create(name,&table,create_info);
13821389
VOID(closefrm(&table));
13831390
if (error)
1384-
my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error);
1391+
my_printf_error(ER_CANT_CREATE_TABLE, ER(ER_CANT_CREATE_TABLE),
1392+
MYF(ME_BELL+ME_WAITTANG),
1393+
name,error);
13851394
DBUG_RETURN(error != 0);
13861395
}
13871396

sql/item.cc

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
15121512
{
15131513
if (!(*refer)->fixed)
15141514
{
1515-
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
1516-
"forward reference in item list");
1515+
my_printf_error(ER_ILLEGAL_REFERENCE, ER(ER_ILLEGAL_REFERENCE),
1516+
MYF(0), name, "forward reference in item list");
15171517
return TRUE;
15181518
}
15191519

@@ -2418,8 +2418,9 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference)
24182418
{
24192419
if (!(*ref)->fixed)
24202420
{
2421-
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
2422-
"forward reference in item list");
2421+
my_printf_error(ER_ILLEGAL_REFERENCE,
2422+
ER(ER_ILLEGAL_REFERENCE), MYF(0),
2423+
name, "forward reference in item list");
24232424
return TRUE;
24242425
}
24252426
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)
24332434
{
24342435
if (!(*ref)->fixed)
24352436
{
2436-
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
2437-
"forward reference in item list");
2437+
my_printf_error(ER_ILLEGAL_REFERENCE,
2438+
ER(ER_ILLEGAL_REFERENCE), MYF(0),
2439+
name, "forward reference in item list");
24382440
return TRUE;
24392441
}
24402442
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)
24542456
thd->lex->current_select->having_fix_field))) ||
24552457
!(*ref)->fixed)
24562458
{
2457-
my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
2458-
((*ref)->with_sum_func?
2459-
"reference on group function":
2460-
"forward reference in item list"));
2459+
my_printf_error(ER_ILLEGAL_REFERENCE, ER(ER_ILLEGAL_REFERENCE), MYF(0),
2460+
name,
2461+
((*ref)->with_sum_func?
2462+
"reference on group function":
2463+
"forward reference in item list"));
24612464
return TRUE;
24622465
}
24632466
max_length= (*ref)->max_length;
@@ -3115,11 +3118,12 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
31153118
*old_derivation= collation.derivation_name();
31163119
if (item_type == STRING_RESULT && collation.aggregate(item->collation))
31173120
{
3118-
my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0),
3119-
old_cs, old_derivation,
3120-
item->collation.collation->name,
3121-
item->collation.derivation_name(),
3122-
"UNION");
3121+
my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
3122+
ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
3123+
old_cs, old_derivation,
3124+
item->collation.collation->name,
3125+
item->collation.derivation_name(),
3126+
"UNION");
31233127
return 1;
31243128
}
31253129

sql/item_cmpfunc.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ static void agg_cmp_type(Item_result *type, Item **items, uint nitems)
5353

5454
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname)
5555
{
56-
my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
57-
c1.collation->name,c1.derivation_name(),
58-
c2.collation->name,c2.derivation_name(),
59-
fname);
56+
my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
57+
ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
58+
c1.collation->name,c1.derivation_name(),
59+
c2.collation->name,c2.derivation_name(),
60+
fname);
6061
}
6162

6263

sql/item_func.cc

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ bool check_reserved_words(LEX_STRING *name)
4545
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
4646
const char *fname)
4747
{
48-
my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
49-
c1.collation->name,c1.derivation_name(),
50-
c2.collation->name,c2.derivation_name(),
51-
fname);
48+
my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
49+
ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
50+
c1.collation->name, c1.derivation_name(),
51+
c2.collation->name, c2.derivation_name(),
52+
fname);
5253
}
5354

5455
static void my_coll_agg_error(DTCollation &c1,
5556
DTCollation &c2,
5657
DTCollation &c3,
5758
const char *fname)
5859
{
59-
my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
60-
c1.collation->name,c1.derivation_name(),
61-
c2.collation->name,c2.derivation_name(),
62-
c3.collation->name,c3.derivation_name(),
63-
fname);
60+
my_printf_error(ER_CANT_AGGREGATE_3COLLATIONS,
61+
ER(ER_CANT_AGGREGATE_3COLLATIONS), MYF(0),
62+
c1.collation->name, c1.derivation_name(),
63+
c2.collation->name, c2.derivation_name(),
64+
c3.collation->name, c3.derivation_name(),
65+
fname);
6466
}
6567

6668

@@ -74,7 +76,8 @@ static void my_coll_agg_error(Item** args, uint count, const char *fname)
7476
args[2]->collation,
7577
fname);
7678
else
77-
my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname);
79+
my_printf_error(ER_CANT_AGGREGATE_NCOLLATIONS,
80+
ER(ER_CANT_AGGREGATE_NCOLLATIONS), MYF(0),fname);
7881
}
7982

8083

@@ -3112,7 +3115,8 @@ bool Item_func_match::fix_index()
31123115
key=NO_SUCH_KEY;
31133116
return 0;
31143117
}
3115-
my_error(ER_FT_MATCHING_KEY_NOT_FOUND,MYF(0));
3118+
my_message(ER_FT_MATCHING_KEY_NOT_FOUND,
3119+
ER(ER_FT_MATCHING_KEY_NOT_FOUND), MYF(0));
31163120
return 1;
31173121
}
31183122

@@ -3241,7 +3245,8 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
32413245
{
32423246
if (!var->is_struct())
32433247
{
3244-
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), base_name->str);
3248+
my_printf_error(ER_VARIABLE_IS_NOT_STRUCT, ER(ER_VARIABLE_IS_NOT_STRUCT),
3249+
MYF(0), base_name->str);
32453250
return 0;
32463251
}
32473252
}

sql/item_strfunc.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ String my_empty_string("",default_charset_info);
4242
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
4343
const char *fname)
4444
{
45-
my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
46-
c1.collation->name,c1.derivation_name(),
47-
c2.collation->name,c2.derivation_name(),
48-
fname);
45+
my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
46+
ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
47+
c1.collation->name, c1.derivation_name(),
48+
c2.collation->name, c2.derivation_name(),
49+
fname);
4950
}
5051

5152
uint nr_of_decimals(const char *str)
@@ -2243,16 +2244,18 @@ void Item_func_set_collation::fix_length_and_dec()
22432244
{
22442245
if (!(set_collation= get_charset_by_name(colname,MYF(0))))
22452246
{
2246-
my_error(ER_UNKNOWN_COLLATION, MYF(0), colname);
2247+
my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0),
2248+
colname);
22472249
return;
22482250
}
22492251
}
22502252

22512253
if (!set_collation ||
22522254
!my_charset_same(args[0]->collation.collation,set_collation))
22532255
{
2254-
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
2255-
colname,args[0]->collation.collation->csname);
2256+
my_printf_error(ER_COLLATION_CHARSET_MISMATCH,
2257+
ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
2258+
colname, args[0]->collation.collation->csname);
22562259
return;
22572260
}
22582261
collation.set(set_collation, DERIVATION_EXPLICIT);

sql/item_subselect.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref)
167167
// We can't substitute aggregate functions like "SELECT (max(i))"
168168
if (substype() == SINGLEROW_SUBS && (*ref)->with_sum_func)
169169
{
170-
my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0));
170+
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
171+
MYF(0));
171172
return TRUE;
172173
}
173174
return ret;

sql/item_sum.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
220220

221221
if (!thd->allow_sum_func)
222222
{
223-
my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
223+
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
224+
MYF(0));
224225
return TRUE;
225226
}
226227
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)
255256
Item *item= args[0];
256257
if (!thd->allow_sum_func)
257258
{
258-
my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
259+
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
260+
MYF(0));
259261
return TRUE;
260262
}
261263
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)
20652067

20662068
if (!thd->allow_sum_func)
20672069
{
2068-
my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
2070+
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
2071+
MYF(0));
20692072
return TRUE;
20702073
}
20712074

sql/lock.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
430430
*write_lock_used=table;
431431
if (table->db_stat & HA_READ_ONLY)
432432
{
433-
my_error(ER_OPEN_AS_READONLY,MYF(0),table->table_name);
433+
my_printf_error(ER_OPEN_AS_READONLY, ER(ER_OPEN_AS_READONLY), MYF(0),
434+
table->table_name);
434435
my_free((gptr) sql_lock,MYF(0));
435436
return 0;
436437
}
@@ -794,7 +795,8 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
794795
{
795796
if (thd->global_read_lock) // This thread had the read locks
796797
{
797-
my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0));
798+
my_message(ER_CANT_UPDATE_WITH_READLOCK,
799+
ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0));
798800
(void) pthread_mutex_unlock(&LOCK_open);
799801
DBUG_RETURN(1);
800802
}

sql/log.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,9 +1515,10 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
15151515
if (error)
15161516
{
15171517
if (my_errno == EFBIG)
1518-
my_error(ER_TRANS_CACHE_FULL, MYF(0));
1518+
my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0));
15191519
else
1520-
my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
1520+
my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0),
1521+
name, errno);
15211522
write_error=1;
15221523
}
15231524
if (file == &log_file)

0 commit comments

Comments
 (0)