extra correction of check_db_name, check_table_name and check_column_name

parent 29bc7b03
...@@ -1140,7 +1140,7 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr) ...@@ -1140,7 +1140,7 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr)
bool check_db_name(char *name) bool check_db_name(char *name)
{ {
char *start=name; char *start=name;
bool space= false; bool last_char_is_space= FALSE;
if (lower_case_table_names) if (lower_case_table_names)
casedn_str(name); casedn_str(name);
...@@ -1148,7 +1148,7 @@ bool check_db_name(char *name) ...@@ -1148,7 +1148,7 @@ bool check_db_name(char *name)
while (*name) while (*name)
{ {
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
space= my_isspace(default_charset_info, *name); last_char_is_space= my_isspace(default_charset_info, *name);
if (use_mb(default_charset_info)) if (use_mb(default_charset_info))
{ {
int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN); int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
...@@ -1159,16 +1159,14 @@ bool check_db_name(char *name) ...@@ -1159,16 +1159,14 @@ bool check_db_name(char *name)
} }
} }
#else #else
space= *name==' '; last_char_is_space= *name==' ';
#endif #endif
if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR || if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR ||
*name == FN_EXTCHAR) *name == FN_EXTCHAR)
return 1; return 1;
name++; name++;
} }
if (space) return last_char_is_space || (uint) (name - start) > NAME_LEN;
return 1;
return name[-1]==' ' || (uint) (name - start) > NAME_LEN;
} }
...@@ -1186,7 +1184,7 @@ bool check_table_name(const char *name, uint length) ...@@ -1186,7 +1184,7 @@ bool check_table_name(const char *name, uint length)
if (!length || length > NAME_LEN) if (!length || length > NAME_LEN)
return 1; return 1;
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
bool space= false; bool last_char_is_space= FALSE;
#else #else
if (name[length-1]==' ') if (name[length-1]==' ')
return 1; return 1;
...@@ -1195,7 +1193,7 @@ bool check_table_name(const char *name, uint length) ...@@ -1195,7 +1193,7 @@ bool check_table_name(const char *name, uint length)
while (name != end) while (name != end)
{ {
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
space= my_isspace(default_charset_info, *name); last_char_is_space= my_isspace(default_charset_info, *name);
if (use_mb(default_charset_info)) if (use_mb(default_charset_info))
{ {
int len=my_ismbchar(default_charset_info, name, end); int len=my_ismbchar(default_charset_info, name, end);
...@@ -1211,21 +1209,21 @@ bool check_table_name(const char *name, uint length) ...@@ -1211,21 +1209,21 @@ bool check_table_name(const char *name, uint length)
name++; name++;
} }
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
if (space) return last_char_is_space;
return 1; #else
#endif
return 0; return 0;
#endif
} }
bool check_column_name(const char *name) bool check_column_name(const char *name)
{ {
const char *start= name; const char *start= name;
bool space= false; bool last_char_is_space= false;
while (*name) while (*name)
{ {
#if defined(USE_MB) && defined(USE_MB_IDENT) #if defined(USE_MB) && defined(USE_MB_IDENT)
space= my_isspace(default_charset_info, *name); last_char_is_space= my_isspace(default_charset_info, *name);
if (use_mb(default_charset_info)) if (use_mb(default_charset_info))
{ {
int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN); int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
...@@ -1236,16 +1234,14 @@ bool check_column_name(const char *name) ...@@ -1236,16 +1234,14 @@ bool check_column_name(const char *name)
} }
} }
#else #else
space= *name==' '; last_char_is_space= *name==' ';
#endif #endif
if (*name == NAMES_SEP_CHAR) if (*name == NAMES_SEP_CHAR)
return 1; return 1;
name++; name++;
} }
if (space)
return 1;
/* Error if empty or too long column name */ /* Error if empty or too long column name */
return (name == start || (uint) (name - start) > NAME_LEN); return last_char_is_space || (name == start || (uint) (name - start) > NAME_LEN);
} }
/* /*
......
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