summaryrefslogtreecommitdiff
path: root/extra/comp_err.c
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-05-21 00:46:18 +0300
committerMichael Widenius <monty@askmonty.org>2011-05-21 00:46:18 +0300
commitf610296d98917908d49dc70d5075ea02ff68243d (patch)
treeaa77d24c55137d119bfde333df875e52fe4a589b /extra/comp_err.c
parentbe6d6e1b3eb0d243dfa9f1d0de108069df5774e4 (diff)
downloadmariadb-git-f610296d98917908d49dc70d5075ea02ff68243d.tar.gz
Changed MariaDB error numbers to start from 1900 to not conflict with MySQL error numbers
extra/comp_err.c: Allow one to have multiple start-error-numbers in the same error.txt file. Generate 'empty' error strings for the missing error numbers in the errmsg.sys file mysql-test/r/bigint.result: Update results to use new error numbers mysql-test/r/dyncol.result: Update results to use new error numbers mysql-test/r/func_math.result: Update results to use new error numbers mysql-test/r/func_str.result: Update results to use new error numbers mysql-test/r/plugin.result: Update results to use new error numbers mysql-test/r/table_options.result: Update results to use new error numbers mysql-test/r/type_newdecimal.result: Update results to use new error numbers mysql-test/r/warnings.result: Update results to use new error numbers mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result: Update results to use new error numbers mysql-test/suite/vcol/r/vcol_ins_upd_myisam.result: Update results to use new error numbers mysql-test/suite/vcol/r/vcol_misc.result: Update results to use new error numbers sql/derror.cc: Ensure we don't read a errmsg.sys with a missing required error message; This change was needed as errmsg.sys may now contain empty error messages between the MySQL and MariaDB error messages. If error message file didn't exist and we have not read one in the past, don't continue. Give better error message if the errmsg.sys header has changed. sql/share/errmsg.txt: Create new section, starting from 1900, for MariaDB error messages
Diffstat (limited to 'extra/comp_err.c')
-rw-r--r--extra/comp_err.c84
1 files changed, 73 insertions, 11 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c
index adce6a6f5bd..11c36bb7f85 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -34,6 +34,7 @@
#define HEADER_LENGTH 32 /* Length of header in errmsg.sys */
#define DEFAULT_CHARSET_DIR "../sql/share/charsets"
#define ER_PREFIX "ER_"
+#define ER_PREFIX2 "MARIA_ER_"
#define WARN_PREFIX "WARN_"
static char *OUTFILE= (char*) "errmsg.sys";
static char *HEADERFILE= (char*) "mysqld_error.h";
@@ -57,7 +58,7 @@ const char *empty_string= ""; /* For empty states */
*/
const char *default_language= "eng";
-int er_offset= 1000;
+uint er_offset= 1000;
my_bool info_flag= 0;
/* Storage of one error message row (for one language) */
@@ -85,7 +86,7 @@ struct languages
struct errors
{
const char *er_name; /* Name of the error (ER_HASHCK) */
- int d_code; /* Error code number */
+ uint d_code; /* Error code number */
const char *sql_code1; /* sql state */
const char *sql_code2; /* ODBC state */
struct errors *next_error; /* Pointer to next error */
@@ -127,6 +128,7 @@ static struct my_option my_long_options[]=
};
+static struct errors *generate_empty_message(uint dcode);
static struct languages *parse_charset_string(char *str);
static struct errors *parse_error_string(char *ptr, int er_count);
static struct message *parse_message_string(struct message *new_message,
@@ -203,6 +205,7 @@ static int create_header_files(struct errors *error_head)
uint er_last;
FILE *er_definef, *sql_statef, *er_namef;
struct errors *tmp_error;
+ uint current_d_code;
DBUG_ENTER("create_header_files");
LINT_INIT(er_last);
@@ -228,13 +231,22 @@ static int create_header_files(struct errors *error_head)
fprintf(er_definef, "#define ER_ERROR_FIRST %d\n", error_head->d_code);
+ current_d_code= error_head->d_code -1;
for (tmp_error= error_head; tmp_error; tmp_error= tmp_error->next_error)
{
/*
generating mysqld_error.h
fprintf() will automatically add \r on windows
*/
- fprintf(er_definef, "#define %s %d\n", tmp_error->er_name,
+
+ if (!tmp_error->er_name)
+ continue; /* Placeholder for gap */
+
+ if (tmp_error->d_code > current_d_code + 1)
+ fprintf(er_definef, "\n/* New section */\n\n");
+ current_d_code= tmp_error->d_code;
+
+ fprintf(er_definef, "#define %s %u\n", tmp_error->er_name,
tmp_error->d_code);
er_last= tmp_error->d_code;
@@ -403,7 +415,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
char *str, buff[1000];
struct errors *current_error= 0, **tail_error= top_error;
struct message current_message;
- int rcount= 0;
+ uint rcount= 0;
+ my_bool er_offset_found= 0;
DBUG_ENTER("parse_input_file");
*top_error= 0;
@@ -424,11 +437,32 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
}
if (is_prefix(str, "start-error-number"))
{
- if (!(er_offset= parse_error_offset(str)))
+ uint tmp_er_offset;
+ if (!(tmp_er_offset= parse_error_offset(str)))
{
fprintf(stderr, "Failed to parse the error offset string!\n");
DBUG_RETURN(0);
}
+ if (!er_offset_found)
+ {
+ er_offset_found= 1;
+ er_offset= tmp_er_offset;
+ }
+ else
+ {
+ /* Create empty error messages between er_offset and tmp_err_offset */
+ if (tmp_er_offset < er_offset + rcount)
+ {
+ fprintf(stderr, "new start-error-number %u is smaller than current error message: %u\n", tmp_er_offset, er_offset + rcount);
+ DBUG_RETURN(0);
+ }
+ for ( ; er_offset + rcount < tmp_er_offset ; rcount++)
+ {
+ current_error= generate_empty_message(er_offset + rcount);
+ *tail_error= current_error;
+ tail_error= &current_error->next_error;
+ }
+ }
continue;
}
if (is_prefix(str, "default-language"))
@@ -475,7 +509,8 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
DBUG_RETURN(0);
continue;
}
- if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX))
+ if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX) ||
+ is_prefix(str, ER_PREFIX2))
{
if (!(current_error= parse_error_string(str, rcount)))
{
@@ -490,12 +525,12 @@ static int parse_input_file(const char *file_name, struct errors **top_error,
continue;
}
if (*str == '#' || *str == '\n')
- continue; /* skip comment or empty lines */
+ continue; /* skip comment or empty lines */
fprintf(stderr, "Wrong input file format. Stop!\nLine: %s\n", str);
DBUG_RETURN(0);
}
- *tail_error= 0; /* Mark end of list */
+ *tail_error= 0; /* Mark end of list */
my_fclose(file, MYF(0));
DBUG_RETURN(rcount);
@@ -604,7 +639,6 @@ static struct message *find_message(struct errors *err, const char *lang,
DBUG_RETURN(tmp);
if (!strcmp(tmp->lang_short_name, default_language))
{
- DBUG_ASSERT(tmp->text[0] != 0);
return_val= tmp;
}
}
@@ -824,6 +858,32 @@ static struct message *parse_message_string(struct message *new_message,
}
+static struct errors *generate_empty_message(uint d_code)
+{
+ struct errors *new_error;
+ struct message message;
+
+ /* create a new element */
+ if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
+ MYF(MY_WME))))
+ return(0);
+ if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 1))
+ return(0); /* OOM: Fatal error */
+
+ new_error->d_code= d_code;
+ new_error->sql_code1= empty_string;
+ new_error->sql_code2= empty_string;
+
+ if (!(message.lang_short_name= my_strdup(default_language, MYF(MY_WME))) ||
+ !(message.text= my_strdup("", MYF(MY_WME))))
+ return(0);
+
+ /* Can't fail as msg is preallocated */
+ (void) insert_dynamic(&new_error->msg, (uchar*) &message);
+ return(new_error);
+}
+
+
/*
Parsing the string with error name and codes; returns the pointer to
the errors struct
@@ -836,7 +896,9 @@ static struct errors *parse_error_string(char *str, int er_count)
DBUG_PRINT("enter", ("str: %s", str));
/* create a new element */
- new_error= (struct errors *) my_malloc(sizeof(*new_error), MYF(MY_WME));
+ if (!(new_error= (struct errors *) my_malloc(sizeof(*new_error),
+ MYF(MY_WME))))
+ DBUG_RETURN(0);
if (my_init_dynamic_array(&new_error->msg, sizeof(struct message), 0, 0))
DBUG_RETURN(0); /* OOM: Fatal error */
@@ -966,7 +1028,7 @@ static struct languages *parse_charset_string(char *str)
static void print_version(void)
{
DBUG_ENTER("print_version");
- printf("%s (Compile errormessage) Ver %s\n", my_progname, "2.0");
+ printf("%s (Compile errormessage) Ver %s\n", my_progname, "3.0");
DBUG_VOID_RETURN;
}