Commit 4d1f521f authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

Fix for the bug #1994: mysqldump does not correctly dump UCS2 data.

parent 9aa12e25
......@@ -89,7 +89,11 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*where=0,
*opt_compatible_mode_str= 0,
*err_ptr= 0;
#ifdef HAVE_CHARSET_utf8
static char *default_charset= (char*) "utf8";
#else
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
#endif
static ulong opt_compatible_mode= 0;
static uint opt_mysql_port= 0, err_len= 0;
static my_string opt_mysql_unix_port=0;
......@@ -351,7 +355,7 @@ static void write_header(FILE *sql_file, char *db_name)
fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
if (!opt_set_names)
fprintf(sql_file,"\n/*!40101 SET NAMES %s*/;\n",default_charset);
fprintf(sql_file,"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=%s */;\n",default_charset);
fprintf(md_result_file,"\
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n\
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n\
......@@ -372,6 +376,7 @@ static void write_footer(FILE *sql_file)
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n\
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n\
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n\
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n\
");
}
fputs("\n", sql_file);
......
......@@ -62,3 +62,42 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
</database>
</mysqldump>
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET ucs2;
INSERT INTO t1 VALUES (_ucs2 x'05D005D505DC05D9');
-- MySQL dump 10.2
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 4.1.2-alpha-debug-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=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 */;
--
-- Table structure for table `t1`
--
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a varchar(255) default NULL
) TYPE=MyISAM DEFAULT CHARSET=ucs2;
--
-- Dumping data for table `t1`
--
/*!40000 ALTER TABLE t1 DISABLE KEYS */;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES ('אולי');
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;
......@@ -22,3 +22,12 @@ CREATE TABLE t1 (`a"b"` char(2));
INSERT INTO t1 VALUES ("1\""), ("\"2");
--exec $MYSQL_DUMP --skip-all -X test t1
DROP TABLE t1;
#
# Bug #1994
#
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET ucs2;
INSERT INTO t1 VALUES (_ucs2 x'05D005D505DC05D9');
--exec $MYSQL_DUMP test t1
DROP TABLE t1;
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