Two implementations of "get_err_code_from_name", one use if mysqld_ername.h is...

Two implementations of "get_err_code_from_name", one use if mysqld_ername.h is available and oe if it's not
Declare "to_ptr" first in block 
parent 7ba18803
...@@ -2472,17 +2472,13 @@ static st_error global_error_names[] = ...@@ -2472,17 +2472,13 @@ static st_error global_error_names[] =
#include <mysqld_ername.h> #include <mysqld_ername.h>
{ 0, 0 } { 0, 0 }
}; };
#define HAVE_MYSQLD_ERNAME
#endif
uint get_errcode_from_name(char *error_name, char *error_end) uint get_errcode_from_name(char *error_name, char *error_end)
{ {
DBUG_ENTER("get_errcode_from_name");
#ifdef HAVE_MYSQLD_ERNAME
/* SQL error as string */ /* SQL error as string */
st_error *e= global_error_names; st_error *e= global_error_names;
DBUG_ENTER("get_errcode_from_name");
DBUG_PRINT("enter", ("error_name: %s", error_name)); DBUG_PRINT("enter", ("error_name: %s", error_name));
/* Loop through the array of known error names */ /* Loop through the array of known error names */
...@@ -2501,13 +2497,17 @@ uint get_errcode_from_name(char *error_name, char *error_end) ...@@ -2501,13 +2497,17 @@ uint get_errcode_from_name(char *error_name, char *error_end)
} }
if (!e->name) if (!e->name)
die("Unknown SQL error name '%s'", error_name); die("Unknown SQL error name '%s'", error_name);
DBUG_RETURN(0);
}
#else #else
LINT_INIT(error_name); uint get_errcode_from_name(char *error_name __attribute__((unused)),
LINT_INIT(error_end); char *error_end __attribute__((unused)))
{
abort_not_in_this_version(); abort_not_in_this_version();
#endif return 0; /* Never reached */
DBUG_RETURN(0);;
} }
#endif
void do_get_errcodes(struct st_command *command) void do_get_errcodes(struct st_command *command)
...@@ -2536,6 +2536,8 @@ void do_get_errcodes(struct st_command *command) ...@@ -2536,6 +2536,8 @@ void do_get_errcodes(struct st_command *command)
if (*p == 'S') if (*p == 'S')
{ {
char *to_ptr= to->code.sqlstate;
/* /*
SQLSTATE string SQLSTATE string
- Must be SQLSTATE_LENGTH long - Must be SQLSTATE_LENGTH long
...@@ -2546,7 +2548,6 @@ void do_get_errcodes(struct st_command *command) ...@@ -2546,7 +2548,6 @@ void do_get_errcodes(struct st_command *command)
die("The sqlstate must be exactly %d chars long", SQLSTATE_LENGTH); die("The sqlstate must be exactly %d chars long", SQLSTATE_LENGTH);
/* Check sqlstate string validity */ /* Check sqlstate string validity */
char *to_ptr= to->code.sqlstate;
while (*p && p != end) while (*p && p != end)
{ {
if (my_isdigit(charset_info, *p) || my_isupper(charset_info, *p)) if (my_isdigit(charset_info, *p) || my_isupper(charset_info, *p))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment