Bug #2634 mysqldump in --compatible=mysql4
Submitted: 3 Feb 2004 17:33 Modified: 4 Feb 2004 18:33
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.1 OS:Any (All)
Assigned to: Antony Curtis CPU Architecture:Any

[3 Feb 2004 17:33] Peter Zaitsev
Description:
MySQLdump in compatible mode:  

mysqldump --compatible=mysql4

Still dumps   ... ENGINE=MYISAM which is not recognised by MySQL 4.0, before 4.0.18

How to repeat:
Dump any table from MySQL 4.1 in compatible mode and try to import it to
MySQL 4.0.17 or below.
[4 Feb 2004 18:15] Antony Curtis
The following patch fixes

===== sql/sql_show.cc 1.145 vs edited =====
--- 1.145/sql/sql_show.cc	Fri Jan 30 06:32:31 2004
+++ edited/sql/sql_show.cc	Thu Feb  5 01:01:23 2004
@@ -1338,7 +1338,14 @@
   packet->append("\n)", 2);
   if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
   {
-    packet->append(" ENGINE=", 8);
+    if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
+    {
+      packet->append(" TYPE=", 6);
+    }
+    else
+    {
+      packet->append(" ENGINE=", 8);
+    }
     packet->append(file->table_type());
     
     if (table->table_charset &&
===== mysql-test/t/mysqldump.test 1.11 vs edited =====
--- 1.11/mysql-test/t/mysqldump.test	Thu Jan 22 20:13:19 2004
+++ edited/mysql-test/t/mysqldump.test	Thu Feb  5 02:01:21 2004
@@ -53,3 +53,13 @@
 INSERT INTO t1  VALUES (_koi8r x'C1C2C3C4C5');
 --exec $MYSQL_DUMP  --skip-comments test t1
 DROP TABLE t1;
+
+#
+# Bug #2634
+#
+
+CREATE TABLE t1 (a int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES (1), (2);
+--exec $MYSQL_DUMP --skip-comments --compatible=mysql40 test t1
+--exec $MYSQL_DUMP --skip-comments --compatible=mysql323 test t1
+DROP TABLE t1;
===== mysql-test/r/mysqldump.result 1.14 vs edited =====
--- 1.14/mysql-test/r/mysqldump.result	Sat Jan 17 10:03:04 2004
+++ edited/mysql-test/r/mysqldump.result	Thu Feb  5 02:01:34 2004
@@ -123,3 +123,40 @@
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 
 DROP TABLE t1;
+CREATE TABLE t1 (a int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES (1), (2);
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+  `a` int(11) default NULL
+) TYPE=MyISAM;
+
+
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+LOCK TABLES `t1` WRITE;
+INSERT INTO `t1` VALUES (1),(2);
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+  `a` int(11) default NULL
+) TYPE=MyISAM;
+
+
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+LOCK TABLES `t1` WRITE;
+INSERT INTO `t1` VALUES (1),(2);
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+
+DROP TABLE t1;
[4 Feb 2004 18:33] Antony Curtis
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html