diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result
index ed57b87c1bac6171cdcff5925e316064f5ea5c19..01b7fab2aba5da2d16974b5c8ada727d71031465 100755
--- a/mysql-test/r/ctype_cp932.result
+++ b/mysql-test/r/ctype_cp932.result
@@ -11353,3 +11353,13 @@ a
 a
 a
 drop table t1;
+ƒ\
+ƒ\
+c_cp932
+ƒ\
+ƒ\
+ƒ\
+ソ
+ソ
+ƒ\
+ƒ\
diff --git a/mysql-test/r/innodb-ucs2.result b/mysql-test/r/innodb-ucs2.result
new file mode 100644
index 0000000000000000000000000000000000000000..a1c73c912b20050a9fee048044061fe74026f4ed
--- /dev/null
+++ b/mysql-test/r/innodb-ucs2.result
@@ -0,0 +1,313 @@
+create table t1 (
+a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a	hex(b)	hex(c)	filler
+1	61626364656667	61626364656667	boo
+4	D0B1	D0B1	eight
+4	5B	5B	five
+4	E880BD	E880BD	four
+4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
+4	E880BDE880BD	E880BDE880BD	six
+3	71727374757677	71727374757677	three
+2	696A6B696C6D6E	696A6B696C6D6E	two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a	hex(b)	hex(c)	filler
+4	05630563	05630563	email
+4	0563	0563	email
+4	05612020	05612020	email
+4	01FC	01FC	email
+4	0120	0120	email
+4	00640065	00640065	email
+4	00E400E50068	00E400E50068	email
+4	0000E400	0000E400	email
+4	0000563001FC0563	0000563001FC0563	email
+1	0061006200630064006500660067	0061006200630064006500660067	one
+3	0071007200730074007500760077	0071007200730074007500760077	three
+2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
+drop table t1;
+drop table t2;
+create table t1 (
+a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a	hex(b)	hex(c)	filler
+1	61626364656667	61626364656667	boo
+4	D0B1	D0B1	eight
+4	5B	5B	five
+4	E880BD	E880BD	four
+4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
+4	E880BDE880BD	E880BDE880BD	six
+3	71727374757677	71727374757677	three
+2	696A6B696C6D6E	696A6B696C6D6E	two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a	hex(b)	hex(c)	filler
+4	05630563	05630563	email
+4	0563	0563	email
+4	05612020	05612020	email
+4	01FC	01FC	email
+4	0120	0120	email
+4	00640065	00640065	email
+4	00E400E50068	00E400E50068	email
+4	0000E400	0000E400	email
+4	0000563001FC0563	0000563001FC0563	email
+1	0061006200630064006500660067	0061006200630064006500660067	one
+3	0071007200730074007500760077	0071007200730074007500760077	three
+2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
+drop table t1;
+drop table t2;
+create table t1 (
+a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a	hex(b)	hex(c)	filler
+1	61626364656667	61626364656667	boo
+4	D0B1	D0B1	eight
+4	5B	5B	five
+4	E880BD	E880BD	four
+4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
+4	E880BDE880BD	E880BDE880BD	six
+3	71727374757677	71727374757677	three
+2	696A6B696C6D6E	696A6B696C6D6E	two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a	hex(b)	hex(c)	filler
+4	0120	0120	email
+4	01FC	01FC	email
+4	0563	0563	email
+4	0000563001FC0563	0000563001FC0563	email
+4	0000E400	0000E400	email
+4	00640065	00640065	email
+4	00E400E50068	00E400E50068	email
+4	05612020	05612020	email
+4	05630563	05630563	email
+1	0061006200630064006500660067	0061006200630064006500660067	one
+3	0071007200730074007500760077	0071007200730074007500760077	three
+2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
+drop table t1;
+drop table t2;
+create table t1 (
+a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a	hex(b)	hex(c)	filler
+1	61626364656667	61626364656667	boo
+4	D0B1	D0B1	eight
+4	5B	5B	five
+4	E880BD	E880BD	four
+3	71727374757677	71727374757677	three
+2	696A6B696C6D6E	696A6B696C6D6E	two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a	hex(b)	hex(c)	filler
+4	0000E400	0000E400	email
+4	00640065	00640065	email
+4	00E400E50068	00E400E50068	email
+4	0120	0120	email
+4	01FC	01FC	email
+4	05612020	05612020	email
+4	0563	0563	email
+1	61626364656667	61626364656667	one
+3	71727374757677	71727374757677	three
+2	696A6B696C6D6E	696A6B696C6D6E	two
+drop table t1;
+drop table t2;
+commit;
+CREATE TABLE t1 (
+ind enum('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind enum('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+hex(ind)	hex(string1)
+31	
+32	
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+hex(ind)	hex(string1)
+0031	
+0032	
+drop table t1,t2;
+CREATE TABLE t1 (
+ind set('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind set('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+hex(ind)	hex(string1)
+31	
+32	
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+hex(ind)	hex(string1)
+0031	
+0032	
+drop table t1,t2;
+CREATE TABLE t1 (
+ind bit not null,
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind bit not null,
+string1 varchar(250) NOT NULL,
+PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+insert into t1 values(0,''),(1,'');
+insert into t2 values(0,''),(1,'');
+select hex(ind),hex(string1) from t1 order by string1;
+hex(ind)	hex(string1)
+0	
+1	
+select hex(ind),hex(string1) from t2 order by string1;
+hex(ind)	hex(string1)
+0	
+1	
+drop table t1,t2;
+create table t2 (
+a int, b char(10), filler char(10), primary key(a, b(2)) 
+) character set utf8 engine = innodb;
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t2 (
+a int, b char(10), filler char(10), primary key(a, b(2)) 
+) character set ucs2 engine = innodb;
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+a	hex(b)
+1	61626364656667
+2	6465666768696A6B
+6	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
+7	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
+update t1 set b = 'three' where a = 6;
+drop table t1;
+create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+a	hex(b)
+1	61626364656667
+2	6465666768696A6B
+6	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
+7	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
+update t1 set b = 'three' where a = 6;
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 38d71ac7a42314864ac58e3d9d3da5f834e9906f..9abb95e2cc3a7f8e0021a121d7f2f250af67cf0d 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -2673,215 +2673,6 @@ checksum table t1;
 Table	Checksum
 test.t1	2050879373
 drop table t1;
-create table t1 (
-a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-a	hex(b)	hex(c)	filler
-1	61626364656667	61626364656667	boo
-4	D0B1	D0B1	eight
-4	5B	5B	five
-4	E880BD	E880BD	four
-4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
-4	E880BDE880BD	E880BDE880BD	six
-3	71727374757677	71727374757677	three
-2	696A6B696C6D6E	696A6B696C6D6E	two
-select a,hex(b),hex(c),filler from t2 order by filler;
-a	hex(b)	hex(c)	filler
-4	05630563	05630563	email
-4	0563	0563	email
-4	05612020	05612020	email
-4	01FC	01FC	email
-4	0120	0120	email
-4	00640065	00640065	email
-4	00E400E50068	00E400E50068	email
-4	0000E400	0000E400	email
-4	0000563001FC0563	0000563001FC0563	email
-1	0061006200630064006500660067	0061006200630064006500660067	one
-3	0071007200730074007500760077	0071007200730074007500760077	three
-2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
-drop table t1;
-drop table t2;
-create table t1 (
-a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-a	hex(b)	hex(c)	filler
-1	61626364656667	61626364656667	boo
-4	D0B1	D0B1	eight
-4	5B	5B	five
-4	E880BD	E880BD	four
-4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
-4	E880BDE880BD	E880BDE880BD	six
-3	71727374757677	71727374757677	three
-2	696A6B696C6D6E	696A6B696C6D6E	two
-select a,hex(b),hex(c),filler from t2 order by filler;
-a	hex(b)	hex(c)	filler
-4	05630563	05630563	email
-4	0563	0563	email
-4	05612020	05612020	email
-4	01FC	01FC	email
-4	0120	0120	email
-4	00640065	00640065	email
-4	00E400E50068	00E400E50068	email
-4	0000E400	0000E400	email
-4	0000563001FC0563	0000563001FC0563	email
-1	0061006200630064006500660067	0061006200630064006500660067	one
-3	0071007200730074007500760077	0071007200730074007500760077	three
-2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
-drop table t1;
-drop table t2;
-create table t1 (
-a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-a	hex(b)	hex(c)	filler
-1	61626364656667	61626364656667	boo
-4	D0B1	D0B1	eight
-4	5B	5B	five
-4	E880BD	E880BD	four
-4	E880BDD0B1E880BD	E880BDD0B1E880BD	seven
-4	E880BDE880BD	E880BDE880BD	six
-3	71727374757677	71727374757677	three
-2	696A6B696C6D6E	696A6B696C6D6E	two
-select a,hex(b),hex(c),filler from t2 order by filler;
-a	hex(b)	hex(c)	filler
-4	0120	0120	email
-4	01FC	01FC	email
-4	0563	0563	email
-4	0000563001FC0563	0000563001FC0563	email
-4	0000E400	0000E400	email
-4	00640065	00640065	email
-4	00E400E50068	00E400E50068	email
-4	05612020	05612020	email
-4	05630563	05630563	email
-1	0061006200630064006500660067	0061006200630064006500660067	one
-3	0071007200730074007500760077	0071007200730074007500760077	three
-2	0069006A006B0069006C006D006E	0069006A006B0069006C006D006E	two
-drop table t1;
-drop table t2;
-create table t1 (
-a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-a	hex(b)	hex(c)	filler
-1	61626364656667	61626364656667	boo
-4	D0B1	D0B1	eight
-4	5B	5B	five
-4	E880BD	E880BD	four
-3	71727374757677	71727374757677	three
-2	696A6B696C6D6E	696A6B696C6D6E	two
-select a,hex(b),hex(c),filler from t2 order by filler;
-a	hex(b)	hex(c)	filler
-4	0000E400	0000E400	email
-4	00640065	00640065	email
-4	00E400E50068	00E400E50068	email
-4	0120	0120	email
-4	01FC	01FC	email
-4	05612020	05612020	email
-4	0563	0563	email
-1	61626364656667	61626364656667	one
-3	71727374757677	71727374757677	three
-2	696A6B696C6D6E	696A6B696C6D6E	two
-drop table t1;
-drop table t2;
-commit;
 set foreign_key_checks=0;
 create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
 create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
@@ -3058,109 +2849,6 @@ select hex(s1) from t2;
 hex(s1)
 12
 drop table t2,t1;
-CREATE TABLE t1 (
-ind enum('0','1','2') NOT NULL default '0',
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-ind enum('0','1','2') NOT NULL default '0',
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-INSERT INTO t1 VALUES ('1', ''),('2', '');
-INSERT INTO t2 VALUES ('1', ''),('2', '');
-SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
-hex(ind)	hex(string1)
-31	
-32	
-SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
-hex(ind)	hex(string1)
-0031	
-0032	
-drop table t1,t2;
-CREATE TABLE t1 (
-ind set('0','1','2') NOT NULL default '0',
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-ind set('0','1','2') NOT NULL default '0',
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-INSERT INTO t1 VALUES ('1', ''),('2', '');
-INSERT INTO t2 VALUES ('1', ''),('2', '');
-SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
-hex(ind)	hex(string1)
-31	
-32	
-SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
-hex(ind)	hex(string1)
-0031	
-0032	
-drop table t1,t2;
-CREATE TABLE t1 (
-ind bit not null,
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-ind bit not null,
-string1 varchar(250) NOT NULL,
-PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-insert into t1 values(0,''),(1,'');
-insert into t2 values(0,''),(1,'');
-select hex(ind),hex(string1) from t1 order by string1;
-hex(ind)	hex(string1)
-0	
-1	
-select hex(ind),hex(string1) from t2 order by string1;
-hex(ind)	hex(string1)
-0	
-1	
-drop table t1,t2;
-create table t2 (
-a int, b char(10), filler char(10), primary key(a, b(2)) 
-) character set utf8 engine = innodb;
-insert into t2 values (1,'abcdefg','one');
-insert into t2 values (2,'ijkilmn','two');
-insert into t2 values (3, 'qrstuvw','three');
-update t2 set a=5, filler='booo' where a=1;
-drop table t2;
-create table t2 (
-a int, b char(10), filler char(10), primary key(a, b(2)) 
-) character set ucs2 engine = innodb;
-insert into t2 values (1,'abcdefg','one');
-insert into t2 values (2,'ijkilmn','two');
-insert into t2 values (3, 'qrstuvw','three');
-update t2 set a=5, filler='booo' where a=1;
-drop table t2;
-create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
-insert into t1 values(1,'abcdefg'),(2,'defghijk');
-insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
-insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
-select a,hex(b) from t1 order by b;
-a	hex(b)
-1	61626364656667
-2	6465666768696A6B
-6	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
-7	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
-update t1 set b = 'three' where a = 6;
-drop table t1;
-create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
-insert into t1 values(1,'abcdefg'),(2,'defghijk');
-insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
-insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
-select a,hex(b) from t1 order by b;
-a	hex(b)
-1	61626364656667
-2	6465666768696A6B
-6	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
-7	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
-update t1 set b = 'three' where a = 6;
-drop table t1;
 CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
 CREATE TABLE t2(a INT) ENGINE=InnoDB;
 ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index 3bba1944c52479e86b1254a1d2a244a7196b8b1b..e83bbe97eaa17b76340d2f25519be7731ccf8699 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -61,16 +61,6 @@ database()
 test
 unlock tables;
 drop table t1;
-ƒ\
-ƒ\
-c_cp932
-ƒ\
-ƒ\
-ƒ\
-ソ
-ソ
-ƒ\
-ƒ\
 +----------------------+------------+--------+
 | concat('>',col1,'<') | col2       | col3   |
 +----------------------+------------+--------+
diff --git a/mysql-test/r/mysqlbinlog-cp932.result b/mysql-test/r/mysqlbinlog-cp932.result
new file mode 100644
index 0000000000000000000000000000000000000000..1640a3b16424bda7bd3909bf1410f6bdca4c02b7
--- /dev/null
+++ b/mysql-test/r/mysqlbinlog-cp932.result
@@ -0,0 +1,19 @@
+flush logs;
+create table t3 (f text character set utf8);
+create table t4 (f text character set cp932);
+flush logs;
+rename table t3 to t03, t4 to t04;
+select HEX(f) from t03;
+HEX(f)
+E382BD
+select HEX(f) from t3;
+HEX(f)
+E382BD
+select HEX(f) from t04;
+HEX(f)
+835C
+select HEX(f) from t4;
+HEX(f)
+835C
+drop table t3, t4, t03, t04;
+End of 5.0 tests
diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result
index c3be791b523f7c34eed559f9447dae11d0bef4f0..1bb607abb7f1a936e524c09bcc53c6a0b3bf6067 100644
--- a/mysql-test/r/mysqlbinlog.result
+++ b/mysql-test/r/mysqlbinlog.result
@@ -173,25 +173,9 @@ insert t1 values (1);
 ROLLBACK /* added by mysqlbinlog */;
 /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 flush logs;
-create table t3 (f text character set utf8);
-create table t4 (f text character set cp932);
-flush logs;
-rename table t3 to t03, t4 to t04;
-select HEX(f) from t03;
-HEX(f)
-E382BD
-select HEX(f) from t3;
-HEX(f)
-E382BD
-select HEX(f) from t04;
-HEX(f)
-835C
-select HEX(f) from t4;
-HEX(f)
-835C
-flush logs;
 select * from t5  /* must be (1),(1) */;
 a
 1
 1
-drop table t1, t2, t03, t04, t3, t4, t5;
+drop table t1, t2, t5;
+End of 5.0 tests
diff --git a/mysql-test/r/sp-ucs2.result b/mysql-test/r/sp-ucs2.result
new file mode 100644
index 0000000000000000000000000000000000000000..ce6be5b0a65c7f8c3138cf8b12de5e6095d02ca4
--- /dev/null
+++ b/mysql-test/r/sp-ucs2.result
@@ -0,0 +1,14 @@
+drop function if exists bug17615|
+create table t3 (a varchar(256) unicode)|
+create function bug17615() returns varchar(256) unicode
+begin
+declare tmp_res varchar(256) unicode;
+set tmp_res= 'foo string';
+return tmp_res;
+end|
+insert into t3 values(bug17615())|
+select * from t3|
+a
+foo string
+drop function bug17615|
+drop table t3|
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 793abb417fb187ae62fe9e9d9639798ac74de6cc..6ce20b55358e60d987fdd25371f7127b407dfb46 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4697,20 +4697,6 @@ Handler
 Inner
 drop procedure bug15011|
 drop table t3|
-drop function if exists bug17615|
-create table t3 (a varchar(256) unicode)|
-create function bug17615() returns varchar(256) unicode
-begin
-declare tmp_res varchar(256) unicode;
-set tmp_res= 'foo string';
-return tmp_res;
-end|
-insert into t3 values(bug17615())|
-select * from t3|
-a
-foo string
-drop function bug17615|
-drop table t3|
 drop procedure if exists bug17476|
 create table t3 ( d date )|
 insert into t3 values
diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test
index 688d06c4dde0a88b8c4d7762fb070767cbe8a008..440ce02af9e84bb9050070742d6fb09d67b394d4 100644
--- a/mysql-test/t/ctype_cp932.test
+++ b/mysql-test/t/ctype_cp932.test
@@ -413,3 +413,17 @@ select * from t1;
 insert into t1 values ('abc');
 select * from t1;
 drop table t1;
+
+#
+# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\' 
+#
+
+# new command \C or charset
+--exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g"
+--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
+
+# its usage to switch internally in mysql to requested charset
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1;  drop table t1;"
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'"
diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt
index a0b5b06186001b9bb129a9af5d440aa1220236be..84d2a52b6399f5abd04303fcd74749277e21e8cd 100644
--- a/mysql-test/t/ctype_ucs2_def-master.opt
+++ b/mysql-test/t/ctype_ucs2_def-master.opt
@@ -1 +1 @@
---default-collation=ucs2_unicode_ci --default-character-set=ucs2
+--default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1
diff --git a/mysql-test/t/ctype_ucs2_def.test b/mysql-test/t/ctype_ucs2_def.test
index 00f636d79dcc9a50ff3ac3cfdfd081607ff65801..e435d1fb07df7007e7fcf3656b40d5f0ae557b69 100644
--- a/mysql-test/t/ctype_ucs2_def.test
+++ b/mysql-test/t/ctype_ucs2_def.test
@@ -1,3 +1,5 @@
+-- source include/have_ucs2.inc
+
 #
 # MySQL Bug#15276: MySQL ignores collation-server
 #
diff --git a/mysql-test/t/innodb-ucs2.test b/mysql-test/t/innodb-ucs2.test
new file mode 100644
index 0000000000000000000000000000000000000000..6647a9d08456cfee8c86a3165f84cc1608420383
--- /dev/null
+++ b/mysql-test/t/innodb-ucs2.test
@@ -0,0 +1,226 @@
+-- source include/have_innodb.inc
+-- source include/have_ucs2.inc
+
+#
+# BUG 14056 Column prefix index on UTF-8 primary key column causes: Can't find record..
+#
+
+create table t1 (
+  a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+  a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
+drop table t1;
+drop table t2;
+
+create table t1 (
+  a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+  a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
+drop table t1;
+drop table t2;
+
+create table t1 (
+  a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+  a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
+insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
+insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
+drop table t1;
+drop table t2;
+
+create table t1 (
+  a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
+) character set utf8 engine = innodb;
+create table t2 (
+  a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
+) character set ucs2 engine = innodb;
+insert into t1 values (1,'abcdefg','abcdefg','one');
+insert into t1 values (2,'ijkilmn','ijkilmn','two');
+insert into t1 values (3,'qrstuvw','qrstuvw','three');
+insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
+insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
+insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
+insert into t2 values (1,'abcdefg','abcdefg','one');
+insert into t2 values (2,'ijkilmn','ijkilmn','two');
+insert into t2 values (3,'qrstuvw','qrstuvw','three');
+insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
+insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
+insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
+insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
+insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
+insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
+insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
+drop table t1;
+drop table t2;
+commit;
+
+#
+# Test cases for bug #15308 Problem of Order with Enum Column in Primary Key
+#
+CREATE TABLE t1 (
+  ind enum('0','1','2') NOT NULL default '0',
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+  ind enum('0','1','2') NOT NULL default '0',
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+drop table t1,t2;
+
+CREATE TABLE t1 (
+  ind set('0','1','2') NOT NULL default '0',
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+  ind set('0','1','2') NOT NULL default '0',
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+drop table t1,t2;
+
+CREATE TABLE t1 (
+  ind bit not null,
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+  ind bit not null,
+  string1 varchar(250) NOT NULL,
+  PRIMARY KEY  (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+insert into t1 values(0,''),(1,'');
+insert into t2 values(0,''),(1,'');
+select hex(ind),hex(string1) from t1 order by string1;
+select hex(ind),hex(string1) from t2 order by string1;
+drop table t1,t2;
+
+# tests for bug #14056 Column prefix index on UTF-8 primary key column causes 'Can't find record..'
+
+create table t2 (
+  a int, b char(10), filler char(10), primary key(a, b(2)) 
+) character set utf8 engine = innodb;
+
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t2 (
+  a int, b char(10), filler char(10), primary key(a, b(2)) 
+) character set ucs2 engine = innodb;
+
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+
+create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+update t1 set b = 'three' where a = 6;
+drop table t1;
+create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+update t1 set b = 'three' where a = 6;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 4a1efc9e566c8d9cea2ccdf9dd081a9d609bd181..236a7b737bccc2c4fcd900d9186ba73b8a357f47 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1636,139 +1636,6 @@ connection default;
 disconnect a;
 disconnect b;
 
-#
-# BUG 14056 Column prefix index on UTF-8 primary key column causes: Can't find record..
-#
-
-create table t1 (
-  a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-  a int, b char(10), c char(10), filler char(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-select a,hex(b),hex(c),filler from t2 order by filler;
-drop table t1;
-drop table t2;
-
-create table t1 (
-  a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-  a int, b varchar(10), c varchar(10), filler varchar(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-select a,hex(b),hex(c),filler from t2 order by filler;
-drop table t1;
-drop table t2;
-
-create table t1 (
-  a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-  a int, b text(10), c text(10), filler text(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xe880bde880bd,_utf8 0xe880bde880bd,'six');
-insert into t1 values (4,_utf8 0xe880bdD0B1e880bd,_utf8 0xe880bdD0B1e880bd,'seven');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
-insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-select a,hex(b),hex(c),filler from t2 order by filler;
-drop table t1;
-drop table t2;
-
-create table t1 (
-  a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
-) character set utf8 engine = innodb;
-create table t2 (
-  a int, b blob(10), c blob(10), filler blob(10), primary key(a, b(2)), unique key (a, c(2))
-) character set ucs2 engine = innodb;
-insert into t1 values (1,'abcdefg','abcdefg','one');
-insert into t1 values (2,'ijkilmn','ijkilmn','two');
-insert into t1 values (3,'qrstuvw','qrstuvw','three');
-insert into t1 values (4,_utf8 0xe880bd,_utf8 0xe880bd,'four');
-insert into t1 values (4,_utf8 0x5b,_utf8 0x5b,'five');
-insert into t1 values (4,_utf8 0xD0B1,_utf8 0xD0B1,'eight');
-insert into t2 values (1,'abcdefg','abcdefg','one');
-insert into t2 values (2,'ijkilmn','ijkilmn','two');
-insert into t2 values (3,'qrstuvw','qrstuvw','three');
-insert into t2 values (4,_ucs2 0x00e400,_ucs2 0x00e400,'four');
-insert into t2 values (4,_ucs2 0x00640065,_ucs2 0x00640065,'five');
-insert into t2 values (4,_ucs2 0x00e400e50068,_ucs2 0x00e400e50068,'six');
-insert into t2 values (4,_ucs2 0x01fc,_ucs2 0x01fc,'seven');
-insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
-insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
-insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
-update t1 set filler = 'boo' where a = 1;
-update t2 set filler ='email' where a = 4;
-select a,hex(b),hex(c),filler from t1 order by filler;
-select a,hex(b),hex(c),filler from t2 order by filler;
-drop table t1;
-drop table t2;
-commit;
-
 # tests for bugs #9802 and #13778
 
 # test that FKs between invalid types are not accepted
@@ -1949,95 +1816,6 @@ select a,hex(s1) from t1;
 select hex(s1) from t2;
 
 drop table t2,t1;
-#
-# Test cases for bug #15308 Problem of Order with Enum Column in Primary Key
-#
-CREATE TABLE t1 (
-  ind enum('0','1','2') NOT NULL default '0',
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-  ind enum('0','1','2') NOT NULL default '0',
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-
-INSERT INTO t1 VALUES ('1', ''),('2', '');
-INSERT INTO t2 VALUES ('1', ''),('2', '');
-SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
-SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
-drop table t1,t2;
-
-CREATE TABLE t1 (
-  ind set('0','1','2') NOT NULL default '0',
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-  ind set('0','1','2') NOT NULL default '0',
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-
-INSERT INTO t1 VALUES ('1', ''),('2', '');
-INSERT INTO t2 VALUES ('1', ''),('2', '');
-SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
-SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
-drop table t1,t2;
-
-CREATE TABLE t1 (
-  ind bit not null,
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE t2 (
-  ind bit not null,
-  string1 varchar(250) NOT NULL,
-  PRIMARY KEY  (ind)
-) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
-insert into t1 values(0,''),(1,'');
-insert into t2 values(0,''),(1,'');
-select hex(ind),hex(string1) from t1 order by string1;
-select hex(ind),hex(string1) from t2 order by string1;
-drop table t1,t2;
-
-# tests for bug #14056 Column prefix index on UTF-8 primary key column causes 'Can't find record..'
-
-create table t2 (
-  a int, b char(10), filler char(10), primary key(a, b(2)) 
-) character set utf8 engine = innodb;
-
-insert into t2 values (1,'abcdefg','one');
-insert into t2 values (2,'ijkilmn','two');
-insert into t2 values (3, 'qrstuvw','three');
-update t2 set a=5, filler='booo' where a=1;
-drop table t2;
-create table t2 (
-  a int, b char(10), filler char(10), primary key(a, b(2)) 
-) character set ucs2 engine = innodb;
-
-insert into t2 values (1,'abcdefg','one');
-insert into t2 values (2,'ijkilmn','two');
-insert into t2 values (3, 'qrstuvw','three');
-update t2 set a=5, filler='booo' where a=1;
-drop table t2;
-
-create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
-insert into t1 values(1,'abcdefg'),(2,'defghijk');
-insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
-insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
-select a,hex(b) from t1 order by b;
-update t1 set b = 'three' where a = 6;
-drop table t1;
-create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
-insert into t1 values(1,'abcdefg'),(2,'defghijk');
-insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
-insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
-select a,hex(b) from t1 order by b;
-update t1 set b = 'three' where a = 6;
-drop table t1;
-
 # Ensure that <tablename>_ibfk_0 is not mistreated as a
 # generated foreign key identifier.  (Bug #16387)
 
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 3d022eb27e4880e3dcbce9a1968436a28e55688e..785f88b2ed6a542bd8d9206221fa531faf68238f 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -43,20 +43,6 @@ lock tables t1 write;
 unlock tables;
 drop table t1;
 
-#
-# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\' 
-#
-
-# new command \C or charset
---exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g"
---exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
-
-# its usage to switch internally in mysql to requested charset
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1;  drop table t1;"
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'"
-
 #
 # Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string".
 #
diff --git a/mysql-test/t/mysqlbinlog-cp932.test b/mysql-test/t/mysqlbinlog-cp932.test
new file mode 100644
index 0000000000000000000000000000000000000000..0e0a4e2bfae6b949ae951dba787d5d35b33c462a
--- /dev/null
+++ b/mysql-test/t/mysqlbinlog-cp932.test
@@ -0,0 +1,19 @@
+-- source include/have_cp932.inc
+
+# Bug#16217 (mysql client did not know how not switch its internal charset)
+flush logs;
+create table t3 (f text character set utf8);
+create table t4 (f text character set cp932); 
+--exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'ソ')"
+--exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'ƒ\');"
+flush logs;
+rename table t3 to t03, t4 to t04;
+--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000002 | $MYSQL --default-character-set=utf8
+# original and recovered data must be equal
+select HEX(f) from t03;
+select HEX(f) from t3;
+select HEX(f) from t04;
+select HEX(f) from t4;
+
+drop table t3, t4, t03, t04;
+--echo End of 5.0 tests
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index 0691cb7c76b629b3449429f1642600b219f03af3..4638474e1e8725695e2e1ad57f29253c28d4bf19 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -107,21 +107,6 @@ select "--- reading stdin --" as "";
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 --exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
 
-# Bug#16217 (mysql client did not know how not switch its internal charset)
-flush logs;
-create table t3 (f text character set utf8);
-create table t4 (f text character set cp932); 
---exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'ソ')"
---exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'ƒ\');"
-flush logs;
-rename table t3 to t03, t4 to t04;
---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000004 | $MYSQL --default-character-set=utf8
-# original and recovered data must be equal
-select HEX(f) from t03;
-select HEX(f) from t3;
-select HEX(f) from t04;
-select HEX(f) from t4;
-
 #
 #BUG#14157: utf8 encoding in binlog without set character_set_client
 #
@@ -131,10 +116,10 @@ flush logs;
 # resulted binlog, parly consisting of multi-byte utf8 chars, 
 # must be digestable for both client and server. In 4.1 the client 
 # should use default-character-set same as the server.
---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL
+--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000004 | $MYSQL
 select * from t5  /* must be (1),(1) */;
 
 # clean up
-drop table t1, t2, t03, t04, t3, t4, t5; 
+drop table t1, t2, t5; 
 
-# End of 5.0 tests
+--echo End of 5.0 tests
diff --git a/mysql-test/t/sp-ucs2.test b/mysql-test/t/sp-ucs2.test
new file mode 100644
index 0000000000000000000000000000000000000000..7dd88b0487197bd621d89cb009f654913476b1e0
--- /dev/null
+++ b/mysql-test/t/sp-ucs2.test
@@ -0,0 +1,28 @@
+-- source include/have_ucs2.inc
+
+delimiter |;
+
+#
+# BUG#17615: problem with character set
+#
+--disable_warnings
+drop function if exists bug17615|
+--enable_warnings
+
+create table t3 (a varchar(256) unicode)|
+
+create function bug17615() returns varchar(256) unicode
+begin
+  declare tmp_res varchar(256) unicode;
+  set tmp_res= 'foo string';
+  return tmp_res;
+end|
+
+insert into t3 values(bug17615())|
+select * from t3|
+
+drop function bug17615|
+drop table t3|
+
+
+delimiter ;|
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 95bb9f7c376e27abcc06dca10cec30d38cda4c69..5a3bab1e51aa55567a426907690a6b646e426ca5 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -11,6 +11,8 @@
 # Tests that uses 'goto' to into sp-goto.test (currently disabled)
 # Tests that destroys system tables (e.g. mysql.proc) for error testing
 #   go to sp-destruct.
+# Tests that require multibyte character sets, which are not always available,
+#   go into separate files (e.g. sp-ucs2.test)
 
 use test;
 
@@ -5525,29 +5527,6 @@ drop procedure bug15011|
 drop table t3|
 
 
-#
-# BUG#17615: problem with character set
-#
---disable_warnings
-drop function if exists bug17615|
---enable_warnings
-
-create table t3 (a varchar(256) unicode)|
-
-create function bug17615() returns varchar(256) unicode
-begin
-  declare tmp_res varchar(256) unicode;
-  set tmp_res= 'foo string';
-  return tmp_res;
-end|
-
-insert into t3 values(bug17615())|
-select * from t3|
-
-drop function bug17615|
-drop table t3|
-
-
 #
 # BUG#17476: Stored procedure not returning data when it is called first
 #            time per connection
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5890a2af21d057a75d474e8757f6cd49d1bd1d7a..e86f94e98e662b9e6f1e28d2a7c525dddd65073c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2718,10 +2718,33 @@ static int init_common_variables(const char *conf_file_name, int argc,
 #ifdef USE_REGEX
   my_regex_init(&my_charset_latin1);
 #endif
-  if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
-						    MY_CS_PRIMARY,
-						    MYF(MY_WME))))
-    return 1;
+  /*
+    Process a comma-separated character set list and choose
+    the first available character set. This is mostly for
+    test purposes, to be able to start "mysqld" even if
+    the requested character set is not available (see bug#18743).
+  */
+  for (;;)
+  {
+    char *next_character_set_name= strchr(default_character_set_name, ',');
+    if (next_character_set_name)
+      *next_character_set_name++= '\0';
+    if (!(default_charset_info=
+          get_charset_by_csname(default_character_set_name,
+                                MY_CS_PRIMARY, MYF(MY_WME))))
+    {
+      if (next_character_set_name)
+      {
+        default_character_set_name= next_character_set_name;
+        default_collation_name= 0;          // Ignore collation
+      }
+      else
+        return 1;                           // Eof of the list
+    }
+    else
+      break;
+  }
+
   if (default_collation_name)
   {
     CHARSET_INFO *default_collation;