Skip to content

Commit d09358d

Browse files
author
Bharathy Satish
committed
Bug #22505474 MYSQLPUMP FAILS WHEN IS DUMPING ALL DATABASES
Problem: When views are named with a space character there is a syntax error when dumping view. Fix: Fixed by quoting the view names.
1 parent 5554fd9 commit d09358d

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

client/dump/mysql_crawler.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -238,8 +238,9 @@ void Mysql_crawler::enumerate_views(const Database& db)
238238
if (is_view[0] == "1")
239239
{
240240
/* Check if view dependent objects exists */
241-
if (runner->run_query(std::string("LOCK TABLES ") + db.get_name()
242-
+ "." + table_name + " READ") != 0)
241+
if (runner->run_query(std::string("LOCK TABLES ")
242+
+ this->get_quoted_object_full_name(db.get_name(), table_name)
243+
+ " READ") != 0)
243244
return;
244245
else
245246
runner->run_query(std::string("UNLOCK TABLES"));

mysql-test/r/mysqlpump_basic.result

+23
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,26 @@ sum pk a c
551551
2014 2003-01-02 10:30:00 11 12
552552
2036 2015-11-22 00:30:00 21 22
553553
DROP DATABASE bug21650559;
554+
CREATE DATABASE bug22505474;
555+
USE bug22505474;
556+
CREATE TABLE t1 (a INT);
557+
INSERT INTO t1 VALUES (1),(2),(3);
558+
CREATE VIEW `v 1` AS SELECT * FROM t1;
559+
SELECT * FROM `v 1`;
560+
a
561+
1
562+
2
563+
3
564+
DROP DATABASE bug22505474;
565+
USE bug22505474;
566+
SELECT * FROM t1;
567+
a
568+
1
569+
2
570+
3
571+
SELECT * FROM `v 1`;
572+
a
573+
1
574+
2
575+
3
576+
DROP DATABASE bug22505474;

mysql-test/t/mysqlpump_basic.test

+19
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,22 @@ SELECT * FROM t1;
477477
SELECT * FROM t2;
478478
SELECT * FROM t3;
479479
DROP DATABASE bug21650559;
480+
481+
#echo
482+
#echo Bug #22505474 MYSQLPUMP FAILS WHEN IS DUMPING ALL DATABASES
483+
#echo
484+
485+
CREATE DATABASE bug22505474;
486+
USE bug22505474;
487+
CREATE TABLE t1 (a INT);
488+
INSERT INTO t1 VALUES (1),(2),(3);
489+
CREATE VIEW `v 1` AS SELECT * FROM t1;
490+
SELECT * FROM `v 1`;
491+
--exec $MYSQL_PUMP --databases bug22505474 > $MYSQLTEST_VARDIR/tmp/bug22505474.sql
492+
DROP DATABASE bug22505474;
493+
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug22505474.sql
494+
--remove_file $MYSQLTEST_VARDIR/tmp/bug22505474.sql
495+
USE bug22505474;
496+
SELECT * FROM t1;
497+
SELECT * FROM `v 1`;
498+
DROP DATABASE bug22505474;

0 commit comments

Comments
 (0)