Commit 2c6a5fd2 authored by unknown's avatar unknown

Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names

db name should be quoted. this code does communication with the server.
it's always ok to quote names in this case.


client/mysqldump.c:
  db name should be quoted. this code does communication with the server.
  it's always ok to quote names in this case.
mysql-test/r/mysqldump.result:
  test result
mysql-test/t/mysqldump.test:
  test case
parent 61bd5d0f
...@@ -1040,8 +1040,10 @@ static int fetch_db_collation(const char *db_name, ...@@ -1040,8 +1040,10 @@ static int fetch_db_collation(const char *db_name,
char query[QUERY_LENGTH]; char query[QUERY_LENGTH];
MYSQL_RES *db_cl_res; MYSQL_RES *db_cl_res;
MYSQL_ROW db_cl_row; 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", db_name); my_snprintf(query, sizeof (query), "use %s", qdatabase);
if (mysql_query_with_error_report(mysql, NULL, query)) if (mysql_query_with_error_report(mysql, NULL, query))
return 1; return 1;
......
...@@ -4212,5 +4212,24 @@ TRUNCATE mysql.event; ...@@ -4212,5 +4212,24 @@ TRUNCATE mysql.event;
SHOW EVENTS; SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
# #
# Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
#
create database `test-database`;
use `test-database`;
create table test (a int);
DROP TABLE IF EXISTS `test`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `test` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
LOCK TABLES `test` WRITE;
/*!40000 ALTER TABLE `test` DISABLE KEYS */;
/*!40000 ALTER TABLE `test` ENABLE KEYS */;
UNLOCK TABLES;
drop database `test-database`;
use test;
#
# End of 5.1 tests # End of 5.1 tests
# #
...@@ -1788,6 +1788,18 @@ TRUNCATE mysql.event; ...@@ -1788,6 +1788,18 @@ TRUNCATE mysql.event;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql
SHOW EVENTS; SHOW EVENTS;
--echo #
--echo # Bug#31113 mysqldump 5.1 can't handle a dash ("-") in database names
--echo #
create database `test-database`;
use `test-database`;
create table test (a int);
--exec $MYSQL_DUMP --compact --opt --quote-names test-database
drop database `test-database`;
use test;
--echo # --echo #
--echo # End of 5.1 tests --echo # End of 5.1 tests
--echo # --echo #
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment