Bug #8148 mysqldump generates problematic SET statements
Submitted: 26 Jan 2005 18:40 Modified: 1 Feb 2005 3:04
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:4.1.3-beta bk tree OS:
Assigned to: Jim Winstead CPU Architecture:Any

[26 Jan 2005 18:40] Paul DuBois
Description:
mysqldump generates a couple of SET statements
that use double-quotes to quote the sql_mode value.
This is a problem when reloading the dump file because
if ANSI_QUOTES is already enabled, these quoted mode
values will be treated as identifiers, not quoted strings,
and the SET statements have no effect.

How to repeat:
run mysqldump.

Suggested fix:
Delivered-To: paul-mysql.snake.net@localhost.kitebird.com
Date: Wed, 26 Jan 2005 12:36:49 -0600
From: Paul DuBois <paul@snake.net>
To: paul@mysql.com
User-Agent: Mutt/1.4i

===== mysqldump.c 1.170 vs edited =====
--- 1.170/client/mysqldump.c	2005-01-24 08:48:16 -06:00
+++ edited/mysqldump.c	2005-01-26 12:28:02 -06:00
@@ -489,7 +489,7 @@
 ");
     }
     fprintf(sql_file,
-	    "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=\"%s%s%s\" */;\n",
+	    "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n",
 	    path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",",
 	    compatible_mode_normal_str);
     check_io(sql_file);
@@ -863,7 +863,7 @@
     cannot reconnect.
   */
   sock->reconnect= 0;
-  sprintf(buff, "/*!40100 SET @@SQL_MODE=\"%s\" */",
+  sprintf(buff, "/*!40100 SET @@SQL_MODE='%s' */",
 	  compatible_mode_normal_str);
   if (mysql_query_with_error_report(sock, 0, buff))
   {
[26 Jan 2005 19:21] Jorge del Conde
Verified 4.1.9 source tree
[1 Feb 2005 1:50] Jim Winstead
Pushed to 4.1.
[1 Feb 2005 3:04] Paul DuBois
Mentioned in 4.1.10 change notes.