Bug #13700 mysqldump results in bad SQL with --add-drop-database
Submitted: 3 Oct 2005 7:31 Modified: 3 Oct 2005 9:24
Reporter: Jimmy Mäkelä Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.14 OS:FreeBSD (FreeBSD 5.4-RELEASE-p6)
Assigned to: CPU Architecture:Any

[3 Oct 2005 7:31] Jimmy Mäkelä
Description:
When using:
mysqldump -B --opt -Q --add-drop-database database

i get a dump which looks like:
...
/*!40000 DROP DATABASE IF EXISTS `database`;*/

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `database`;

USE `database`;

which produces an error of the form:
'*/
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `database`' at line 1

this is because 
/*!40000 DROP DATABASE IF EXISTS `database`;*/

followed by any statement gives such an error.

How to repeat:
see above.

Suggested fix:
Replace the drop-database statement with:
/*!40000 DROP DATABASE IF EXISTS `database`*/;
[3 Oct 2005 8:55] Valeriy Kravchuk
On 4.1.14-nt it works OK...
[3 Oct 2005 9:24] Valeriy Kravchuk
Thank you for a problem report. Sorry, but I was unable to reproduce it, both on Windows and on FreeBSD 5.4:

-bash-2.05b$ bin/mysqldump -uroot -p -B --opt -Q --add-drop-database test | more
Enter password:
-- MySQL dump 10.9
--
-- Host: localhost    Database: test
-- ------------------------------------------------------
-- Server version       4.1.14

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `test`
--

/*!40000 DROP DATABASE IF EXISTS `test`*/;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
-bash-2.05b$ uname -a
FreeBSD buildb 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Tue Jun 28 14:47:31 CEST 2005     root@buildb.mysql.com:/usr/src/sys/i386/compile/GENERIC  i386

Note the following line:

/*!40000 DROP DATABASE IF EXISTS `test`*/;

Nothins similar to yours...

Please, check your setup once more (including mysqldump version used).
[3 Oct 2005 11:59] Jimmy Mäkelä
The exact command was:
mysqldump -B --opt -Q --add-drop-database -h "remote_server" -u user -ppass database

and remote_server is running 4.0.18 on FreeBSD 4.9-RELEASE-p19

It is repeatable every time I run the command.
[3 Oct 2005 12:00] Jimmy Mäkelä
> mysqldump --version
mysqldump  Ver 10.9 Distrib 4.1.14, for portbld-freebsd5.4 (i386)