1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#11766310 : 59398: MYSQLDUMP 5.1 CAN'T HANDLE A DASH

("-") IN DATABASE NAMES IN ALTER DATABASE.

mysqldump did not quote database name in 'ALTER DATABASE'
statements in its output. This can further cause a failure
while loading if database name contains a hyphen '-'.

This happened as, while printing the 'ALTER DATABASE'
statements, the database name was not quoted.

Fixed by quoting the database name.
This commit is contained in:
Nirbhay Choubey
2011-02-21 12:37:24 +05:30
parent cd3a8131c6
commit a8e6f7c67b
3 changed files with 65 additions and 2 deletions

View File

@ -1134,6 +1134,9 @@ static int switch_db_collation(FILE *sql_file,
{
if (strcmp(current_db_cl_name, required_db_cl_name) != 0)
{
char quoted_db_buf[NAME_LEN * 2 + 3];
char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
CHARSET_INFO *db_cl= get_charset_by_name(required_db_cl_name, MYF(0));
if (!db_cl)
@ -1141,7 +1144,7 @@ static int switch_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
(const char *) db_name,
(const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);
@ -1162,6 +1165,9 @@ static int restore_db_collation(FILE *sql_file,
const char *delimiter,
const char *db_cl_name)
{
char quoted_db_buf[NAME_LEN * 2 + 3];
char *quoted_db_name= quote_name(db_name, quoted_db_buf, FALSE);
CHARSET_INFO *db_cl= get_charset_by_name(db_cl_name, MYF(0));
if (!db_cl)
@ -1169,7 +1175,7 @@ static int restore_db_collation(FILE *sql_file,
fprintf(sql_file,
"ALTER DATABASE %s CHARACTER SET %s COLLATE %s %s\n",
(const char *) db_name,
(const char *) quoted_db_name,
(const char *) db_cl->csname,
(const char *) db_cl->name,
(const char *) delimiter);