Commit f218f9f2 authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

Bug#33550: mysqldump 4.0 compatibility broken

mysqldump included character_set_client magic
that is unknown before 4.1 even when asked for
an appropriate compatibility mode.

In compatibility (3.23, 4.0) mode, we do not
output charset statements (not even in a
"comment conditional"), nor do we do magic on
the server, even if the server is sufficient
new (4.1+). Table-names will be output converted
to the charset requested by mysqldump; if such
a conversion is not possible (Ivrit -> Latin),
mysqldump will fail.
parents 6a9de01a 5622d426
...@@ -1129,7 +1129,8 @@ static int connect_to_db(char *host, char *user,char *passwd) ...@@ -1129,7 +1129,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
DB_error(&mysql_connection, "when trying to connect"); DB_error(&mysql_connection, "when trying to connect");
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (mysql_get_server_version(&mysql_connection) < 40100) if ((mysql_get_server_version(&mysql_connection) < 40100) ||
(opt_compatible_mode & 3))
{ {
/* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */ /* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */
opt_set_charset= 0; opt_set_charset= 0;
...@@ -1857,11 +1858,11 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -1857,11 +1858,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
fprintf(sql_file, fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
"SET @saved_cs_client = @@character_set_client;\n" "/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
"SET character_set_client = utf8;\n" "/*!40101 SET character_set_client = utf8 */;\n"
"%s;\n" "%s;\n"
"SET character_set_client = @saved_cs_client;\n", "/*!40101 SET character_set_client = @saved_cs_client */;\n",
row[1]); row[1]);
check_io(sql_file); check_io(sql_file);
......
...@@ -93,73 +93,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l ...@@ -93,73 +93,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`; USE `test`;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`; DROP TABLE IF EXISTS `t2`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`; DROP TABLE IF EXISTS `t3`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` ( CREATE TABLE `t3` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */; /*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`; DROP TABLE IF EXISTS `t4`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t4` ( CREATE TABLE `t4` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */; /*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`; DROP TABLE IF EXISTS `t5`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t5` ( CREATE TABLE `t5` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1; ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */; /*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`; DROP TABLE IF EXISTS `t6`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t6` ( CREATE TABLE `t6` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
...@@ -190,73 +190,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l ...@@ -190,73 +190,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`; USE `test`;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`; DROP TABLE IF EXISTS `t2`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */; /*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`; DROP TABLE IF EXISTS `t3`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` ( CREATE TABLE `t3` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */; /*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`; DROP TABLE IF EXISTS `t4`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t4` ( CREATE TABLE `t4` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1; ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */; /*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`; DROP TABLE IF EXISTS `t5`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t5` ( CREATE TABLE `t5` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1; ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */; /*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`; DROP TABLE IF EXISTS `t6`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t6` ( CREATE TABLE `t6` (
`id` int(8) default NULL, `id` int(8) default NULL,
`name` varchar(32) default NULL `name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
......
This diff is collapsed.
...@@ -77,12 +77,12 @@ INSERT INTO t1 VALUES (1), (2); ...@@ -77,12 +77,12 @@ INSERT INTO t1 VALUES (1), (2);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) default NULL `a` int(11) default NULL
); );
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
...@@ -111,12 +111,12 @@ UNLOCK TABLES; ...@@ -111,12 +111,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) default NULL `a` int(11) default NULL
); );
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
...@@ -145,12 +145,12 @@ UNLOCK TABLES; ...@@ -145,12 +145,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`; DROP TABLE IF EXISTS `t1`;
SET @saved_cs_client = @@character_set_client; /*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8; /*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`a` int(11) default NULL `a` int(11) default NULL
); );
SET character_set_client = @saved_cs_client; /*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE; LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */;
......
...@@ -1650,6 +1650,24 @@ DROP TABLE t1,t2; ...@@ -1650,6 +1650,24 @@ DROP TABLE t1,t2;
SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
--echo #
--echo # Bug#33550 mysqldump 4.0 compatibility broken
--echo #
SET NAMES utf8;
CREATE TABLE `straße` ( f1 INT );
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=latin1 --compatible=mysql323 test
DROP TABLE `straße`;
CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT );
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test
--error 2
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=latin1 --compatible=mysql323 test
DROP TABLE `כדשגכחךלדגכחשךדגחכךלדגכ`;
SET NAMES latin1;
--echo # --echo #
--echo # End of 5.0 tests --echo # End of 5.0 tests
--echo # --echo #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment