Bug #30126 ADD_DROP_DATABASE with mysqldump problem
| Submitted: | 30 Jul 2007 17:14 | Modified: | 23 Oct 2007 16:24 |
|---|---|---|---|
| Reporter: | Theo Groß | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Backup | Severity: | S3 (Non-critical) |
| Version: | 5.0.45 | OS: | Linux |
| Assigned to: | Gleb Shchepa | CPU Architecture: | Any |
| Tags: | mysqldump --add-drop-database | ||
[1 Aug 2007 16:12]
MySQL Verification Team
Thank you for the bug report.
[24 Aug 2007 17:59]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/33045 ChangeSet@1.2504, 2007-08-24 23:29:31+05:00, gshchepa@gleb.loc +5 -0 Fixed bug #30126. When dumping database from the old (4.x) server, the mysqldump client inserted a delimiter sign inside special commentaries of the form: /*!... CREATE DATABASE IF NOT EXISTS ... ;*/ During restoration that dump file was splitten by delimiter signs on the client side, and the rest of some commentary strings was prepended to following statements.
[24 Aug 2007 20:01]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/33055 ChangeSet@1.2504, 2007-08-25 01:35:10+05:00, gshchepa@gleb.loc +5 -0 Fixed bug #30126. When dumping database from the 4.x server, the mysqldump client inserted a delimiter sign inside special commentaries of the form: /*!... CREATE DATABASE IF NOT EXISTS ... ;*/ During restoration that dump file was splitten by delimiter signs on the client side, and the rest of some commentary strings was prepended to following statements.
[25 Aug 2007 16:51]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/33105 ChangeSet@1.2504, 2007-08-25 22:26:08+05:00, gshchepa@gleb.loc +5 -0 Fixed bug #30126. When dumping database from a 4.x server, the mysqldump client inserted a delimiter sign inside special commentaries of the form: /*!... CREATE DATABASE IF NOT EXISTS ... ;*/ During restoration that dump file was splitten by delimiter signs on the client side, and the rest of some commentary strings was prepended to following statements.
[31 Aug 2007 12:01]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/33524 ChangeSet@1.2504, 2007-08-31 16:59:07+05:00, gshchepa@gleb.loc +5 -0 Fixed bug #30126. When dumping database from a 4.x server, the mysqldump client inserted a delimiter sign inside special commentaries of the form: /*!... CREATE DATABASE IF NOT EXISTS ... ;*/ During restoration that dump file was splitten by delimiter signs on the client side, and the rest of some commentary strings was prepended to following statements. The 4x_server_emul test case option has been added for use with the DBUG_EXECUTE_IF debugging macro. This option affects debug server builds only to emulate particular behavior of a 4.x server for the mysqldump client testing. Non-debugging builds are not affected.
[14 Sep 2007 7:45]
Bugs System
Pushed into 5.1.23-beta
[14 Sep 2007 7:46]
Bugs System
Pushed into 5.0.50
[23 Oct 2007 16:24]
Paul DuBois
Noted in 5.0.50, 5.1.23 changelogs. When mysqldump wrote DROP DATABASE statements within version-specific comments, it included the terminating semicolon in the wrong place, causing following statements to fail when the dump file was reloaded.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.065 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: mysqldump output of the DROP DATABASE line corrupts the dump because the line is not terminated with a semicolon. How to repeat: I created a full dump with the latest Version of mysqldump an added the --add-drop-database Comand-Line-Switch. [on a Mysql 4.0.24 Server] mysqldump --add-drop-database [...] > dump.sql When trying to restore the dump with the command: mysql[...] < dump.sql After adding this switch I got the following error Message: ERROR 1064 (42000) at line 15: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*/ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `databasename`' at line 1 So something is wrong there. Without the --add-drop-database switch this line worked perfectly for me. So i looked closer to the output and found: /*!40000 DROP DATABASE IF EXISTS `databasename`;*/ before that CREATE DATABASE line. A very close look discovered that the "*/" ist outside of the "semicolon" [;] on other Lines with "/*" "*/" the ";[semicolon]" is the trailing character of that line. Suggested fix: First i used "sed" to change the Position of the [Semicolon] but then i realised, that a fix in the source-code would be very easy [I am using the source anyway all the time]. So changing the Line in the source-file of mysqldump i.e. mysqldump.c which results in the following patch --- mysqldump.c 2007-07-30 19:09:58.000000000 +0200 +++ mysqldump.c.patched 2007-07-30 19:09:45.000000000 +0200 @@ -2872,7 +2872,7 @@ /* Old server version, dump generic CREATE DATABASE */ if (opt_drop_database) fprintf(md_result_file, - "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", + "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", qdatabase); fprintf(md_result_file, "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",