diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-12-02 16:08:54 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-12-03 16:33:50 +0400 |
commit | 9f07c6b383d776d430510de1256b3e4e8680bc60 (patch) | |
tree | 8cccbf3cc4a008696e639fd450a8896f888e53c5 /client | |
parent | 33589b25efe3283b748e43a54c42db2ed176c3e5 (diff) | |
download | mariadb-git-9f07c6b383d776d430510de1256b3e4e8680bc60.tar.gz |
MDEV-9001 - [PATCH] Fix DB name quoting in mysqldump --routine
mysqldump --routine fails to dump databases containing backslash ("\")
character. This happened because escaped database name was being used as an
identifier while changing current database. Such identifers are not supposed
to be escaped, they must be properly quoted instead.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqldump.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index b649e638bc3..cfd38e019ba 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1119,13 +1119,12 @@ static int fetch_db_collation(const char *db_name, char query[QUERY_LENGTH]; MYSQL_RES *db_cl_res; MYSQL_ROW db_cl_row; - char quoted_database_buf[NAME_LEN*2+3]; - char *qdatabase= quote_name(db_name, quoted_database_buf, 1); - my_snprintf(query, sizeof (query), "use %s", qdatabase); - - if (mysql_query_with_error_report(mysql, NULL, query)) - return 1; + if (mysql_select_db(mysql, db_name)) + { + DB_error(mysql, "when selecting the database"); + return 1; /* If --force */ + } if (mysql_query_with_error_report(mysql, &db_cl_res, "select @@collation_database")) @@ -2319,7 +2318,7 @@ static uint dump_routines_for_db(char *db) /* Get database collation. */ - if (fetch_db_collation(db_name_buff, db_cl_name, sizeof (db_cl_name))) + if (fetch_db_collation(db, db_cl_name, sizeof (db_cl_name))) DBUG_RETURN(1); if (switch_character_set_results(mysql, "binary")) @@ -2388,7 +2387,7 @@ static uint dump_routines_for_db(char *db) if (mysql_num_fields(routine_res) >= 6) { - if (switch_db_collation(sql_file, db_name_buff, ";", + if (switch_db_collation(sql_file, db, ";", db_cl_name, row[5], &db_cl_altered)) { DBUG_RETURN(1); @@ -2435,7 +2434,7 @@ static uint dump_routines_for_db(char *db) if (db_cl_altered) { - if (restore_db_collation(sql_file, db_name_buff, ";", db_cl_name)) + if (restore_db_collation(sql_file, db, ";", db_cl_name)) DBUG_RETURN(1); } } |