1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte

client/mysqldump.c:
  fixed typo
include/mysql_com.h:
  added new constants SYSTEM_CHARSET_MBMAXLEN, NAME_CHAR_LEN, USERNAME_CHAR_LENGTH
  increased NAME_LEN, USERNAME_LENGTH
mysql-test/r/create.result:
  result fix
mysql-test/r/grant.result:
  result fix
mysql-test/r/mysql.result:
  result fix
mysql-test/r/sp.result:
  result fix
mysql-test/t/create.test:
  test case
mysql-test/t/grant.test:
  test case
sql/events.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/item_strfunc.h:
  fixed calculation of max_length
sql/mysql_priv.h:
  check_string_length function is replaced with check_string_byte_length
  added new function check_string_char_length
sql/sp.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sp_head.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sp_head.h:
  changed parameter of 'check_routine_name' function
sql/sql_class.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/share/errmsg.txt:
  increased argument lengths according to new constants
sql/sql_parse.cc:
  removed unnecessary checks
  added function 'check_string_char_length'
sql/sql_plugin.cc:
  check that name is not longer than NAME_CHAR_LEN symbols
sql/sql_show.cc:
  NAME_LEN is replaced with NAME_CHAR_LEN
sql/sql_table.cc:
  check that key name is not longer than NAME_LEN symbols
sql/sql_udf.cc:
  check that udf name is not longer than NAME_CHAR_LEN symbols
sql/sql_yacc.yy:
  check that user name is not longer than USERNAME_CHAR_LENGTH symbols
sql/table.cc:
  check that db or table or column name is not longer than NAME_LEN symbols
storage/innobase/handler/ha_innodb.cc:
  removed unnecessary multiplication
tests/mysql_client_test.c:
  NAME_LEN is replaced with NAME_CHAR_LEN
This commit is contained in:
unknown
2007-04-03 16:13:27 +05:00
parent 6e5ca12b6a
commit fe074a726f
25 changed files with 2255 additions and 1997 deletions

View File

@@ -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;
}