diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sql/table.cc b/sql/table.cc index 4123473cf1e..d1c9836d15c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2329,8 +2329,9 @@ uint calculate_key_len(TABLE *table, uint key, const byte *buf, bool check_db_name(LEX_STRING *org_name) { char *name= org_name->str; + uint name_length= org_name->length; - if (!org_name->length || org_name->length > NAME_LEN) + if (!name_length || name_length > NAME_LEN) return 1; if (lower_case_table_names && name != any_db) @@ -2339,6 +2340,7 @@ bool check_db_name(LEX_STRING *org_name) #if defined(USE_MB) && defined(USE_MB_IDENT) if (use_mb(system_charset_info)) { + name_length= 0; bool last_char_is_space= TRUE; char *end= name + org_name->length; while (name < end) @@ -2349,12 +2351,14 @@ bool check_db_name(LEX_STRING *org_name) if (!len) len= 1; name+= len; + name_length++; } - return last_char_is_space; + return (last_char_is_space || name_length > NAME_CHAR_LEN); } else #endif - return org_name->str[org_name->length - 1] != ' '; /* purecov: inspected */ + return ((org_name->str[org_name->length - 1] != ' ') || + (name_length > NAME_CHAR_LEN)); /* purecov: inspected */ } @@ -2367,6 +2371,7 @@ bool check_db_name(LEX_STRING *org_name) bool check_table_name(const char *name, uint length) { + uint name_length= 0; // name length in symbols const char *end= name+length; if (!length || length > NAME_LEN) return 1; @@ -2387,14 +2392,16 @@ bool check_table_name(const char *name, uint length) if (len) { name += len; + name_length++; continue; } } #endif name++; + name_length++; } #if defined(USE_MB) && defined(USE_MB_IDENT) - return last_char_is_space; + return (last_char_is_space || name_length > NAME_CHAR_LEN) ; #else return 0; #endif @@ -2403,7 +2410,7 @@ bool check_table_name(const char *name, uint length) bool check_column_name(const char *name) { - const char *start= name; + uint name_length= 0; // name length in symbols bool last_char_is_space= TRUE; while (*name) @@ -2417,6 +2424,7 @@ bool check_column_name(const char *name) if (len) { name += len; + name_length++; continue; } } @@ -2426,9 +2434,10 @@ bool check_column_name(const char *name) if (*name == NAMES_SEP_CHAR) return 1; name++; + name_length++; } /* Error if empty or too long column name */ - return last_char_is_space || (uint) (name - start) > NAME_LEN; + return last_char_is_space || (uint) name_length > NAME_CHAR_LEN; } |