mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
This commit is contained in:
@ -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;
|
|||||||
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;
|
|||||||
--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 #
|
||||||
|
Reference in New Issue
Block a user