mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
bug#17870 Table names conflict with Windows device names
It was impossible to create some table names on Windows (e.g. LPT1, AUX, COM1, etc). Fixed to pad dangerous names with thee "at" signs (e.g. LPT1@@@, AUX@@@, COM1@@@, and so on). include/my_sys.h: Adding new function declaration mysys/my_access.c: Adding new function check_if_legal_tablename(). It works almost like check_if_legal_filename(), but accepts a table name without extension and path, and does not check "CLOCK$". sql/sql_table.cc: Check if a dangerous table name and append @@@ strings/ctype-utf8.c: Treat "@@@" sequence in a table name as a end-of-line. mysql-test/r/ctype_filename.result: New BitKeeper file ``mysql-test/r/ctype_filename.result'' mysql-test/t/ctype_filename.test: New BitKeeper file ``mysql-test/t/ctype_filename.test''
This commit is contained in:
@ -72,12 +72,19 @@ uint filename_to_tablename(const char *from, char *to, uint to_length)
|
||||
|
||||
uint tablename_to_filename(const char *from, char *to, uint to_length)
|
||||
{
|
||||
uint errors;
|
||||
uint errors, length;
|
||||
if (from[0] == '#' && !strncmp(from, MYSQL50_TABLE_NAME_PREFIX,
|
||||
MYSQL50_TABLE_NAME_PREFIX_LENGTH))
|
||||
return my_snprintf(to, to_length, "%s", from + 9);
|
||||
return strconvert(system_charset_info, from,
|
||||
&my_charset_filename, to, to_length, &errors);
|
||||
length= strconvert(system_charset_info, from,
|
||||
&my_charset_filename, to, to_length, &errors);
|
||||
if (check_if_legal_tablename(to) &&
|
||||
length + 4 < to_length)
|
||||
{
|
||||
memcpy(to + length, "@@@", 4);
|
||||
length+= 3;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user