Skip to content

Commit 0b0f559

Browse files
committed
WL#8206: Introduce separate error code range for 5.7
This patch introduces support for separate error code ranges where errors in each range is consecutively numbered. This means that it is possible to have separate error code ranges for each GA release. All new error codes in 5.7 are changed so that that they start at 3000.
1 parent 34fcffa commit 0b0f559

Some content is hidden

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

61 files changed

+388
-386
lines changed

extra/comp_err.c

+42-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -246,7 +246,6 @@ static void print_escaped_string(FILE *f, const char *str)
246246

247247
static int create_header_files(struct errors *error_head)
248248
{
249-
uint er_last= 0;
250249
FILE *er_definef, *sql_statef, *er_namef;
251250
struct errors *tmp_error;
252251
struct message *er_msg;
@@ -274,7 +273,40 @@ static int create_header_files(struct errors *error_head)
274273
fprintf(sql_statef, "/* Autogenerated file, please don't edit */\n\n");
275274
fprintf(er_namef, "/* Autogenerated file, please don't edit */\n\n");
276275

277-
fprintf(er_definef, "#define ER_ERROR_FIRST %d\n", error_head->d_code);
276+
fprintf(er_definef, "#ifndef MYSQLD_ERROR_INCLUDED\n");
277+
fprintf(er_definef, "#define MYSQLD_ERROR_INCLUDED\n\n");
278+
279+
/*
280+
Find out how many sections of error messages we have, what the first
281+
number in each section is and the number of messages in each section.
282+
*/
283+
{
284+
int error_code= error_head->d_code;
285+
int section_size[100]; /* Assume that 100 sections is enough. */
286+
int current_section= 0;
287+
int section_nr;
288+
section_size[0]= 0;
289+
fprintf(er_definef,
290+
"static const int errmsg_section_start[] = { %d", error_code);
291+
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
292+
{
293+
if (tmp_error->d_code != error_code) /* Starting new section? */
294+
{
295+
fprintf(er_definef, ", %d", tmp_error->d_code);
296+
error_code= tmp_error->d_code;
297+
section_size[++current_section]= 0;
298+
}
299+
error_code++;
300+
section_size[current_section]++;
301+
}
302+
fprintf(er_definef, " };\n");
303+
304+
fprintf(er_definef,
305+
"static const int errmsg_section_size[] = { %d", section_size[0]);
306+
for (section_nr= 1; section_nr <= current_section; section_nr++)
307+
fprintf(er_definef, ", %d", section_size[section_nr]);
308+
fprintf(er_definef, " };\n\n");
309+
}
278310

279311
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
280312
{
@@ -284,7 +316,6 @@ static int create_header_files(struct errors *error_head)
284316
*/
285317
fprintf(er_definef, "#define %s %d\n", tmp_error->er_name,
286318
tmp_error->d_code);
287-
er_last= tmp_error->d_code;
288319

289320
/* generating sql_state.h file */
290321
if (tmp_error->sql_code1[0] || tmp_error->sql_code2[0])
@@ -300,7 +331,7 @@ static int create_header_files(struct errors *error_head)
300331
fprintf(er_namef, "\" },\n");
301332
}
302333
/* finishing off with mysqld_error.h */
303-
fprintf(er_definef, "#define ER_ERROR_LAST %d\n", er_last);
334+
fprintf(er_definef, "#endif\n");
304335
my_fclose(er_definef, MYF(0));
305336
my_fclose(sql_statef, MYF(0));
306337
my_fclose(er_namef, MYF(0));
@@ -454,7 +485,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
454485
char *str, buff[1000];
455486
struct errors *current_error= 0, **tail_error= top_error;
456487
struct message current_message;
457-
int rcount= 0;
488+
int rcount= 0; /* Number of error codes in current section. */
489+
int ecount= 0; /* Number of error codes in total. */
458490
DBUG_ENTER("parse_input_file");
459491

460492
*top_error= 0;
@@ -480,6 +512,7 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
480512
fprintf(stderr, "Failed to parse the error offset string!\n");
481513
DBUG_RETURN(0);
482514
}
515+
rcount= 0; /* Reset count if a fixed number is set. */
483516
continue;
484517
}
485518
if (is_prefix(str, "default-language"))
@@ -533,7 +566,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
533566
fprintf(stderr, "Failed to parse the error name string\n");
534567
DBUG_RETURN(0);
535568
}
536-
rcount++; /* Count number of unique errors */
569+
rcount++;
570+
ecount++; /* Count number of unique errors */
537571

538572
/* add error to the list */
539573
*tail_error= current_error;
@@ -549,7 +583,7 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
549583
*tail_error= 0; /* Mark end of list */
550584

551585
my_fclose(file, MYF(0));
552-
DBUG_RETURN(rcount);
586+
DBUG_RETURN(ecount);
553587
}
554588

555589

extra/perror.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -207,6 +207,13 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose)
207207
}
208208
#endif
209209

210+
211+
static const char *get_handler_error_message(int nr)
212+
{
213+
return handler_error_messages[nr - HA_ERR_FIRST];
214+
}
215+
216+
210217
/*
211218
Register handler error messages for usage with my_error()
212219
@@ -215,12 +222,7 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose)
215222
will ignore calls to register already registered error numbers.
216223
*/
217224

218-
static const char **get_handler_error_messages()
219-
{
220-
return handler_error_messages;
221-
}
222-
223-
void my_handler_error_register(void)
225+
void my_handler_error_register()
224226
{
225227
/*
226228
If you got compilation error here about compile_time_assert array, check
@@ -230,7 +232,7 @@ void my_handler_error_register(void)
230232
*/
231233
compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
232234
HA_ERR_LAST + 1);
233-
my_error_register(get_handler_error_messages, HA_ERR_FIRST,
235+
my_error_register(get_handler_error_message, HA_ERR_FIRST,
234236
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
235237
}
236238

include/my_sys.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,7 @@ extern HANDLE my_get_osfhandle(File fd);
587587
extern void my_osmaperr(unsigned long last_error);
588588
#endif
589589

590-
extern void init_glob_errs(void);
591-
extern const char** get_global_errmsgs();
590+
extern const char* get_global_errmsg(int nr);
592591
extern void wait_for_free_space(const char *filename, int errors);
593592
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
594593
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
@@ -609,9 +608,9 @@ extern void my_printf_error(uint my_err, const char *format,
609608
__attribute__((format(printf, 2, 4)));
610609
extern void my_printv_error(uint error, const char *format, myf MyFlags,
611610
va_list ap);
612-
extern int my_error_register(const char** (*get_errmsgs) (),
611+
extern int my_error_register(const char* (*get_errmsg) (int),
613612
int first, int last);
614-
extern const char **my_error_unregister(int first, int last);
613+
extern my_bool my_error_unregister(int first, int last);
615614
extern void my_message(uint my_err, const char *str,myf MyFlags);
616615
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
617616
void my_message_local_stderr(enum loglevel ll,

libmysql/errmsg.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -90,9 +90,9 @@ const char *client_errors[]=
9090
""
9191
};
9292

93-
const char** get_client_errmsgs()
93+
const char* get_client_errmsg(int nr)
9494
{
95-
return client_errors;
95+
return client_errors[nr - CR_ERROR_FIRST];
9696
}
9797

9898
/*
@@ -109,7 +109,7 @@ void init_client_errs(void)
109109
{
110110
compile_time_assert(array_elements(client_errors) ==
111111
(CR_ERROR_LAST - CR_ERROR_FIRST + 2));
112-
(void) my_error_register(get_client_errmsgs, CR_ERROR_FIRST, CR_ERROR_LAST);
112+
(void) my_error_register(get_client_errmsg, CR_ERROR_FIRST, CR_ERROR_LAST);
113113
}
114114

115115

mysql-test/r/events_bugs.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ drop procedure if exists p;
729729
set @old_mode= @@sql_mode;
730730
set @@sql_mode= cast(pow(2,32)-1 as unsigned integer);
731731
Warnings:
732-
Warning 1913 'ERROR_FOR_DIVISION_BY_ZERO' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
733-
Warning 1913 'NO_ZERO_DATE' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
734-
Warning 1913 'NO_ZERO_IN_DATE' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
732+
Warning 3027 'ERROR_FOR_DIVISION_BY_ZERO' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
733+
Warning 3027 'NO_ZERO_DATE' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
734+
Warning 3027 'NO_ZERO_IN_DATE' mode no longer has any effect. Use STRICT_ALL_TABLES or STRICT_TRANS_TABLES instead.
735735
create event e1 on schedule every 1 day do select 1;
736736
select @@sql_mode into @full_mode;
737737
set @@sql_mode= @old_mode;

mysql-test/r/func_math.result

+36-36
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log
5151
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
5252
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
5353
Warnings:
54-
Warning 1906 Invalid argument for logarithm
55-
Warning 1906 Invalid argument for logarithm
56-
Warning 1906 Invalid argument for logarithm
54+
Warning 3020 Invalid argument for logarithm
55+
Warning 3020 Invalid argument for logarithm
56+
Warning 3020 Invalid argument for logarithm
5757
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
5858
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
5959
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -64,8 +64,8 @@ select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
6464
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
6565
10 10.000000000000002 NULL NULL NULL
6666
Warnings:
67-
Warning 1906 Invalid argument for logarithm
68-
Warning 1906 Invalid argument for logarithm
67+
Warning 3020 Invalid argument for logarithm
68+
Warning 3020 Invalid argument for logarithm
6969
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
7070
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
7171
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -76,8 +76,8 @@ select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
7676
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
7777
3 3.9068905956085187 NULL NULL NULL
7878
Warnings:
79-
Warning 1906 Invalid argument for logarithm
80-
Warning 1906 Invalid argument for logarithm
79+
Warning 3020 Invalid argument for logarithm
80+
Warning 3020 Invalid argument for logarithm
8181
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
8282
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
8383
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -88,8 +88,8 @@ select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
8888
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
8989
2 1.255272505103306 NULL NULL NULL
9090
Warnings:
91-
Warning 1906 Invalid argument for logarithm
92-
Warning 1906 Invalid argument for logarithm
91+
Warning 3020 Invalid argument for logarithm
92+
Warning 3020 Invalid argument for logarithm
9393
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
9494
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
9595
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -255,27 +255,27 @@ select ln(-1);
255255
ln(-1)
256256
NULL
257257
Warnings:
258-
Warning 1906 Invalid argument for logarithm
258+
Warning 3020 Invalid argument for logarithm
259259
select log10(-1);
260260
log10(-1)
261261
NULL
262262
Warnings:
263-
Warning 1906 Invalid argument for logarithm
263+
Warning 3020 Invalid argument for logarithm
264264
select log2(-1);
265265
log2(-1)
266266
NULL
267267
Warnings:
268-
Warning 1906 Invalid argument for logarithm
268+
Warning 3020 Invalid argument for logarithm
269269
select log(2,-1);
270270
log(2,-1)
271271
NULL
272272
Warnings:
273-
Warning 1906 Invalid argument for logarithm
273+
Warning 3020 Invalid argument for logarithm
274274
select log(-2,1);
275275
log(-2,1)
276276
NULL
277277
Warnings:
278-
Warning 1906 Invalid argument for logarithm
278+
Warning 3020 Invalid argument for logarithm
279279
set sql_mode='';
280280
select round(111,-10);
281281
round(111,-10)
@@ -791,22 +791,22 @@ SET sql_mode='';
791791
INSERT INTO t1 VALUES (ln(1));
792792
INSERT INTO t1 VALUES (ln(0));
793793
Warnings:
794-
Warning 1906 Invalid argument for logarithm
794+
Warning 3020 Invalid argument for logarithm
795795
INSERT INTO t1 VALUES (ln(-1));
796796
Warnings:
797-
Warning 1906 Invalid argument for logarithm
797+
Warning 3020 Invalid argument for logarithm
798798
INSERT INTO t1 VALUES (log(0));
799799
Warnings:
800-
Warning 1906 Invalid argument for logarithm
800+
Warning 3020 Invalid argument for logarithm
801801
INSERT INTO t1 VALUES (log(1,0));
802802
Warnings:
803-
Warning 1906 Invalid argument for logarithm
803+
Warning 3020 Invalid argument for logarithm
804804
INSERT INTO t1 VALUES (log2(0));
805805
Warnings:
806-
Warning 1906 Invalid argument for logarithm
806+
Warning 3020 Invalid argument for logarithm
807807
INSERT INTO t1 VALUES (log10(0));
808808
Warnings:
809-
Warning 1906 Invalid argument for logarithm
809+
Warning 3020 Invalid argument for logarithm
810810
SELECT * FROM t1 ORDER BY a;
811811
a
812812
NULL
@@ -856,14 +856,14 @@ NULL
856856
SET sql_mode='';
857857
UPDATE t1 SET a = ln(0);
858858
Warnings:
859-
Warning 1906 Invalid argument for logarithm
860-
Warning 1906 Invalid argument for logarithm
861-
Warning 1906 Invalid argument for logarithm
862-
Warning 1906 Invalid argument for logarithm
863-
Warning 1906 Invalid argument for logarithm
864-
Warning 1906 Invalid argument for logarithm
865-
Warning 1906 Invalid argument for logarithm
866-
Warning 1906 Invalid argument for logarithm
859+
Warning 3020 Invalid argument for logarithm
860+
Warning 3020 Invalid argument for logarithm
861+
Warning 3020 Invalid argument for logarithm
862+
Warning 3020 Invalid argument for logarithm
863+
Warning 3020 Invalid argument for logarithm
864+
Warning 3020 Invalid argument for logarithm
865+
Warning 3020 Invalid argument for logarithm
866+
Warning 3020 Invalid argument for logarithm
867867
SELECT * FROM t1 ORDER BY a;
868868
a
869869
NULL
@@ -890,14 +890,14 @@ NULL
890890
SET sql_mode='';
891891
DELETE FROM t1 WHERE a <=> ln(0);
892892
Warnings:
893-
Warning 1906 Invalid argument for logarithm
894-
Warning 1906 Invalid argument for logarithm
895-
Warning 1906 Invalid argument for logarithm
896-
Warning 1906 Invalid argument for logarithm
897-
Warning 1906 Invalid argument for logarithm
898-
Warning 1906 Invalid argument for logarithm
899-
Warning 1906 Invalid argument for logarithm
900-
Warning 1906 Invalid argument for logarithm
893+
Warning 3020 Invalid argument for logarithm
894+
Warning 3020 Invalid argument for logarithm
895+
Warning 3020 Invalid argument for logarithm
896+
Warning 3020 Invalid argument for logarithm
897+
Warning 3020 Invalid argument for logarithm
898+
Warning 3020 Invalid argument for logarithm
899+
Warning 3020 Invalid argument for logarithm
900+
Warning 3020 Invalid argument for logarithm
901901
SELECT * FROM t1 ORDER BY a;
902902
a
903903
DROP TABLE t1;

mysql-test/r/func_str.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ sha1('P'),
30263026
)
30273027
);
30283028
Warnings:
3029-
Error 1923 Invalid GIS data provided to function st_geometryfromwkb.
3029+
Error 3037 Invalid GIS data provided to function st_geometryfromwkb.
30303030
Warning 1292 Truncated incorrect DECIMAL value: '[.DC2.]'
30313031
SET @@global.max_allowed_packet:= @tmp_max;
30323032
#

mysql-test/r/func_time.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ DROP TABLE t1;
18191819
#
18201820
DO contains(1, if(0, coalesce(NULL), now()));
18211821
Warnings:
1822-
Error 1923 Invalid GIS data provided to function mbrcontains.
1822+
Error 3037 Invalid GIS data provided to function mbrcontains.
18231823
CREATE TABLE t1 AS SELECT IF(0, coalesce(NULL), now(0)) + 0;
18241824
SHOW CREATE TABLE t1;
18251825
Table Create Table

0 commit comments

Comments
 (0)