← Back to team overview

maria-developers team mailing list archive

Re: utf16le

 

Hi!

I cc: mariadb-developers to ensure that others can also comment on the
patch.

Because the patch was not originally submitted there, I am not cutting
out ok code parts as I usually do.

>>>>> "Alexander" == Alexander Barkov <bar@xxxxxxxxxxx> writes:

Alexander>    Hi Monty,
Alexander> Please review a merge from MySQL-5.6 for utf16le.

Alexander> I also merged a few related bug fixes,
Alexander> which affected the test "ctype_utf16le":

Alexander> - Unreadable warnings in CAST(<ucs2, utf16, utf32 value> AS SIGNED)

Alexander> - Errors about unknown collation and unknown charset in cases
Alexander>    when the SET queries should actually succeed:

Alexander>    SET collation_connection=<ucs2, utf16, utf32 value>;
Alexander>    SET character_set_connection=<ucs2, utf16, utf32 value>;

Alexander> - MySQL Bug#59145 valgrind warnings for uninitialized values in 
Alexander> my_strtoll10_mb2

Alexander> - MySQL Bug#32859 Character sets: no warning with non-fitting chariot wheel

>----------------------------------------------------------------------
>=== modified file 'cmake/character_sets.cmake'
>--- cmake/character_sets.cmake	2011-12-15 21:08:42 +0000
>+++ cmake/character_sets.cmake	2013-03-15 04:14:25 +0000
>@@ -25,14 +25,14 @@
> SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb4)
> SET(CHARSETS_COMPLEX
>   big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2
>-  sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32)
>+  sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf16le utf32)
> 
> SET(CHARSETS_AVAILABLE 
> binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257
> cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8
> greek hebrew hp8 keybcs2 koi8r koi8u
> latin1 latin2 latin5 latin7 macce macroman
>-sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32)
>+sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf16le utf32)
> 
> SET (EXTRA_CHARSETS "all")
>
>=== modified file 'include/m_ctype.h'
>--- include/m_ctype.h	2012-04-07 13:58:46 +0000
>+++ include/m_ctype.h	2013-03-14 12:45:40 +0000
>@@ -362,6 +362,8 @@
> extern struct charset_info_st my_charset_utf16_bin;
> extern struct charset_info_st my_charset_utf16_general_ci;
> extern struct charset_info_st my_charset_utf16_unicode_ci;
>+extern struct charset_info_st my_charset_utf16le_bin;
>+extern struct charset_info_st my_charset_utf16le_general_ci;
> extern struct charset_info_st my_charset_utf32_bin;
> extern struct charset_info_st my_charset_utf32_general_ci;
> extern struct charset_info_st my_charset_utf32_unicode_ci;
>
>=== added file 'mysql-test/include/ctype_heap.inc'
>--- mysql-test/include/ctype_heap.inc	1970-01-01 00:00:00 +0000
>+++ mysql-test/include/ctype_heap.inc	2012-12-24 16:09:42 +0000
>@@ -0,0 +1,11 @@
>+SELECT @@collation_connection;
>+CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0;
>+ALTER TABLE t1 ADD KEY (a);
>+CREATE TABLE t2 (a VARCHAR(10));
>+INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
>+INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
>+INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1;
>+DROP TABLE t2;
>+INSERT INTO t1 VALUES ('a ');
>+SELECT a, HEX(a) FROM t1 WHERE a='a';
>+DROP TABLE t1;

Monty:
What new code / issue does the above test?
Please add a comment before the test.


>=== modified file 'mysql-test/r/ctype_ucs.result'
>--- mysql-test/r/ctype_ucs.result	2013-01-15 18:13:32 +0000
>+++ mysql-test/r/ctype_ucs.result	2013-03-15 04:38:24 +0000
>@@ -1274,7 +1274,7 @@
> CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED)
> 0
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: ''õ''
> End of 5.0 tests
> #
> # Start of 5.1 tests
>@@ -4200,3 +4200,22 @@
> #
> # End of 5.5 tests
> #
>+#
>+# Start of 5.6 tests
>+#
>+#
>+# Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2
>+#
>+SET NAMES latin1;
>+SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED);
>+CONVERT(CHAR(NULL USING ucs2), UNSIGNED)
>+0
>+Warnings:
>+Warning	1292	Truncated incorrect INTEGER value: ''
>+DO IFNULL(CHAR(NULL USING ucs2), '');
>+DO CAST(CONVERT('' USING ucs2) AS UNSIGNED);
>+Warnings:
>+Warning	1292	Truncated incorrect INTEGER value: ''
>+#
>+# End of 5.6 tests
>+#
>
>=== added file 'mysql-test/r/ctype_utf16le.result'
>--- mysql-test/r/ctype_utf16le.result	1970-01-01 00:00:00 +0000
>+++ mysql-test/r/ctype_utf16le.result	2013-03-14 15:04:17 +0000
>@@ -0,0 +1,1394 @@
>+SET TIME_ZONE='+03:00';
>+DROP TABLE IF EXISTS t1;
>+#
>+# Start of 5.6 tests
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT HEX('a'), HEX('a ');
>+HEX('a')	HEX('a ')
>+6100	61002000
>+select 'a' = 'a', 'a' = 'a ', 'a ' = 'a';
>+'a' = 'a'	'a' = 'a '	'a ' = 'a'
>+1	1	1
>+select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a';
>+'a\0' = 'a'	'a\0' < 'a'	'a\0' > 'a'
>+0	1	0
>+select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0';
>+'a' = 'a\0'	'a' < 'a\0'	'a' > 'a\0'
>+0	0	1
>+select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a ';
>+'a\0' = 'a '	'a\0' < 'a '	'a\0' > 'a '
>+0	1	0
>+select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0';
>+'a ' = 'a\0'	'a ' < 'a\0'	'a ' > 'a\0'
>+0	0	1
>+select 'a  a' > 'a', 'a  \0' < 'a';
>+'a  a' > 'a'	'a  \0' < 'a'
>+1	1
>+select binary 'a  a' > 'a', binary 'a  \0' > 'a', binary 'a\0' > 'a';
>+binary 'a  a' > 'a'	binary 'a  \0' > 'a'	binary 'a\0' > 'a'
>+1	1	1
>+#
>+# Check that incomplete utf16le characters in HEX notation
>+# are left-padded with zeros
>+#
>+SELECT HEX(_utf16le 0x44);
>+HEX(_utf16le 0x44)
>+0044
>+SELECT HEX(_utf16le 0x3344);
>+HEX(_utf16le 0x3344)
>+3344
>+SELECT HEX(_utf16le 0x113344);
>+HEX(_utf16le 0x113344)
>+00113344
>+#
>+# Check that 0x20 is only trimmed when it is
>+# a part of real SPACE character, not just a part
>+# of a multibyte sequence.
>+# Note, CYRILLIC LETTER ER is used as an example, which
>+# is stored as 0x0420 in utf16le, thus contains 0x20 in the
>+# low byte. The second character is THREE-PER-M, U+2004,
>+# which contains 0x20 in the high byte.
>+#
>+CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (_ucs2 X'2004',_ucs2 X'2004');
>+SELECT HEX(word) FROM t1 ORDER BY word;
>+HEX(word)
>+2004
>+0420
>+SELECT HEX(word2) FROM t1 ORDER BY word2;
>+HEX(word2)
>+2004
>+0420
>+DELETE FROM t1;
>+#
>+# Check that real spaces are correctly trimmed.
>+#
>+INSERT INTO t1 VALUES (_ucs2 X'042000200020', _ucs2 X'042000200020');
>+INSERT INTO t1 VALUES (_ucs2 X'200400200020', _ucs2 X'200400200020');
>+SELECT HEX(word) FROM t1 ORDER BY word;
>+HEX(word)
>+200420002000
>+042020002000
>+SELECT HEX(word2) FROM t1 ORDER BY word2;
>+HEX(word2)
>+2004
>+0420
>+DROP TABLE t1;
>+#
>+# Check LPAD/RPAD
>+#
>+CREATE TABLE t1 (a VARCHAR(10), pad INT, b VARCHAR(10)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'0421');
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'04210422');
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'042104220423');
>+INSERT INTO t1 VALUES (_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
>+Warnings:
>+Warning	1265	Data truncated for column 'a' at row 1
>+INSERT INTO t1 VALUES (_utf32 X'010000', 10, _ucs2 X'0421');
>+INSERT INTO t1 VALUES (_ucs2 X'0421', 10, _utf32 X'010000');
>+SELECT a, pad, b, LPAD(a, pad, b), HEX(LPAD(a, pad, b)) FROM t1;
>+a	pad	b	LPAD(a, pad, b)	HEX(LPAD(a, pad, b))
>+Р	10	С	СССССССССР	2104210421042104210421042104210421042004
>+Р	10	СТ	СТСТСТСТСР	2104220421042204210422042104220421042004
>+Р	10	СТУ	СТУСТУСТУР	2104220423042104220423042104220423042004
>+РСТУФХЦЧШЩ	10	СТУ	РСТУФХЦЧШЩ	2004210422042304240425042604270428042904
>+?	10	С	ССССССССС?	21042104210421042104210421042104210400D800DC
>+С	10	?	?????????С	00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC2104

Monty:
Is the last line with '?' right
Note that for test cases, it may sometimes be better to just output
the HEX part.

Result files with 'wrong' letters will sooner or later cause a problem
when someone tries to edit the file for fixing a test result case as
the editor may 'scramble some characters.

>+DROP TABLE t1;
>+CREATE TABLE t1 SELECT
>+LPAD(_utf16le X'2004',10,_utf16le X'2104') l,
>+RPAD(_utf16le X'2004',10,_utf16le X'2104') r;
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `l` varchar(10) CHARACTER SET utf16le NOT NULL DEFAULT '',
>+  `r` varchar(10) CHARACTER SET utf16le NOT NULL DEFAULT ''
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+SELECT HEX(l), HEX(r) FROM t1;
>+HEX(l)	HEX(r)
>+2104210421042104210421042104210421042004	2004210421042104210421042104210421042104
>+DROP TABLE t1;
>+CREATE TABLE t1 (f1 CHAR(30));
>+INSERT INTO t1 VALUES ("103000"), ("22720000"), ("3401200"), ("78000");
>+SELECT LPAD(f1, 12, "-o-/") FROM t1;
>+LPAD(f1, 12, "-o-/")
>+-o-/-o103000
>+-o-/22720000
>+-o-/-3401200
>+-o-/-o-78000
>+DROP TABLE t1;
>+#
>+# Testing LIKE
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+select @@collation_connection;
>+@@collation_connection
>+utf16le_general_ci
>+create table t1 as select repeat(' ',10) as a union select null;
>+alter table t1 add key(a);
>+show create table t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` varchar(10) CHARACTER SET utf16le DEFAULT NULL,
>+  KEY `a` (`a`)
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
>+explain select * from t1 where a like 'abc%';
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	range	a	a	43	NULL	1	Using where; Using index
>+explain select * from t1 where a like concat('abc','%');
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	range	a	a	43	NULL	1	Using where; Using index
>+select * from t1 where a like "abc%";
>+a
>+abc
>+abcd
>+select * from t1 where a like concat("abc","%");
>+a
>+abc
>+abcd
>+select * from t1 where a like "ABC%";
>+a
>+abc
>+abcd
>+select * from t1 where a like "test%";
>+a
>+test
>+select * from t1 where a like "te_t";
>+a
>+test
>+select * from t1 where a like "%a%";
>+a
>+a
>+abc
>+abcd
>+select * from t1 where a like "%abcd%";
>+a
>+abcd
>+select * from t1 where a like "%abc\d%";
>+a
>+abcd
>+drop table t1;
>+select 'AA' like 'AA';
>+'AA' like 'AA'
>+1
>+select 'AA' like 'A%A';
>+'AA' like 'A%A'
>+1
>+select 'AA' like 'A%%A';
>+'AA' like 'A%%A'
>+1
>+select 'AA' like 'AA%';
>+'AA' like 'AA%'
>+1
>+select 'AA' like '%AA%';
>+'AA' like '%AA%'
>+1
>+select 'AA' like '%A';
>+'AA' like '%A'
>+1
>+select 'AA' like '%AA';
>+'AA' like '%AA'
>+1
>+select 'AA' like 'A%A%';
>+'AA' like 'A%A%'
>+1
>+select 'AA' like '_%_%';
>+'AA' like '_%_%'
>+1
>+select 'AA' like '%A%A';
>+'AA' like '%A%A'
>+1
>+select 'AAA'like 'A%A%A';
>+'AAA'like 'A%A%A'
>+1
>+select 'AZ' like 'AZ';
>+'AZ' like 'AZ'
>+1
>+select 'AZ' like 'A%Z';
>+'AZ' like 'A%Z'
>+1
>+select 'AZ' like 'A%%Z';
>+'AZ' like 'A%%Z'
>+1
>+select 'AZ' like 'AZ%';
>+'AZ' like 'AZ%'
>+1
>+select 'AZ' like '%AZ%';
>+'AZ' like '%AZ%'
>+1
>+select 'AZ' like '%Z';
>+'AZ' like '%Z'
>+1
>+select 'AZ' like '%AZ';
>+'AZ' like '%AZ'
>+1
>+select 'AZ' like 'A%Z%';
>+'AZ' like 'A%Z%'
>+1
>+select 'AZ' like '_%_%';
>+'AZ' like '_%_%'
>+1
>+select 'AZ' like '%A%Z';
>+'AZ' like '%A%Z'
>+1
>+select 'AZ' like 'A_';
>+'AZ' like 'A_'
>+1
>+select 'AZ' like '_Z';
>+'AZ' like '_Z'
>+1
>+select 'AMZ'like 'A%M%Z';
>+'AMZ'like 'A%M%Z'
>+1
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА');
>+INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж');
>+INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж');
>+INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ');
>+SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a;
>+a
>+ФЫВА
>+ФЫВАПРОЛДЖ
>+Фыва
>+Фывапролдж
>+фЫва
>+фЫвапролдж
>+фыВа
>+фыВапролдж
>+фывА
>+фывАпролдж
>+фыва
>+фываПролдж
>+фывапРолдж
>+фывапрОлдж
>+фывапроЛдж
>+фывапролДж
>+фывапролдЖ
>+фывапролдж
>+SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a;
>+a
>+ФЫВА
>+ФЫВАПРОЛДЖ
>+Фыва
>+Фывапролдж
>+фЫва
>+фЫвапролдж
>+фыВа
>+фыВапролдж
>+фывА
>+фывАпролдж
>+фыва
>+фываПролдж
>+фывапРолдж
>+фывапрОлдж
>+фывапроЛдж
>+фывапролДж
>+фывапролдЖ
>+фывапролдж
>+SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a;
>+a
>+ФЫВА
>+ФЫВАПРОЛДЖ
>+Фыва
>+Фывапролдж
>+фЫва
>+фЫвапролдж
>+фыВа
>+фыВапролдж
>+фывА
>+фывАпролдж
>+фыва
>+фываПролдж
>+фывапРолдж
>+фывапрОлдж
>+фывапроЛдж
>+фывапролДж
>+фывапролдЖ
>+фывапролдж
>+SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16le_bin ORDER BY BINARY a;
>+a
>+фЫва
>+фЫвапролдж
>+DROP TABLE t1;
>+CREATE TABLE t1 (word VARCHAR(64) NOT NULL, PRIMARY KEY (word))
>+ENGINE=MyISAM CHARACTER SET utf16le;
>+INSERT INTO t1 (word) VALUES ("cat");
>+SELECT * FROM t1 WHERE word LIKE "c%";
>+word
>+cat
>+SELECT * FROM t1 WHERE word LIKE "ca_";
>+word
>+cat
>+SELECT * FROM t1 WHERE word LIKE "cat";
>+word
>+cat
>+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';
>+word
>+cat
>+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
>+word
>+cat
>+DROP TABLE t1;
>+#
>+# Check that INSERT() works fine.
>+# This invokes charpos() function.
>+#
>+CREATE TABLE t1 (
>+a VARCHAR(10) CHARACTER SET utf16le,
>+b VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ('abc', 'def');
>+SELECT INSERT(a, 10, 2, b) FROM t1;
>+INSERT(a, 10, 2, b)
>+abc
>+SELECT INSERT(a, 1, 2, b) FROM t1;
>+INSERT(a, 1, 2, b)
>+defc
>+DROP TABLE t1;
>+#
>+# Bug#1264
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+#
>+# Two fields, index
>+#
>+CREATE TABLE t1 (
>+word VARCHAR(64),
>+bar INT(11) DEFAULT 0,
>+PRIMARY KEY (word))
>+ENGINE=MyISAM
>+CHARSET utf16le
>+COLLATE utf16le_general_ci ;
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a");
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY word;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
>+SELECT * FROM t1 ORDER BY word;
>+word	bar
>+a	0
>+aar	0
>+aardvar	0
>+aardvara	0
>+aardvark	0
>+aardvarz	0
>+EXPLAIN SELECT word FROM t1 ORDER BY word;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	index	NULL	PRIMARY	258	NULL	6	Using index
>+SELECT word FROM t1 ORDER by word;
>+word
>+a
>+aar
>+aardvar
>+aardvara
>+aardvark
>+aardvarz
>+DROP TABLE t1;
>+#
>+# One field, index
>+#
>+CREATE TABLE t1 (
>+word VARCHAR(64) ,
>+PRIMARY KEY (word))
>+ENGINE=MyISAM
>+CHARSET utf16le
>+COLLATE utf16le_general_ci;
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a");
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	index	NULL	PRIMARY	258	NULL	6	Using index
>+SELECT * FROM t1 ORDER BY word;
>+word
>+a
>+aar
>+aardvar
>+aardvara
>+aardvark
>+aardvarz
>+DROP TABLE t1;
>+#
>+# Two fields, no index
>+#
>+CREATE TABLE t1 (
>+word TEXT,
>+bar INT(11) AUTO_INCREMENT,
>+PRIMARY KEY (bar))
>+ENGINE=MyISAM
>+CHARSET utf16le
>+COLLATE utf16le_general_ci ;
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a" );
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY word;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
>+SELECT * FROM t1 ORDER BY word;
>+word	bar
>+a	2
>+aar	1
>+aardvar	3
>+aardvara	5
>+aardvark	4
>+aardvarz	6
>+EXPLAIN SELECT word FROM t1 ORDER BY word;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using filesort
>+SELECT word FROM t1 ORDER BY word;
>+word
>+a
>+aar
>+aardvar
>+aardvara
>+aardvark
>+aardvarz
>+DROP TABLE t1;
>+#
>+# END OF Bug 1264 test
>+#
>+#
>+# Check alignment for from-binary-conversion with CAST and CONVERT
>+#
>+SELECT HEX(CAST(0xAA as char CHARACTER SET utf16le));
>+HEX(CAST(0xAA as char CHARACTER SET utf16le))
>+00AA
>+SELECT HEX(CONVERT(0xAA USING utf16le));
>+HEX(CONVERT(0xAA USING utf16le))
>+00AA
>+#
>+# Check alignment for string types
>+#
>+CREATE TABLE t1 (a CHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+0001
>+0011
>+0111
>+1111
>+00011111
>+DROP TABLE t1;
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+0001
>+0011
>+0111
>+1111
>+00011111
>+DROP TABLE t1;
>+CREATE TABLE t1 (a TEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+0001
>+0011
>+0111
>+1111
>+00011111
>+DROP TABLE t1;
>+CREATE TABLE t1 (a MEDIUMTEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+0001
>+0011
>+0111
>+1111
>+00011111
>+DROP TABLE t1;
>+CREATE TABLE t1 (a LONGTEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+0001
>+0011
>+0111
>+1111
>+00011111
>+DROP TABLE t1;
>+#
>+# Bug#5081 : UCS2 fields are filled with '0x2020'
>+# after extending field length
>+#
>+CREATE TABLE t1(a CHAR(1)) DEFAULT CHARSET utf16le;
>+INSERT INTO t1 VALUES ('a'),('b'),('c');
>+ALTER TABLE t1 MODIFY a CHAR(5);
>+SELECT a, HEX(a) FROM t1;
>+a	HEX(a)
>+a	6100
>+b	6200
>+c	6300
>+DROP TABLE t1;
>+#
>+# Check prepare statement from an UTF16 string
>+#
>+SET NAMES latin1;
>+SET @ivar= 1234;
>+SET @str1 = 'SELECT ?';
>+SET @str2 = CONVERT(@str1 USING utf16le);
>+PREPARE stmt1 FROM @str2;
>+EXECUTE stmt1 USING @ivar;
>+?
>+1234
>+#
>+# Check that utf16le works with ENUM and SET type
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+CREATE TABLE t1 (a ENUM('x','y','z') CHARACTER SET utf16le);
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` enum('x','y','z') CHARACTER SET utf16le DEFAULT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES ('x');
>+INSERT INTO t1 VALUES ('y');
>+INSERT INTO t1 VALUES ('z');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+a	HEX(a)
>+x	7800
>+y	7900
>+z	7A00
>+ALTER TABLE t1 CHANGE a a ENUM('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16le;
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` enum('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16le DEFAULT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES ('D');
>+INSERT INTO t1 VALUES ('E ');
>+INSERT INTO t1 VALUES ('ä');
>+INSERT INTO t1 VALUES ('ö');
>+INSERT INTO t1 VALUES ('ü');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+a	HEX(a)
>+x	7800
>+y	7900
>+z	7A00
>+d	6400
>+e	6500
>+ä	E400
>+ö	F600
>+ü	FC00
>+DROP TABLE t1;
>+CREATE TABLE t1 (a set ('x','y','z','ä','ö','ü') CHARACTER SET utf16le);
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` set('x','y','z','ä','ö','ü') CHARACTER SET utf16le DEFAULT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES ('x');
>+INSERT INTO t1 VALUES ('y');
>+INSERT INTO t1 VALUES ('z');
>+INSERT INTO t1 VALUES ('x,y');
>+INSERT INTO t1 VALUES ('x,y,z,ä,ö,ü');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+a	HEX(a)
>+x	7800
>+y	7900
>+x,y	78002C007900
>+z	7A00
>+x,y,z,ä,ö,ü	78002C0079002C007A002C00E4002C00F6002C00FC00
>+DROP TABLE t1;
>+#
>+# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
>+#
>+CREATE TABLE t1(a ENUM('a','b','c')) DEFAULT CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES('a'),('b'),('c');
>+ALTER TABLE t1 ADD b CHAR(1);
>+SHOW WARNINGS;
>+Level	Code	Message
>+SELECT * FROM t1 ORDER BY a;
>+a	b
>+a	NULL
>+b	NULL
>+c	NULL
>+DROP TABLE t1;
>+SET NAMES utf8, collation_connection='utf16le_general_ci';
>+create table t1 select repeat('a',4000) a;
>+delete from t1;
>+insert into t1 values ('a'), ('a '), ('a\t');
>+select collation(a),hex(a) from t1 order by a;
>+collation(a)	hex(a)
>+utf16le_general_ci	61000900
>+utf16le_general_ci	6100
>+utf16le_general_ci	61002000
>+drop table t1;
>+select @@collation_connection;
>+@@collation_connection
>+utf16le_general_ci
>+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
>+insert into t1 values('abcdef');
>+insert into t1 values('_bcdef');
>+insert into t1 values('a_cdef');
>+insert into t1 values('ab_def');
>+insert into t1 values('abc_ef');
>+insert into t1 values('abcd_f');
>+insert into t1 values('abcde_');
>+select c1 as c1u from t1 where c1 like 'ab\_def';
>+c1u
>+ab_def
>+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
>+c2h
>+ab_def
>+drop table t1;
>+SET NAMES utf8, collation_connection='utf16le_bin';
>+create table t1 select repeat('a',4000) a;
>+delete from t1;
>+insert into t1 values ('a'), ('a '), ('a\t');
>+select collation(a),hex(a) from t1 order by a;
>+collation(a)	hex(a)
>+utf16le_bin	61000900
>+utf16le_bin	6100
>+utf16le_bin	61002000
>+drop table t1;
>+#
>+# Bug#55980 Character sets: supplementary character _bin ordering is wrong
>+#
>+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a LIMIT 0;
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` varchar(1) CHARACTER SET utf16le COLLATE utf16le_bin NOT NULL DEFAULT ''
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES (_utf8mb4 0xEFBE9D),(_utf8mb4 0xF0908E84);
>+INSERT INTO t1 VALUES (_utf8mb4 0xCE85),(_utf8mb4 0xF4808080);
>+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
>+HEX(a)	HEX(CONVERT(a USING utf8mb4))
>+8503	CE85
>+9DFF	EFBE9D
>+00D884DF	F0908E84
>+C0DB00DC	F4808080
>+ALTER TABLE t1 ADD KEY(a);
>+SELECT HEX(a), HEX(CONVERT(a USING utf8mb4)) FROM t1 ORDER BY a;
>+HEX(a)	HEX(CONVERT(a USING utf8mb4))
>+8503	CE85
>+9DFF	EFBE9D
>+00D884DF	F0908E84
>+C0DB00DC	F4808080
>+DROP TABLE IF EXISTS t1;
>+select @@collation_connection;
>+@@collation_connection
>+utf16le_bin
>+create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ;
>+insert into t1 values('abcdef');
>+insert into t1 values('_bcdef');
>+insert into t1 values('a_cdef');
>+insert into t1 values('ab_def');
>+insert into t1 values('abc_ef');
>+insert into t1 values('abcd_f');
>+insert into t1 values('abcde_');
>+select c1 as c1u from t1 where c1 like 'ab\_def';
>+c1u
>+ab_def
>+select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
>+c2h
>+ab_def
>+drop table t1;
>+#
>+# Bug#10344 Some string functions fail for UCS2
>+#
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le, pos INT);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,1);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,2);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,3);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-1);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-2);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-3);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 1);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 2);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 3);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -1);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -2);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -3);
>+SELECT HEX(SUBSTR(a, pos)), SUBSTR(a, pos) FROM t1;
>+HEX(SUBSTR(a, pos))	SUBSTR(a, pos)
>+E400E5006800	äåh
>+E5006800	åh
>+6800	h
>+6800	h
>+E5006800	åh
>+E400E5006800	äåh
>+E400E50000D800DC	äå?
>+E50000D800DC	å?
>+00D800DC	?
>+00D800DC	?
>+E50000D800DC	å?
>+E400E50000D800DC	äå?
>+DROP TABLE t1;
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+#
>+# Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2
>+#
>+CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ("lily");
>+INSERT INTO t1 VALUES ("river");
>+PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?';
>+SET @param1='%%';
>+EXECUTE stmt USING @param1;
>+utext
>+lily
>+river
>+EXECUTE stmt USING @param1;
>+utext
>+lily
>+river
>+SELECT utext FROM t1 where utext like '%%';
>+utext
>+lily
>+river
>+DROP TABLE t1;
>+DEALLOCATE PREPARE stmt;
>+#
>+# Bug#22052 Trailing spaces are not removed FROM UNICODE fields in an index
>+#
>+CREATE TABLE t1 (
>+a CHAR(10) CHARACTER SET utf16le NOT NULL,
>+INDEX a (a)
>+) engine=myisam;
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x201f, 10));
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x2020, 10));
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x2021, 10));
>+# make sure "index read" is used
>+explain SELECT HEX(a) FROM t1 ORDER BY a;
>+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
>+1	SIMPLE	t1	index	NULL	a	40	NULL	3	Using index
>+SELECT HEX(a) FROM t1 ORDER BY a;
>+HEX(a)
>+1F201F201F201F201F201F201F201F201F201F20
>+2020202020202020202020202020202020202020
>+2120212021202120212021202120212021202120
>+ALTER TABLE t1 DROP INDEX a;
>+SELECT HEX(a) FROM t1 ORDER BY a;
>+HEX(a)
>+1F201F201F201F201F201F201F201F201F201F20
>+2020202020202020202020202020202020202020
>+2120212021202120212021202120212021202120
>+DROP TABLE t1;
>+#
>+# Bug #20108: corrupted default enum value for a ucs2 field
>+#
>+CREATE TABLE t1 (
>+status ENUM('active','passive') CHARACTER SET utf16le COLLATE utf16le_general_ci
>+NOT NULL DEFAULT 'passive'
>+);
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `status` enum('active','passive') CHARACTER SET utf16le NOT NULL DEFAULT 'passive'
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+ALTER TABLE t1 ADD a int NOT NULL AFTER status;
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `status` enum('active','passive') CHARACTER SET utf16le NOT NULL DEFAULT 'passive',
>+  `a` int(11) NOT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+DROP TABLE t1;
>+#
>+# Conversion FROM an UTF16LE string to a decimal column
>+#
>+CREATE TABLE t1 (a VARCHAR(64) CHARACTER SET utf16le, b DECIMAL(10,3));
>+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
>+UPDATE t1 set b=a;
>+SELECT *, HEX(a) FROM t1;
>+a	b	HEX(a)
>+1.1	1.100	31002E003100
>+2.1	2.100	32002E003100
>+DROP TABLE t1;
>+#
>+# Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2
>+#
>+CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ("lily");
>+INSERT INTO t1 VALUES ("river");
>+PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?';
>+SET @param1='%%';
>+EXECUTE stmt USING @param1;
>+utext
>+lily
>+river
>+EXECUTE stmt USING @param1;
>+utext
>+lily
>+river
>+SELECT utext FROM t1 where utext like '%%';
>+utext
>+lily
>+river
>+DROP TABLE t1;
>+DEALLOCATE PREPARE stmt;
>+#
>+# Bug#22638 SOUNDEX broken for international characters
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT SOUNDEX(''),SOUNDEX('he'),SOUNDEX('hello all folks'),SOUNDEX('#3556 in bugdb');
>+SOUNDEX('')	SOUNDEX('he')	SOUNDEX('hello all folks')	SOUNDEX('#3556 in bugdb')
>+	H000	H4142	I51231
>+SELECT HEX(SOUNDEX('')),HEX(SOUNDEX('he')),HEX(SOUNDEX('hello all folks')),HEX(SOUNDEX('#3556 in bugdb'));
>+HEX(SOUNDEX(''))	HEX(SOUNDEX('he'))	HEX(SOUNDEX('hello all folks'))	HEX(SOUNDEX('#3556 in bugdb'))
>+	4800300030003000	48003400310034003200	490035003100320033003100
>+SELECT 'mood' sounds like 'mud';
>+'mood' sounds like 'mud'
>+1
>+# Cyrillic A, BE, VE
>+SELECT HEX(SOUNDEX(_utf16le 0x041004110412));
>+HEX(SOUNDEX(_utf16le 0x041004110412))
>+0410300030003000
>+# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
>+SELECT HEX(SOUNDEX(_utf16le 0x00BF00C0));
>+HEX(SOUNDEX(_utf16le 0x00BF00C0))
>+00BF300030003000
>+#
>+# Bug#14290: character_maximum_length for text fields
>+#
>+CREATE TABLE t1(a BLOB, b TEXT CHARSET utf16le);
>+SELECT data_type, character_octet_length, character_maximum_length
>+FROM information_schema.columns where table_name='t1';
>+data_type	character_octet_length	character_maximum_length
>+blob	65535	65535
>+text	65535	32767
>+DROP TABLE t1;
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+#
>+# Testing cs->coll->instr()
>+#
>+SELECT POSITION('bb' IN 'abba');
>+POSITION('bb' IN 'abba')
>+2
>+#
>+# Testing cs->coll->hash_sort()
>+#
>+SET NAMES utf8, collation_connection=utf16le_bin;
>+SELECT @@collation_connection;
>+@@collation_connection
>+utf16le_bin
>+CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0;
>+ALTER TABLE t1 ADD KEY (a);
>+CREATE TABLE t2 (a VARCHAR(10));
>+INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
>+INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
>+INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1;
>+DROP TABLE t2;
>+INSERT INTO t1 VALUES ('a ');
>+SELECT a, HEX(a) FROM t1 WHERE a='a';
>+a	HEX(a)
>+a 	61002000
>+DROP TABLE t1;
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT @@collation_connection;
>+@@collation_connection
>+utf16le_general_ci
>+CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0;
>+ALTER TABLE t1 ADD KEY (a);
>+CREATE TABLE t2 (a VARCHAR(10));
>+INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
>+INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
>+INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1;
>+DROP TABLE t2;
>+INSERT INTO t1 VALUES ('a ');
>+SELECT a, HEX(a) FROM t1 WHERE a='a';
>+a	HEX(a)
>+a 	61002000
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->numchars()
>+#
>+SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd');
>+CHAR_LENGTH('abcd')	OCTET_LENGTH('abcd')
>+4	8
>+SELECT CHAR_LENGTH(_utf16le 0x00D800DC), OCTET_LENGTH(_utf16le 0x00D800DC);
>+CHAR_LENGTH(_utf16le 0x00D800DC)	OCTET_LENGTH(_utf16le 0x00D800DC)
>+1	4
>+SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF);
>+CHAR_LENGTH(_utf16le 0x7DD8FFDF)	OCTET_LENGTH(_utf16le 0x7FD8DDDF)
>+1	4
>+#
>+# Testing cs->cset->charpos()
>+#
>+SELECT LEFT('abcd',2);
>+LEFT('abcd',2)
>+ab
>+SELECT HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1));
>+HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1))
>+00D800DC
>+SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1));
>+HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1))
>+7FD8FFDF
>+#
>+# Testing cs->cset->well_formed_length()
>+#
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+# Bad sequences
>+INSERT INTO t1 VALUES (_utf16le 0x00D8);
>+ERROR HY000: Invalid utf16le character string: '00D8'
>+INSERT INTO t1 VALUES (_utf16le 0x00DC);
>+ERROR HY000: Invalid utf16le character string: '00DC'
>+INSERT INTO t1 VALUES (_utf16le 0x00D800D8);
>+ERROR HY000: Invalid utf16le character string: '00D800'
>+INSERT INTO t1 VALUES (_utf16le 0x00D800E8);
>+ERROR HY000: Invalid utf16le character string: '00D800'
>+INSERT INTO t1 VALUES (_utf16le 0x00D80008);
>+ERROR HY000: Invalid utf16le character string: '00D800'
>+# Good sequences
>+INSERT INTO t1 VALUES (_utf16le 0x00D800DC);
>+INSERT INTO t1 VALUES (_utf16le 0x00D8FFDC);
>+INSERT INTO t1 VALUES (_utf16le 0xFFDB00DC);
>+INSERT INTO t1 VALUES (_utf16le 0xFFDBFFDC);
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+00D800DC
>+00D8FFDC
>+FFDB00DC
>+FFDBFFDC
>+DROP TABLE t1;
>+#
>+# Bug#32393 Character sets: illegal characters in utf16le columns
>+#
>+# Tests that cs->cset->wc_mb() doesn't accept surrogate parts
>+#
>+# via ALTER
>+#
>+CREATE TABLE t1 (s1 VARCHAR(50) CHARACTER SET ucs2);
>+INSERT INTO t1 VALUES (0xDF84);
>+ALTER TABLE t1 MODIFY column s1 VARCHAR(50) CHARACTER SET utf16le;
>+Warnings:
>+Warning	1366	Incorrect string value: '\xDF\x84' for column 's1' at row 1
>+SELECT HEX(s1) FROM t1;
>+HEX(s1)
>+3F00
>+DROP TABLE t1;
>+#
>+# via UPDATE
>+#
>+CREATE TABLE t1 (s1 VARCHAR(5) CHARACTER SET ucs2, s2 VARCHAR(5) CHARACTER SET utf16le);
>+INSERT INTO t1 (s1) VALUES (0xdf84);
>+UPDATE t1 set s2 = s1;
>+Warnings:
>+Warning	1366	Incorrect string value: '\xDF\x84' for column 's2' at row 1
>+SELECT HEX(s2) FROM t1;
>+HEX(s2)
>+3F00
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->lengthsp()
>+#
>+CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES ('a   ');
>+SELECT HEX(a) FROM t1;
>+HEX(a)
>+6100
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->caseup() and cs->cset->casedn()
>+#
>+SELECT UPPER('abcd'), LOWER('ABCD');
>+UPPER('abcd')	LOWER('ABCD')
>+ABCD	abcd
>+#
>+# Checking str_to_datetime()
>+#
>+select @@collation_connection;
>+@@collation_connection
>+utf16le_general_ci
>+CREATE TABLE t1 (a date);
>+INSERT INTO t1 VALUES ('2007-09-16');
>+SELECT * FROM t1;
>+a
>+2007-09-16
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->ll10tostr
>+#
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (123456);
>+SELECT a, HEX(a) FROM t1;
>+a	HEX(a)
>+123456	310032003300340035003600
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->fill
>+# SOUNDEX fills strings with DIGIT ZERO up to four characters
>+#
>+SELECT SOUNDEX('a'), HEX(SOUNDEX('a'));
>+SOUNDEX('a')	HEX(SOUNDEX('a'))
>+A000	4100300030003000
>+#
>+# Testing cs->cset->strntoul
>+#
>+CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES ('1');
>+SELECT * FROM t1;
>+a
>+a
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->strntoll and cs->cset->strntoull
>+#
>+SET NAMES latin1;
>+SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16));
>+HEX(CONV(CONVERT('123' USING utf16le), -10, 16))
>+3742
>+SELECT HEX(CONV(CONVERT('123' USING utf16le), 10, 16));
>+HEX(CONV(CONVERT('123' USING utf16le), 10, 16))
>+3742
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+#
>+# Testing cs->cset->strntod
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT 1.1 + '1.2';
>+1.1 + '1.2'
>+2.3
>+SELECT 1.1 + '1.2xxx';
>+1.1 + '1.2xxx'
>+2.3
>+Warnings:
>+Warning	1292	Truncated incorrect DOUBLE value: '1.2xxx'
>+#
>+# Testing cs->cset->strtoll10
>+#
>+SELECT LEFT('aaa','1');
>+LEFT('aaa','1')
>+a
>+CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a;
>+SELECT LEFT(a, '2') FROM t1;
>+LEFT(a, '2')
>+ab
>+SELECT LEFT(a, ' \t \t 2') FROM t1;
>+LEFT(a, ' \t \t 2')
>+ab
>+SELECT LEFT(a, ' \t \t +2') FROM t1;
>+LEFT(a, ' \t \t +2')
>+ab
>+SELECT SUBSTR(a, '-2') FROM t1;
>+SUBSTR(a, '-2')
>+cd
>+SELECT SUBSTR(a, ' \t \t -2') FROM t1;
>+SUBSTR(a, ' \t \t -2')
>+cd
>+SELECT LEFT(a, '00002') FROM t1;
>+LEFT(a, '00002')
>+ab
>+SELECT LEFT(a, ' \t \t 00002') FROM t1;
>+LEFT(a, ' \t \t 00002')
>+ab
>+SELECT LEFT(a, ' \t \t +00002') FROM t1;
>+LEFT(a, ' \t \t +00002')
>+ab
>+SELECT SUBSTR(a, '-00002') FROM t1;
>+SUBSTR(a, '-00002')
>+cd
>+SELECT SUBSTR(a, ' \t \t -00002') FROM t1;
>+SUBSTR(a, ' \t \t -00002')
>+cd
>+DROP TABLE t1;
>+CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a LIMIT 0;
>+INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'),
>+('1099511627775'),('281474976710655'),('72057594037927935'),
>+('1844674407370955161'),('18446744073709551614'), ('18446744073709551615');
>+SELECT a, CAST(a AS SIGNED), CAST(a AS UNSIGNED) FROM t1;
>+a	CAST(a AS SIGNED)	CAST(a AS UNSIGNED)
>+255	255	255
>+65535	65535	65535
>+16777215	16777215	16777215
>+4294967295	4294967295	4294967295
>+1099511627775	1099511627775	1099511627775
>+281474976710655	281474976710655	281474976710655
>+72057594037927935	72057594037927935	72057594037927935
>+1844674407370955161	1844674407370955161	1844674407370955161
>+18446744073709551614	-2	18446744073709551614
>+18446744073709551615	-1	18446744073709551615
>+Warnings:
>+Note	1105	Cast to signed converted positive out-of-range integer to it's negative complement
>+Note	1105	Cast to signed converted positive out-of-range integer to it's negative complement
>+UPDATE t1 SET a=CONCAT('-', a);
>+SELECT a, CAST(a AS SIGNED) FROM t1;
>+a	CAST(a AS SIGNED)
>+-255	-255
>+-65535	-65535
>+-16777215	-16777215
>+-4294967295	-4294967295
>+-1099511627775	-1099511627775
>+-281474976710655	-281474976710655
>+-72057594037927935	-72057594037927935
>+-1844674407370955161	-1844674407370955161
>+-18446744073709551614	-9223372036854775808
>+-18446744073709551615	-9223372036854775808
>+Warnings:
>+Warning	1292	Truncated incorrect INTEGER value: '-18446744073709551614'
>+Warning	1292	Truncated incorrect INTEGER value: '-18446744073709551615'
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->strntoull10rnd
>+#
>+CREATE TABLE t1 (a int);
>+INSERT INTO t1 VALUES ('-1234.1e2');
>+INSERT INTO t1 VALUES ('-1234.1e2xxxx');
>+Warnings:
>+Warning	1265	Data truncated for column 'a' at row 1
>+INSERT INTO t1 VALUES ('-1234.1e2    ');
>+INSERT INTO t1 VALUES ('123');
>+INSERT INTO t1 VALUES ('-124');
>+INSERT INTO t1 VALUES ('+125');
>+INSERT INTO t1 VALUES (' \t \t 123');
>+INSERT INTO t1 VALUES (' \t \t -124');
>+INSERT INTO t1 VALUES (' \t \t +125');
>+INSERT INTO t1 VALUES (' \t \t 000123');
>+INSERT INTO t1 VALUES (' \t \t -000124');
>+INSERT INTO t1 VALUES (' \t \t +000125');
>+SELECT * FROM t1;
>+a
>+-123410
>+-123410
>+-123410
>+123
>+-124
>+125
>+123
>+-124
>+125
>+123
>+-124
>+125
>+DROP TABLE t1;
>+CREATE TABLE t1 (a BIGINT UNSIGNED);
>+INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'),
>+('1099511627775'),('281474976710655'),('72057594037927935'),
>+('1844674407370955161'),('18446744073709551614'), ('18446744073709551615');
>+SELECT * FROM t1;
>+a
>+255
>+65535
>+16777215
>+4294967295
>+1099511627775
>+281474976710655
>+72057594037927935
>+1844674407370955161
>+18446744073709551614
>+18446744073709551615
>+DROP TABLE t1;
>+#
>+# Testing cs->cset->scan
>+#
>+CREATE TABLE t1 (a int);
>+INSERT INTO t1 VALUES ('1 ');
>+INSERT INTO t1 VALUES ('1 x');
>+Warnings:
>+Warning	1265	Data truncated for column 'a' at row 1
>+SELECT * FROM t1;
>+a
>+1
>+1
>+DROP TABLE t1;
>+#
>+# Testing auto-conversion to TEXT
>+#
>+CREATE TABLE t1 (a VARCHAR(17000) CHARACTER SET utf16le);
>+Warnings:
>+Note	1246	Converting column 'a' from VARCHAR to TEXT
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` mediumtext CHARACTER SET utf16le
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+DROP TABLE t1;
>+#
>+# Testing that maximim possible key length is 1000 bytes
>+#
>+CREATE TABLE t1 (a VARCHAR(250) CHARACTER SET utf16le PRIMARY KEY);
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `a` varchar(250) CHARACTER SET utf16le NOT NULL,
>+  PRIMARY KEY (`a`)
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+DROP TABLE t1;
>+CREATE TABLE t1 (a VARCHAR(334) CHARACTER SET utf16le PRIMARY KEY);
>+ERROR 42000: Specified key was too long; max key length is 1000 bytes
>+#
>+# Conversion to utf8
>+#
>+CREATE TABLE t1 (a CHAR(1) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x00D800DC),(0x00D8FFDC),(0x7FDB00DC),(0x7FDBFFDC);
>+INSERT INTO t1 VALUES (0xC000), (0xFF00),(0x00E0), (0xFFFF);
>+SELECT HEX(a), HEX(@a:=CONVERT(a USING utf8mb4)), HEX(CONVERT(@a USING utf16le)) FROM t1;
>+HEX(a)	HEX(@a:=CONVERT(a USING utf8mb4))	HEX(CONVERT(@a USING utf16le))
>+00D800DC	F0908080	00D800DC
>+00D8FFDC	F09083BF	00D8FFDC
>+7FDB00DC	F3AFB080	7FDB00DC
>+7FDBFFDC	F3AFB3BF	7FDBFFDC
>+C000	C380	C000
>+FF00	C3BF	FF00
>+00E0	EE8080	00E0
>+FFFF	EFBFBF	FFFF
>+DROP TABLE t1;
>+#
>+# Test basic regex functionality
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+drop table if exists t1;
>+create table t1 as
>+select repeat(' ', 64) as s1, repeat(' ',64) as s2
>+union
>+select null, null;
>+show create table t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `s1` varchar(64) CHARACTER SET utf16le DEFAULT NULL,
>+  `s2` varchar(64) CHARACTER SET utf16le DEFAULT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+delete from t1;
>+insert into t1 values('aaa','aaa');
>+insert into t1 values('aaa|qqq','qqq');
>+insert into t1 values('gheis','^[^a-dXYZ]+$');
>+insert into t1 values('aab','^aa?b');
>+insert into t1 values('Baaan','^Ba*n');
>+insert into t1 values('aaa','qqq|aaa');
>+insert into t1 values('qqq','qqq|aaa');
>+insert into t1 values('bbb','qqq|aaa');
>+insert into t1 values('bbb','qqq');
>+insert into t1 values('aaa','aba');
>+insert into t1 values(null,'abc');
>+insert into t1 values('def',null);
>+insert into t1 values(null,null);
>+insert into t1 values('ghi','ghi[');
>+select HIGH_PRIORITY s1 regexp s2 from t1;
>+s1 regexp s2
>+0
>+0
>+0
>+1
>+1
>+1
>+1
>+1
>+1
>+1
>+NULL
>+NULL
>+NULL
>+NULL
>+drop table t1;
>+#
>+# Test how CHARACTER SET works with date/time
>+#
>+CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
>+SET timestamp=1216359724;
>+INSERT INTO t1 VALUES (current_date);
>+INSERT INTO t1 VALUES (current_time);
>+INSERT INTO t1 VALUES (current_timestamp);
>+SELECT s1, hex(s1) FROM t1;
>+s1	hex(s1)
>+2008-07-18	32003000300038002D00300037002D0031003800
>+08:42:04	300038003A00340032003A0030003400
>+2008-07-18 08:42:04	32003000300038002D00300037002D00310038002000300038003A00340032003A0030003400
>+DROP TABLE t1;
>+SET timestamp=0;
>+#
>+# Bug#33073 Character sets: ordering fails with utf32
>+#
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0;
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `s1` varchar(2) CHARACTER SET utf16le NOT NULL DEFAULT ''
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
>+SELECT * FROM t1 ORDER BY s1;
>+s1
>+ab
>+ab
>+AE
>+AE
>+SET max_sort_length=4;
>+SELECT * FROM t1 ORDER BY s1;
>+s1
>+ab
>+ab
>+AE
>+AE
>+DROP TABLE t1;
>+SET max_sort_length=DEFAULT;
>+#
>+# Bug#52520 Difference in tinytext utf column metadata
>+#
>+CREATE TABLE t1 (
>+s1 TINYTEXT CHARACTER SET utf16le,
>+s2 TEXT CHARACTER SET utf16le,
>+s3 MEDIUMTEXT CHARACTER SET utf16le,
>+s4 LONGTEXT CHARACTER SET utf16le
>+);
>+SET NAMES utf8, @@character_set_results=NULL;
>+SELECT *, HEX(s1) FROM t1;
>+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
>+def	test	t1	t1	s1	s1	252	255	0	Y	16	0	56
>+def	test	t1	t1	s2	s2	252	65535	0	Y	16	0	56
>+def	test	t1	t1	s3	s3	252	16777215	0	Y	16	0	56
>+def	test	t1	t1	s4	s4	252	4294967295	0	Y	16	0	56
>+def					HEX(s1)	253	6120	0	Y	0	0	33
>+s1	s2	s3	s4	HEX(s1)
>+SET NAMES latin1;
>+SELECT *, HEX(s1) FROM t1;
>+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
>+def	test	t1	t1	s1	s1	252	127	0	Y	16	0	8
>+def	test	t1	t1	s2	s2	252	32767	0	Y	16	0	8
>+def	test	t1	t1	s3	s3	252	8388607	0	Y	16	0	8
>+def	test	t1	t1	s4	s4	252	2147483647	0	Y	16	0	8
>+def					HEX(s1)	253	2040	0	Y	0	0	8
>+s1	s2	s3	s4	HEX(s1)
>+SET NAMES utf8;
>+SELECT *, HEX(s1) FROM t1;
>+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
>+def	test	t1	t1	s1	s1	252	381	0	Y	16	0	33
>+def	test	t1	t1	s2	s2	252	98301	0	Y	16	0	33
>+def	test	t1	t1	s3	s3	252	25165821	0	Y	16	0	33
>+def	test	t1	t1	s4	s4	252	4294967295	0	Y	16	0	33
>+def					HEX(s1)	253	6120	0	Y	0	0	33
>+s1	s2	s3	s4	HEX(s1)
>+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
>+SHOW CREATE TABLE t2;
>+Table	Create Table
>+t2	CREATE TABLE `t2` (
>+  `CONCAT(s1)` varchar(255) CHARACTER SET utf16le DEFAULT NULL
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+DROP TABLE t1, t2;
>+#
>+# Problem found by Roy during review
>+# MY_CS_BINSORT was not set for utf16le_bin,
>+# so filesort did not work well
>+# 
>+SET NAMES utf8, @@collation_connection=utf16le_bin;
>+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) as c LIMIT 0;
>+ALTER TABLE t1 ADD PRIMARY KEY(c);
>+SHOW CREATE TABLE t1;
>+Table	Create Table
>+t1	CREATE TABLE `t1` (
>+  `c` varchar(10) CHARACTER SET utf16le COLLATE utf16le_bin NOT NULL DEFAULT '',
>+  PRIMARY KEY (`c`)
>+) ENGINE=MyISAM DEFAULT CHARSET=latin1
>+INSERT INTO t1 VALUES ('abc'),('zyx'),('acb');
>+SELECT UPPER(c) FROM t1 ORDER BY 1 DESC;
>+UPPER(c)
>+ZYX
>+ACB
>+ABC
>+DROP TABLE t1;
>+#
>+# End of 5.6 tests
>+#
>
>=== modified file 'mysql-test/r/ctype_utf32.result'
>--- mysql-test/r/ctype_utf32.result	2012-08-09 16:25:47 +0000
>+++ mysql-test/r/ctype_utf32.result	2013-03-15 04:53:03 +0000
>@@ -1126,6 +1126,20 @@
> 00
> DROP TABLE t1;
> #
>+# Bug#32859 Character sets: no warning with non-fitting chariot wheel
>+#
>+CREATE TABLE t1 (utf32 CHAR(5) CHARACTER SET utf32, latin1 CHAR(5) CHARACTER SET latin1);
>+INSERT INTO t1 (utf32) VALUES (0xc581);
>+UPDATE t1 SET latin1 = utf32;
>+Warnings:
>+Warning	1366	Incorrect string value: '\x00\x00\xC5\x81' for column 'latin1' at row 1
>+DELETE FROM t1;
>+INSERT INTO t1 (utf32) VALUES (0x100cc);
>+UPDATE t1 SET latin1 = utf32;
>+Warnings:
>+Warning	1366	Incorrect string value: '\x00\x01\x00\xCC' for column 'latin1' at row 1
>+DROP TABLE t1;
>+#
> # Bug#55912 FORMAT with locale set fails for numbers < 1000
> #
> SET collation_connection=utf32_general_ci;
>
>=== modified file 'mysql-test/suite/funcs_1/r/innodb_func_view.result'
>--- mysql-test/suite/funcs_1/r/innodb_func_view.result	2012-09-08 10:15:55 +0000
>+++ mysql-test/suite/funcs_1/r/innodb_func_view.result	2013-03-15 05:14:48 +0000
>@@ -2675,7 +2675,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2692,7 +2692,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2709,10 +2709,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2727,10 +2727,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2749,7 +2749,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2766,7 +2766,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2785,7 +2785,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2802,7 +2802,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -3041,7 +3041,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as signed) AS `CAST(my_varbinary_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3057,7 +3057,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3073,10 +3073,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_binary_30` as signed) AS `CAST(my_binary_30 AS SIGNED INTEGER)`,`t1_values`.`my_binary_30` AS `my_binary_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3090,10 +3090,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> DROP VIEW v1;
> 
> 
>@@ -3111,7 +3111,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as signed) AS `CAST(my_varchar_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3127,7 +3127,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3145,7 +3145,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_char_30` as signed) AS `CAST(my_char_30 AS SIGNED INTEGER)`,`t1_values`.`my_char_30` AS `my_char_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3161,7 +3161,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> DROP VIEW v1;
> 
> 
>
>=== modified file 'mysql-test/suite/funcs_1/r/memory_func_view.result'
>--- mysql-test/suite/funcs_1/r/memory_func_view.result	2012-09-08 10:15:55 +0000
>+++ mysql-test/suite/funcs_1/r/memory_func_view.result	2013-03-15 05:15:06 +0000
>@@ -2676,7 +2676,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2693,7 +2693,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2710,10 +2710,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2728,10 +2728,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2750,7 +2750,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2767,7 +2767,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2786,7 +2786,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2803,7 +2803,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -3042,7 +3042,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as signed) AS `CAST(my_varbinary_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3058,7 +3058,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3074,10 +3074,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_binary_30` as signed) AS `CAST(my_binary_30 AS SIGNED INTEGER)`,`t1_values`.`my_binary_30` AS `my_binary_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3091,10 +3091,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> DROP VIEW v1;
> 
> 
>@@ -3112,7 +3112,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as signed) AS `CAST(my_varchar_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3128,7 +3128,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3146,7 +3146,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_char_30` as signed) AS `CAST(my_char_30 AS SIGNED INTEGER)`,`t1_values`.`my_char_30` AS `my_char_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3162,7 +3162,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> DROP VIEW v1;
> 
> 
>
>=== modified file 'mysql-test/suite/funcs_1/r/myisam_func_view.result'
>--- mysql-test/suite/funcs_1/r/myisam_func_view.result	2012-09-08 10:15:55 +0000
>+++ mysql-test/suite/funcs_1/r/myisam_func_view.result	2013-03-15 05:15:27 +0000
>@@ -2676,7 +2676,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2693,7 +2693,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2710,10 +2710,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2728,10 +2728,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> 18446744073709551615	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2750,7 +2750,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2767,7 +2767,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -2786,7 +2786,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
>@@ -2803,7 +2803,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> Note	1105	Cast to unsigned converted negative integer to it's positive complement
> DROP VIEW v1;
> 
>@@ -3042,7 +3042,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varbinary_1000` as signed) AS `CAST(my_varbinary_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varbinary_1000` AS `my_varbinary_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3058,7 +3058,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3074,10 +3074,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_binary_30` as signed) AS `CAST(my_binary_30 AS SIGNED INTEGER)`,`t1_values`.`my_binary_30` AS `my_binary_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3091,10 +3091,10 @@
> 0	 ---äÖüß@µ*$-- 	4
> -1	-1	5
> Warnings:
>-Warning	1292	Truncated incorrect INTEGER value: ''
>+Warning	1292	Truncated incorrect INTEGER value: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>-Warning	1292	Truncated incorrect INTEGER value: '-1'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$-- \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>+Warning	1292	Truncated incorrect INTEGER value: '-1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
> DROP VIEW v1;
> 
> 
>@@ -3112,7 +3112,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_varchar_1000` as signed) AS `CAST(my_varchar_1000 AS SIGNED INTEGER)`,`t1_values`.`my_varchar_1000` AS `my_varchar_1000`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3128,7 +3128,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<---------1000 characters-------------------------------------------------------------------------------------------------------'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$-- '
> DROP VIEW v1;
> 
> 
>@@ -3146,7 +3146,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> SHOW CREATE VIEW v1;
> View	Create View	character_set_client	collation_connection
> v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_char_30` as signed) AS `CAST(my_char_30 AS SIGNED INTEGER)`,`t1_values`.`my_char_30` AS `my_char_30`,`t1_values`.`id` AS `id` from `t1_values`	latin1	latin1_swedish_ci
>@@ -3162,7 +3162,7 @@
> Warnings:
> Warning	1292	Truncated incorrect INTEGER value: ''
> Warning	1292	Truncated incorrect INTEGER value: '<--------30 characters------->'
>-Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
>+Warning	1292	Truncated incorrect INTEGER value: ' ---äÖüß@µ*$--'
> DROP VIEW v1;
> 
> 
>
>=== modified file 'mysql-test/suite/sys_vars/r/character_set_client_basic.result'
>--- mysql-test/suite/sys_vars/r/character_set_client_basic.result	2011-12-12 22:58:40 +0000
>+++ mysql-test/suite/sys_vars/r/character_set_client_basic.result	2013-03-15 05:18:54 +0000
>@@ -430,7 +430,7 @@
> SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS);
> SELECT @total_charset;
> @total_charset
>-39
>+40
> '#--------------------FN_DYNVARS_010_10-------------------------#'
> SET @@character_set_client = abc;
> ERROR 42000: Unknown character set: 'abc'
>
>=== modified file 'mysql-test/suite/sys_vars/r/character_set_connection_basic.result'
>--- mysql-test/suite/sys_vars/r/character_set_connection_basic.result	2011-12-12 22:58:40 +0000
>+++ mysql-test/suite/sys_vars/r/character_set_connection_basic.result	2013-03-15 05:19:08 +0000
>@@ -424,7 +424,7 @@
> SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS);
> SELECT @total_charset;
> @total_charset
>-39
>+40
> '#--------------------FN_DYNVARS_011_10-------------------------#'
> SET @@character_set_connection = abc;
> ERROR 42000: Unknown character set: 'abc'
>
>=== modified file 'mysql-test/suite/sys_vars/r/character_set_database_basic.result'
>--- mysql-test/suite/sys_vars/r/character_set_database_basic.result	2011-12-12 22:58:40 +0000
>+++ mysql-test/suite/sys_vars/r/character_set_database_basic.result	2013-03-15 05:19:20 +0000
>@@ -424,7 +424,7 @@
> SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS);
> SELECT @total_charset;
> @total_charset
>-39
>+40
> '#--------------------FN_DYNVARS_012_10-------------------------#'
> SET @@character_set_database = "grek";
> ERROR 42000: Unknown character set: 'grek'
>
>=== modified file 'mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result'
>--- mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result	2011-12-12 22:58:40 +0000
>+++ mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result	2013-03-15 05:19:32 +0000
>@@ -402,7 +402,7 @@
> SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS);
> SELECT @total_charset;
> @total_charset
>-39
>+40
> '#--------------------FN_DYNVARS_008_10-------------------------#'
> SET @@character_set_filesystem = abc;
> ERROR 42000: Unknown character set: 'abc'
>
>=== modified file 'mysql-test/suite/sys_vars/r/character_set_results_basic.result'
>--- mysql-test/suite/sys_vars/r/character_set_results_basic.result	2011-12-12 22:58:40 +0000
>+++ mysql-test/suite/sys_vars/r/character_set_results_basic.result	2013-03-15 05:19:46 +0000
>@@ -424,7 +424,7 @@
> SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS);
> SELECT @total_charset;
> @total_charset
>-39
>+40
> 'Bug # 34843: character sets are mapped in such a way that 100 and following';
> 'numbers gives error, and before 100 the 36 mapped wraps arround several times.';
> '#--------------------FN_DYNVARS_013_10-------------------------#'
>
>=== modified file 'mysql-test/t/ctype_ucs.test'
>--- mysql-test/t/ctype_ucs.test	2013-01-15 18:13:32 +0000
>+++ mysql-test/t/ctype_ucs.test	2013-03-15 04:05:28 +0000
>@@ -839,3 +839,20 @@
> --echo #
> --echo # End of 5.5 tests
> --echo #
>+
>+
>+--echo #
>+--echo # Start of 5.6 tests
>+--echo #
>+
>+--echo #
>+--echo # Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2
>+--echo #
>+SET NAMES latin1;
>+SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED);
>+DO IFNULL(CHAR(NULL USING ucs2), '');
>+DO CAST(CONVERT('' USING ucs2) AS UNSIGNED);
>+
>+--echo #
>+--echo # End of 5.6 tests
>+--echo #
>
>=== added file 'mysql-test/t/ctype_utf16le.test'
>--- mysql-test/t/ctype_utf16le.test	1970-01-01 00:00:00 +0000
>+++ mysql-test/t/ctype_utf16le.test	2013-03-14 15:03:57 +0000
>@@ -0,0 +1,729 @@
>+-- source include/have_ucs2.inc
>+-- source include/have_utf16.inc
>+-- source include/have_utf32.inc
>+-- source include/have_utf8mb4.inc
>+
>+
>+SET TIME_ZONE='+03:00';
>+
>+--disable_warnings
>+DROP TABLE IF EXISTS t1;
>+--enable_warnings
>+
>+--echo #
>+--echo # Start of 5.6 tests
>+--echo #
>+
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT HEX('a'), HEX('a ');
>+-- source include/endspace.inc
>+
>+
>+--echo #
>+--echo # Check that incomplete utf16le characters in HEX notation
>+--echo # are left-padded with zeros
>+--echo #
>+SELECT HEX(_utf16le 0x44);
>+SELECT HEX(_utf16le 0x3344);
>+SELECT HEX(_utf16le 0x113344);
>+
>+--echo #
>+--echo # Check that 0x20 is only trimmed when it is
>+--echo # a part of real SPACE character, not just a part
>+--echo # of a multibyte sequence.
>+--echo # Note, CYRILLIC LETTER ER is used as an example, which
>+--echo # is stored as 0x0420 in utf16le, thus contains 0x20 in the
>+--echo # low byte. The second character is THREE-PER-M, U+2004,
>+--echo # which contains 0x20 in the high byte.
>+--echo #
>+
>+CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (_ucs2 X'2004',_ucs2 X'2004');
>+SELECT HEX(word) FROM t1 ORDER BY word;
>+SELECT HEX(word2) FROM t1 ORDER BY word2;
>+DELETE FROM t1;
>+
>+--echo #
>+--echo # Check that real spaces are correctly trimmed.
>+--echo #
>+INSERT INTO t1 VALUES (_ucs2 X'042000200020', _ucs2 X'042000200020');
>+INSERT INTO t1 VALUES (_ucs2 X'200400200020', _ucs2 X'200400200020');
>+SELECT HEX(word) FROM t1 ORDER BY word;
>+SELECT HEX(word2) FROM t1 ORDER BY word2;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Check LPAD/RPAD
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(10), pad INT, b VARCHAR(10)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'0421');
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'04210422');
>+INSERT INTO t1 VALUES (_ucs2 X'0420', 10, _ucs2 X'042104220423');
>+INSERT INTO t1 VALUES (_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
>+INSERT INTO t1 VALUES (_utf32 X'010000', 10, _ucs2 X'0421');
>+INSERT INTO t1 VALUES (_ucs2 X'0421', 10, _utf32 X'010000');
>+SELECT a, pad, b, LPAD(a, pad, b), HEX(LPAD(a, pad, b)) FROM t1;
>+DROP TABLE t1;
>+
>+
>+CREATE TABLE t1 SELECT
>+LPAD(_utf16le X'2004',10,_utf16le X'2104') l,
>+RPAD(_utf16le X'2004',10,_utf16le X'2104') r;
>+SHOW CREATE TABLE t1;
>+SELECT HEX(l), HEX(r) FROM t1;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (f1 CHAR(30));
>+INSERT INTO t1 VALUES ("103000"), ("22720000"), ("3401200"), ("78000");
>+SELECT LPAD(f1, 12, "-o-/") FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Testing LIKE
>+--echo #
>+
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+--source include/ctype_like.inc
>+
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывА'),('ФЫВА');
>+INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж');
>+INSERT INTO t1 VALUES ('фывАпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж');
>+INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВАПРОЛДЖ');
>+SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a;
>+SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a;
>+SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a;
>+SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16le_bin ORDER BY BINARY a;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (word VARCHAR(64) NOT NULL, PRIMARY KEY (word))
>+ENGINE=MyISAM CHARACTER SET utf16le;
>+INSERT INTO t1 (word) VALUES ("cat");
>+SELECT * FROM t1 WHERE word LIKE "c%";
>+SELECT * FROM t1 WHERE word LIKE "ca_";
>+SELECT * FROM t1 WHERE word LIKE "cat";
>+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';     # "c%"
>+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F'; # "ca_"
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Check that INSERT() works fine.
>+--echo # This invokes charpos() function.
>+--echo #
>+CREATE TABLE t1 (
>+  a VARCHAR(10) CHARACTER SET utf16le,
>+  b VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ('abc', 'def');
>+SELECT INSERT(a, 10, 2, b) FROM t1;
>+SELECT INSERT(a, 1, 2, b) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Bug#1264
>+--echo #
>+# Description:
>+#
>+# When USING a ucs2 TABLE in MySQL,
>+# either with ucs2_general_ci or ucs2_bin collation,
>+# words are returned in an incorrect order when USING ORDER BY
>+# on an _indexed_ CHAR or VARCHAR column. They are sorted with
>+# the longest word *first* instead of last. I.E. The word "aardvark"
>+# is in the results before the word "a".
>+#
>+# If there is no index for the column, the problem does not occur.
>+#
>+# Interestingly, if there is no second column, the words are returned
>+# in the correct order.
>+#
>+# According to EXPLAIN, it looks like when the output includes columns that
>+# are not part of the index sorted on, it does a filesort, which fails.
>+# Using a straight index yields correct results.
>+
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+
>+--echo #
>+--echo # Two fields, index
>+--echo #
>+
>+CREATE TABLE t1 (
>+   word VARCHAR(64),
>+   bar INT(11) DEFAULT 0,
>+   PRIMARY KEY (word))
>+   ENGINE=MyISAM
>+   CHARSET utf16le
>+   COLLATE utf16le_general_ci ;
>+
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a");
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY word;
>+SELECT * FROM t1 ORDER BY word;
>+EXPLAIN SELECT word FROM t1 ORDER BY word;
>+SELECT word FROM t1 ORDER by word;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # One field, index
>+--echo #
>+
>+CREATE TABLE t1 (
>+   word VARCHAR(64) ,
>+   PRIMARY KEY (word))
>+   ENGINE=MyISAM
>+   CHARSET utf16le
>+   COLLATE utf16le_general_ci;
>+
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a");
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
>+SELECT * FROM t1 ORDER BY word;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Two fields, no index
>+--echo #
>+
>+CREATE TABLE t1 (
>+   word TEXT,
>+   bar INT(11) AUTO_INCREMENT,
>+   PRIMARY KEY (bar))
>+   ENGINE=MyISAM
>+   CHARSET utf16le
>+   COLLATE utf16le_general_ci ;
>+INSERT INTO t1 (word) VALUES ("aar");
>+INSERT INTO t1 (word) VALUES ("a" );
>+INSERT INTO t1 (word) VALUES ("aardvar");
>+INSERT INTO t1 (word) VALUES ("aardvark");
>+INSERT INTO t1 (word) VALUES ("aardvara");
>+INSERT INTO t1 (word) VALUES ("aardvarz");
>+EXPLAIN SELECT * FROM t1 ORDER BY word;
>+SELECT * FROM t1 ORDER BY word;
>+EXPLAIN SELECT word FROM t1 ORDER BY word;
>+SELECT word FROM t1 ORDER BY word;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # END OF Bug 1264 test
>+--echo #
>+
>+
>+--echo #
>+--echo # Check alignment for from-binary-conversion with CAST and CONVERT
>+--echo #
>+SELECT HEX(CAST(0xAA as char CHARACTER SET utf16le));
>+SELECT HEX(CONVERT(0xAA USING utf16le));
>+
>+--echo #
>+--echo # Check alignment for string types
>+--echo #
>+CREATE TABLE t1 (a CHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (a TEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (a MEDIUMTEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (a LONGTEXT CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Bug#5081 : UCS2 fields are filled with '0x2020'
>+--echo # after extending field length
>+--echo #
>+
>+CREATE TABLE t1(a CHAR(1)) DEFAULT CHARSET utf16le;
>+INSERT INTO t1 VALUES ('a'),('b'),('c');
>+ALTER TABLE t1 MODIFY a CHAR(5);
>+SELECT a, HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Check prepare statement from an UTF16 string
>+--echo #
>+SET NAMES latin1;
>+SET @ivar= 1234;
>+SET @str1 = 'SELECT ?';
>+SET @str2 = CONVERT(@str1 USING utf16le);
>+PREPARE stmt1 FROM @str2;
>+EXECUTE stmt1 USING @ivar;
>+
>+--echo #
>+--echo # Check that utf16le works with ENUM and SET type
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+CREATE TABLE t1 (a ENUM('x','y','z') CHARACTER SET utf16le);
>+SHOW CREATE TABLE t1;
>+INSERT INTO t1 VALUES ('x');
>+INSERT INTO t1 VALUES ('y');
>+INSERT INTO t1 VALUES ('z');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+ALTER TABLE t1 CHANGE a a ENUM('x','y','z','d','e','ä','ö','ü') CHARACTER SET utf16le;
>+SHOW CREATE TABLE t1;
>+INSERT INTO t1 VALUES ('D');
>+INSERT INTO t1 VALUES ('E ');
>+INSERT INTO t1 VALUES ('ä');
>+INSERT INTO t1 VALUES ('ö');
>+INSERT INTO t1 VALUES ('ü');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+DROP TABLE t1;
>+
>+CREATE TABLE t1 (a set ('x','y','z','ä','ö','ü') CHARACTER SET utf16le);
>+SHOW CREATE TABLE t1;
>+INSERT INTO t1 VALUES ('x');
>+INSERT INTO t1 VALUES ('y');
>+INSERT INTO t1 VALUES ('z');
>+INSERT INTO t1 VALUES ('x,y');
>+INSERT INTO t1 VALUES ('x,y,z,ä,ö,ü');
>+SELECT a, HEX(a) FROM t1 ORDER BY a;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
>+--echo #
>+CREATE TABLE t1(a ENUM('a','b','c')) DEFAULT CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES('a'),('b'),('c');
>+ALTER TABLE t1 ADD b CHAR(1);
>+SHOW WARNINGS;
>+SELECT * FROM t1 ORDER BY a;
>+DROP TABLE t1;
>+
>+SET NAMES utf8, collation_connection='utf16le_general_ci';
>+-- source include/ctype_filesort.inc
>+-- source include/ctype_like_escape.inc
>+SET NAMES utf8, collation_connection='utf16le_bin';
>+-- source include/ctype_filesort.inc
>+-- source include/ctype_filesort2.inc
>+-- source include/ctype_like_escape.inc
>+
>+--echo #
>+--echo # Bug#10344 Some string functions fail for UCS2
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le, pos INT);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,1);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,2);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,3);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-1);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-2);
>+INSERT INTO t1 VALUES (_ucs2 0x00e400e50068,-3);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 1);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 2);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, 3);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -1);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -2);
>+INSERT INTO t1 VALUES (_utf32 0x000000e4000000e500010000, -3);
>+SELECT HEX(SUBSTR(a, pos)), SUBSTR(a, pos) FROM t1;
>+DROP TABLE t1;
>+
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+
>+--echo #
>+--echo # Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2
>+--echo #
>+CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ("lily");
>+INSERT INTO t1 VALUES ("river");
>+PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?';
>+SET @param1='%%';
>+EXECUTE stmt USING @param1;
>+EXECUTE stmt USING @param1;
>+SELECT utext FROM t1 where utext like '%%';
>+DROP TABLE t1;
>+DEALLOCATE PREPARE stmt;
>+
>+--echo #
>+--echo # Bug#22052 Trailing spaces are not removed FROM UNICODE fields in an index
>+--echo #
>+CREATE TABLE t1 (
>+  a CHAR(10) CHARACTER SET utf16le NOT NULL,
>+  INDEX a (a)
>+) engine=myisam;
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x201f, 10));
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x2020, 10));
>+INSERT INTO t1 VALUES (REPEAT(_ucs2 0x2021, 10));
>+--echo # make sure "index read" is used
>+explain SELECT HEX(a) FROM t1 ORDER BY a;
>+SELECT HEX(a) FROM t1 ORDER BY a;
>+ALTER TABLE t1 DROP INDEX a;
>+SELECT HEX(a) FROM t1 ORDER BY a;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Bug #20108: corrupted default enum value for a ucs2 field
>+--echo #
>+CREATE TABLE t1 (
>+  status ENUM('active','passive') CHARACTER SET utf16le COLLATE utf16le_general_ci
>+    NOT NULL DEFAULT 'passive'
>+);
>+SHOW CREATE TABLE t1;
>+ALTER TABLE t1 ADD a int NOT NULL AFTER status;
>+SHOW CREATE TABLE t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Conversion FROM an UTF16LE string to a decimal column
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(64) CHARACTER SET utf16le, b DECIMAL(10,3));
>+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
>+UPDATE t1 set b=a;
>+SELECT *, HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Bug#9442 Set parameter make query fail if column CHARACTER SET is UCS2
>+--echo #
>+CREATE TABLE t1 (utext VARCHAR(20) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES ("lily");
>+INSERT INTO t1 VALUES ("river");
>+PREPARE stmt FROM 'SELECT utext FROM t1 where utext like ?';
>+SET @param1='%%';
>+EXECUTE stmt USING @param1;
>+EXECUTE stmt USING @param1;
>+SELECT utext FROM t1 where utext like '%%';
>+DROP TABLE t1;
>+DEALLOCATE PREPARE stmt;
>+
>+--echo #
>+--echo # Bug#22638 SOUNDEX broken for international characters
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT SOUNDEX(''),SOUNDEX('he'),SOUNDEX('hello all folks'),SOUNDEX('#3556 in bugdb');
>+SELECT HEX(SOUNDEX('')),HEX(SOUNDEX('he')),HEX(SOUNDEX('hello all folks')),HEX(SOUNDEX('#3556 in bugdb'));
>+SELECT 'mood' sounds like 'mud';
>+--echo # Cyrillic A, BE, VE
>+SELECT HEX(SOUNDEX(_utf16le 0x041004110412));
>+--echo # Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
>+SELECT HEX(SOUNDEX(_utf16le 0x00BF00C0));
>+
>+--echo #
>+--echo # Bug#14290: character_maximum_length for text fields
>+--echo #
>+CREATE TABLE t1(a BLOB, b TEXT CHARSET utf16le);
>+SELECT data_type, character_octet_length, character_maximum_length
>+  FROM information_schema.columns where table_name='t1';
>+DROP TABLE t1;
>+
>+
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+
>+--echo #
>+--echo # Testing cs->coll->instr()
>+--echo #
>+SELECT POSITION('bb' IN 'abba');
>+
>+--echo #
>+--echo # Testing cs->coll->hash_sort()
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_bin;
>+--source include/ctype_heap.inc
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+--source include/ctype_heap.inc
>+
>+--echo #
>+--echo # Testing cs->cset->numchars()
>+--echo #
>+SELECT CHAR_LENGTH('abcd'), OCTET_LENGTH('abcd');
>+SELECT CHAR_LENGTH(_utf16le 0x00D800DC), OCTET_LENGTH(_utf16le 0x00D800DC);
>+SELECT CHAR_LENGTH(_utf16le 0x7DD8FFDF), OCTET_LENGTH(_utf16le 0x7FD8DDDF);
>+
>+--echo #
>+--echo # Testing cs->cset->charpos()
>+--echo #
>+SELECT LEFT('abcd',2);
>+SELECT HEX(LEFT(_utf16le 0x00D800DC7FD8FFDF, 1));
>+SELECT HEX(RIGHT(_utf16le 0x00D800DC7FD8FFDF, 1));
>+
>+--echo #
>+--echo # Testing cs->cset->well_formed_length()
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+--echo # Bad sequences
>+--error ER_INVALID_CHARACTER_STRING
>+INSERT INTO t1 VALUES (_utf16le 0x00D8);
>+--error ER_INVALID_CHARACTER_STRING
>+INSERT INTO t1 VALUES (_utf16le 0x00DC);
>+--error ER_INVALID_CHARACTER_STRING
>+INSERT INTO t1 VALUES (_utf16le 0x00D800D8);
>+--error ER_INVALID_CHARACTER_STRING
>+INSERT INTO t1 VALUES (_utf16le 0x00D800E8);
>+--error ER_INVALID_CHARACTER_STRING
>+INSERT INTO t1 VALUES (_utf16le 0x00D80008);
>+--echo # Good sequences
>+INSERT INTO t1 VALUES (_utf16le 0x00D800DC);
>+INSERT INTO t1 VALUES (_utf16le 0x00D8FFDC);
>+INSERT INTO t1 VALUES (_utf16le 0xFFDB00DC);
>+INSERT INTO t1 VALUES (_utf16le 0xFFDBFFDC);
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Bug#32393 Character sets: illegal characters in utf16le columns
>+--echo #
>+--echo # Tests that cs->cset->wc_mb() doesn't accept surrogate parts
>+--echo #
>+--echo # via ALTER
>+--echo #
>+CREATE TABLE t1 (s1 VARCHAR(50) CHARACTER SET ucs2);
>+INSERT INTO t1 VALUES (0xDF84);
>+ALTER TABLE t1 MODIFY column s1 VARCHAR(50) CHARACTER SET utf16le;
>+SELECT HEX(s1) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # via UPDATE
>+--echo #
>+CREATE TABLE t1 (s1 VARCHAR(5) CHARACTER SET ucs2, s2 VARCHAR(5) CHARACTER SET utf16le);
>+INSERT INTO t1 (s1) VALUES (0xdf84);
>+UPDATE t1 set s2 = s1;
>+SELECT HEX(s2) FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->lengthsp()
>+--echo #
>+CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES ('a   ');
>+SELECT HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->caseup() and cs->cset->casedn()
>+--echo #
>+SELECT UPPER('abcd'), LOWER('ABCD');
>+
>+--echo #
>+--echo # Checking str_to_datetime()
>+--echo #
>+select @@collation_connection;
>+CREATE TABLE t1 (a date);
>+INSERT INTO t1 VALUES ('2007-09-16');
>+SELECT * FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->ll10tostr
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (123456);
>+SELECT a, HEX(a) FROM t1;
>+DROP TABLE t1;
>+
>+--echo #
>+--echo # Testing cs->cset->fill
>+--echo # SOUNDEX fills strings with DIGIT ZERO up to four characters
>+--echo #
>+SELECT SOUNDEX('a'), HEX(SOUNDEX('a'));
>+
>+
>+--echo #
>+--echo # Testing cs->cset->strntoul
>+--echo #
>+CREATE TABLE t1 (a enum ('a','b','c')) CHARACTER SET utf16le;
>+INSERT INTO t1 VALUES ('1');
>+SELECT * FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->strntoll and cs->cset->strntoull
>+--echo #
>+SET NAMES latin1;
>+SELECT HEX(CONV(CONVERT('123' USING utf16le), -10, 16));
>+SELECT HEX(CONV(CONVERT('123' USING utf16le), 10, 16));
>+SET NAMES utf8, collation_connection=utf16le_general_ci;

Monty:
You have here two idenitcal SET NAMES in a row.

>+
>+
>+--echo #
>+--echo # Testing cs->cset->strntod
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+SELECT 1.1 + '1.2';
>+SELECT 1.1 + '1.2xxx';
>+
>+
>+--echo #
>+--echo # Testing cs->cset->strtoll10
>+--echo #
>+SELECT LEFT('aaa','1');
>+CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a;
>+SELECT LEFT(a, '2') FROM t1;
>+SELECT LEFT(a, ' \t \t 2') FROM t1;
>+SELECT LEFT(a, ' \t \t +2') FROM t1;
>+SELECT SUBSTR(a, '-2') FROM t1;
>+SELECT SUBSTR(a, ' \t \t -2') FROM t1;
>+SELECT LEFT(a, '00002') FROM t1;
>+SELECT LEFT(a, ' \t \t 00002') FROM t1;
>+SELECT LEFT(a, ' \t \t +00002') FROM t1;
>+SELECT SUBSTR(a, '-00002') FROM t1;
>+SELECT SUBSTR(a, ' \t \t -00002') FROM t1;
>+DROP TABLE t1;
>+CREATE TABLE t1 AS SELECT REPEAT('abcd', 128) AS a LIMIT 0;
>+INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'),
>+('1099511627775'),('281474976710655'),('72057594037927935'),
>+('1844674407370955161'),('18446744073709551614'), ('18446744073709551615');
>+SELECT a, CAST(a AS SIGNED), CAST(a AS UNSIGNED) FROM t1;
>+UPDATE t1 SET a=CONCAT('-', a);
>+SELECT a, CAST(a AS SIGNED) FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->strntoull10rnd
>+--echo #
>+CREATE TABLE t1 (a int);
>+INSERT INTO t1 VALUES ('-1234.1e2');
>+INSERT INTO t1 VALUES ('-1234.1e2xxxx');
>+INSERT INTO t1 VALUES ('-1234.1e2    ');
>+INSERT INTO t1 VALUES ('123');
>+INSERT INTO t1 VALUES ('-124');
>+INSERT INTO t1 VALUES ('+125');
>+INSERT INTO t1 VALUES (' \t \t 123');
>+INSERT INTO t1 VALUES (' \t \t -124');
>+INSERT INTO t1 VALUES (' \t \t +125');
>+INSERT INTO t1 VALUES (' \t \t 000123');
>+INSERT INTO t1 VALUES (' \t \t -000124');
>+INSERT INTO t1 VALUES (' \t \t +000125');
>+SELECT * FROM t1;
>+DROP TABLE t1;
>+CREATE TABLE t1 (a BIGINT UNSIGNED);
>+INSERT INTO t1 VALUES ('255'), ('65535'),('16777215'),('4294967295'),
>+('1099511627775'),('281474976710655'),('72057594037927935'),
>+('1844674407370955161'),('18446744073709551614'), ('18446744073709551615');
>+SELECT * FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing cs->cset->scan
>+--echo #
>+CREATE TABLE t1 (a int);
>+INSERT INTO t1 VALUES ('1 ');
>+INSERT INTO t1 VALUES ('1 x');
>+SELECT * FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing auto-conversion to TEXT
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(17000) CHARACTER SET utf16le);
>+SHOW CREATE TABLE t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Testing that maximim possible key length is 1000 bytes
>+--echo #
>+CREATE TABLE t1 (a VARCHAR(250) CHARACTER SET utf16le PRIMARY KEY);
>+SHOW CREATE TABLE t1;
>+DROP TABLE t1;
>+--error ER_TOO_LONG_KEY
>+CREATE TABLE t1 (a VARCHAR(334) CHARACTER SET utf16le PRIMARY KEY);
>+
>+
>+--echo #
>+--echo # Conversion to utf8
>+--echo #
>+CREATE TABLE t1 (a CHAR(1) CHARACTER SET utf16le);
>+INSERT INTO t1 VALUES (0x00D800DC),(0x00D8FFDC),(0x7FDB00DC),(0x7FDBFFDC);
>+INSERT INTO t1 VALUES (0xC000), (0xFF00),(0x00E0), (0xFFFF);
>+SELECT HEX(a), HEX(@a:=CONVERT(a USING utf8mb4)), HEX(CONVERT(@a USING utf16le)) FROM t1;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # Test basic regex functionality
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+--source include/ctype_regex.inc
>+
>+
>+--echo #
>+--echo # Test how CHARACTER SET works with date/time
>+--echo #
>+--source include/ctype_datetime.inc
>+
>+
>+--echo #
>+--echo # Bug#33073 Character sets: ordering fails with utf32
>+--echo #
>+SET NAMES utf8, collation_connection=utf16le_general_ci;
>+CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0;
>+SHOW CREATE TABLE t1;
>+INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
>+SELECT * FROM t1 ORDER BY s1;
>+SET max_sort_length=4;
>+SELECT * FROM t1 ORDER BY s1;
>+DROP TABLE t1;
>+SET max_sort_length=DEFAULT;
>+
>+
>+--echo #
>+--echo # Bug#52520 Difference in tinytext utf column metadata
>+--echo #
>+CREATE TABLE t1 (
>+  s1 TINYTEXT CHARACTER SET utf16le,
>+  s2 TEXT CHARACTER SET utf16le,
>+  s3 MEDIUMTEXT CHARACTER SET utf16le,
>+  s4 LONGTEXT CHARACTER SET utf16le
>+);
>+--enable_metadata
>+SET NAMES utf8, @@character_set_results=NULL;
>+SELECT *, HEX(s1) FROM t1;
>+SET NAMES latin1;
>+SELECT *, HEX(s1) FROM t1;
>+SET NAMES utf8;
>+SELECT *, HEX(s1) FROM t1;
>+--disable_metadata
>+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
>+SHOW CREATE TABLE t2;
>+DROP TABLE t1, t2;
>+
>+--echo #
>+--echo # Problem found by Roy during review
>+--echo # MY_CS_BINSORT was not set for utf16le_bin,
>+--echo # so filesort did not work well
>+--echo # 
>+SET NAMES utf8, @@collation_connection=utf16le_bin;
>+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) as c LIMIT 0;
>+# the problem in fact reproduced even without the primary key:
>+ALTER TABLE t1 ADD PRIMARY KEY(c);
>+SHOW CREATE TABLE t1;
>+INSERT INTO t1 VALUES ('abc'),('zyx'),('acb');
>+SELECT UPPER(c) FROM t1 ORDER BY 1 DESC;
>+DROP TABLE t1;
>+
>+
>+--echo #
>+--echo # End of 5.6 tests
>+--echo #
>
>=== modified file 'mysql-test/t/ctype_utf32.test'
>--- mysql-test/t/ctype_utf32.test	2012-08-09 16:25:47 +0000
>+++ mysql-test/t/ctype_utf32.test	2013-03-15 04:52:28 +0000
>@@ -813,6 +813,17 @@
> DROP TABLE t1;
> 
> --echo #
>+--echo # Bug#32859 Character sets: no warning with non-fitting chariot wheel
>+--echo #
>+CREATE TABLE t1 (utf32 CHAR(5) CHARACTER SET utf32, latin1 CHAR(5) CHARACTER SET latin1);
>+INSERT INTO t1 (utf32) VALUES (0xc581);
>+UPDATE t1 SET latin1 = utf32;
>+DELETE FROM t1;
>+INSERT INTO t1 (utf32) VALUES (0x100cc);
>+UPDATE t1 SET latin1 = utf32;
>+DROP TABLE t1;
>+
>+--echo #
> --echo # Bug#55912 FORMAT with locale set fails for numbers < 1000
> --echo #
> SET collation_connection=utf32_general_ci;
>
>=== modified file 'mysys/charset-def.c'
>--- mysys/charset-def.c	2012-07-31 17:29:07 +0000
>+++ mysys/charset-def.c	2013-03-14 12:43:39 +0000
>@@ -304,6 +304,8 @@
> #ifdef HAVE_CHARSET_utf16
>   add_compiled_collation(&my_charset_utf16_general_ci);
>   add_compiled_collation(&my_charset_utf16_bin);
>+  add_compiled_collation(&my_charset_utf16le_general_ci);
>+  add_compiled_collation(&my_charset_utf16le_bin);
> #ifdef HAVE_UCA_COLLATIONS
>   add_compiled_collation(&my_charset_utf16_unicode_ci);
>   add_compiled_collation(&my_charset_utf16_icelandic_uca_ci);
>
>=== modified file 'sql/item_func.cc'
>--- sql/item_func.cc	2013-01-29 14:10:47 +0000
>+++ sql/item_func.cc	2013-03-14 14:52:45 +0000
>@@ -1027,13 +1027,11 @@
>   value= cs->cset->strtoll10(cs, start, &end, error);
>   if (*error > 0 || end != start+ length)
>   {
>-    char err_buff[128];
>-    String err_tmp(err_buff,(uint32) sizeof(err_buff), system_charset_info);
>-    err_tmp.copy(start, length, system_charset_info);
>+    ErrConvString err(res);
>     push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
>                         ER_TRUNCATED_WRONG_VALUE,
>                         ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
>-                        err_tmp.c_ptr());
>+                        err.ptr());
>   }
>   return value;
> }
>

>=== modified file 'sql/sys_vars.cc'
>--- sql/sys_vars.cc	2013-02-25 23:20:17 +0000
>+++ sql/sys_vars.cc	2013-03-15 04:23:14 +0000
>@@ -385,16 +385,19 @@
>   if (var->value->result_type() == STRING_RESULT)
>   {
>     String str(buff, sizeof(buff), system_charset_info), *res;
>-    if (!(res=var->value->val_str(&str)))
>+    if (!(res= var->value->val_str(&str)))
>       var->save_result.ptr= NULL;
>-    else if (!(var->save_result.ptr= get_charset_by_csname(res->c_ptr(),
>-                                                           MY_CS_PRIMARY,
>-                                                           MYF(0))) &&
>-             !(var->save_result.ptr=get_old_charset_by_name(res->c_ptr())))
>+    else
>     {
>-      ErrConvString err(res);
>-      my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), err.ptr());
>-      return true;
>+      ErrConvString err(res); /* Get utf8 '\0' terminated string */
>+      if (!(var->save_result.ptr= get_charset_by_csname(err.ptr(),
>+                                                         MY_CS_PRIMARY,
>+                                                         MYF(0))) &&
>+          !(var->save_result.ptr= get_old_charset_by_name(err.ptr())))
>+      {
>+        my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), err.ptr());
>+        return true;
>+      }
>     }

Monty:
Please add a comment why we need to use ErrConvString instead of the
original string. (As ErrConvString should normally only be used for
errors).

I assume this is because of:

SET collation_connection=<ucs2, utf16, utf32 value>;
SET character_set_connection=<ucs2, utf16, utf32 value>;

Wouldn't it be better to have a function

String change_character_set(CHARSET_INFO *cs)

for cases like this?

(I am mostly worried someone will try to copy the above code for
things where ErrConvString is not suitable)

After all, instead of using ErrConvString() I assume one could simple have:

  char buff[256];
  String utf8(buff, sizeof(buff), system_charset_info);
  utf8.copy(res);

Which I think is probably faster and more clear than using
ErrConvString().

>   }
>   else // INT_RESULT
>@@ -505,11 +508,14 @@
>     String str(buff, sizeof(buff), system_charset_info), *res;
>     if (!(res= var->value->val_str(&str)))
>       var->save_result.ptr= NULL;
>-    else if (!(var->save_result.ptr= get_charset_by_name(res->c_ptr(), MYF(0))))
>+    else
>     {
>-      ErrConvString err(res);
>-      my_error(ER_UNKNOWN_COLLATION, MYF(0), err.ptr());
>-      return true;
>+      ErrConvString err(res); /* Get utf8 '\0'-terminated string */
>+      if (!(var->save_result.ptr= get_charset_by_name(err.ptr(), MYF(0))))
>+      {
>+        my_error(ER_UNKNOWN_COLLATION, MYF(0), err.ptr());
>+        return true;
>+      }
>     }
>   }

Monty:
same argument as above.

>   else // INT_RESULT
>
>=== modified file 'strings/ctype-latin1.c'
>--- strings/ctype-latin1.c	2013-03-12 14:33:19 +0000
>+++ strings/ctype-latin1.c	2013-03-15 04:51:34 +0000
>@@ -385,7 +385,10 @@
>   if (str >= end)
>     return MY_CS_TOOSMALL;
>   
>-  pl= uni_to_cs[(wc>>8) & 0xFF];
>+  if (wc > 0xFFFF)
>+    return MY_CS_ILUNI;
>+  
>+  pl= uni_to_cs[wc >> 8];
>   str[0]= pl ? pl[wc & 0xFF] : '\0';
>   return (!str[0] && wc) ? MY_CS_ILUNI : 1;
> }
>
>=== modified file 'strings/ctype-ucs2.c'
>--- strings/ctype-ucs2.c	2013-01-29 14:10:47 +0000
>+++ strings/ctype-ucs2.c	2013-03-15 04:27:10 +0000
>@@ -718,17 +718,30 @@
>   ulonglong li;
>   int negative;
>   ulong cutoff, cutoff2, cutoff3;
>+  my_wc_t wc;
>+  int res;
> 
>   s= nptr;
>   /* If fixed length string */
>   if (endptr)
>   {
>-    /* Make sure string length is even */
>+    /*
>+      Make sure string length is even.
>+      Odd length indicates a bug in the caller.
>+      Assert in debug, round in production.
>+    */
>+    DBUG_ASSERT((*endptr - s) % 2 == 0);
>     end= s + ((*endptr - s) / 2) * 2;
>-    while (s < end && !s[0] && (s[1] == ' ' || s[1] == '\t'))
>-      s+= 2;
>-    if (s == end)
>-      goto no_conv;
>+
>+    for ( ; ; ) /* Skip leading spaces and tabs */
>+    {
>+      res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+      if (res <= 0)
>+        goto no_conv;
>+      s+= res;
>+      if (wc != ' ' && wc != '\t')
>+        break;
>+    }
>   }
>   else
>   {
>@@ -738,13 +751,14 @@
> 
>   /* Check for a sign. */
>   negative= 0;
>-  if (!s[0] && s[1] == '-')
>+  if (wc == '-')
>   {
>     *error= -1;                                        /* Mark as negative number */
>     negative= 1;
>-    s+= 2;
>-    if (s == end)
>+    res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+    if (res < 0)
>       goto no_conv;
>+    s+= res;

Monty:
Add a comment:

/* wc should contain the first number in the code below */

It would also be nice to have a comment why we can't assume for this
code that each character is 2 bytes (like the old code assumed).
I assume it's to detect wrong characters ?

>     cutoff=  MAX_NEGATIVE_NUMBER / LFACTOR2;
>     cutoff2= (MAX_NEGATIVE_NUMBER % LFACTOR2) / 100;
>     cutoff3=  MAX_NEGATIVE_NUMBER % 100;
>@@ -752,46 +766,55 @@
>   else
>   {
>     *error= 0;
>-    if (!s[0] && s[1] == '+')
>+    if (wc == '+')
>     {
>-      s+= 2;
>-      if (s == end)
>+      res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+      if (res < 0)
>         goto no_conv;
>+      s+= res;


Monty:
Add same comment as for the earlier comment

>     }
>     cutoff=  ULONGLONG_MAX / LFACTOR2;
>     cutoff2= ULONGLONG_MAX % LFACTOR2 / 100;
>     cutoff3=  ULONGLONG_MAX % 100;
>   }
> 
>+
>   /* Handle case where we have a lot of pre-zero */
>-  if (!s[0] && s[1] == '0')
>+  if (wc == '0')
>   {
>     i= 0;
>-    do
>+    for ( ; ; s+= res)
>     {
>-      s+= 2;
>       if (s == end)
>         goto end_i;                                /* Return 0 */
>+      res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+      if (res < 0)
>+        goto no_conv;
>+      if (wc != '0')
>+        break;
>     }
>-    while (!s[0] && s[1] == '0');
>+    while (wc == '0');

Monty:
The above line is a bug (even if condition is impossible). Remove it!  
(The above code is probably wrongly left there when you converted the
do-while to a for()).

>     n_end= s + 2 * INIT_CNT;
>   }
>   else
>   {
>     /* Read first digit to check that it's a valid number */
>-    if (s[0] || (c= (s[1]-'0')) > 9)
>+    if ((c= (wc - '0')) > 9)
>       goto no_conv;
>     i= c;
>-    s+= 2;
>     n_end= s + 2 * (INIT_CNT-1);
>   }

Monty:
Above you can set 'i' directly.  No reason to use 'c'

>   /* Handle first 9 digits and store them in i */
>   if (n_end > end)
>     n_end= end;
>-  for (; s != n_end ; s+= 2)
>+  for ( ; ; )
>   {
>-    if (s[0] || (c= (s[1]-'0')) > 9)
>+    res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) n_end);
>+    if (res < 0)
>+      break;

Monty:
In general I prefer the code:

if  ((res= cs->cset->mb_wc(cs, &wc, (const uchar *) s,
                           (const uchar *) n_end) < 0)

By the way, wouldn't the code be simpler if you would change the type
of 's' and 'end' and 'n_end' to const uchar * ?

>+    s+= res;
>+    if ((c= (wc - '0')) > 9)
>       goto end_i;
>     i= i*10+c;
>   }
>@@ -806,10 +829,13 @@
>     n_end= end;
>   do
>   {
>-    if (s[0] || (c= (s[1]-'0')) > 9)
>+    res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+    if (res < 0)
>+      goto no_conv;
>+    s+= res;
>+    if ((c= (wc - '0')) > 9)
>       goto end_i_and_j;
>     j= j*10+c;
>-    s+= 2;
>   } while (s != n_end);
>   if (s == end)
>   {
>@@ -817,20 +843,28 @@
>       goto end_i_and_j;
>     goto end3;
>   }
>-  if (s[0] || (c= (s[1]-'0')) > 9)
>+  res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+  if (res < 0)
>+    goto no_conv;
>+  s+= res;
>+  if ((c= (wc - '0')) > 9)
>     goto end3;

Monty:
Here you could store directly in 'k' and remove next line

Isn't it wrong to increment 's' before going to to end3?
's' should point to the first not-number character.  Now it will point
one character past it.

Why wasn't this shown in the test cases?
Maybe because you didn't test with big numbers?

>   /* Handle the next 1 or 2 digits and store them in k */
>   k=c;
>-  s+= 2;
>-  if (s == end || s[0] || (c= (s[1]-'0')) > 9)
>+  if (s == end)
>+    goto end4;
>+  res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end);
>+  if (res < 0)
>+    goto no_conv;
>+  s+= res;
>+  if ((c= (wc - '0')) > 9)
>     goto end4;

Monty:
Isn't it wrong to increment 's' before going to to end4?
's' should point to the first not-number character.  Now it will point
one character past it.

Why wasn't this shown in the test cases?

Please check the same issue with all the other calls to
end_i, end_i_and_j, end3 and end4.

Even some of the earlier code looks not safe.

>   k= k*10+c;
>-  s+= 2;
>   *endptr= (char*) s;
> 
>   /* number string should have ended here */
>-  if (s != end && !s[0] && (c= (s[1]-'0')) <= 9)
>+  if (s != end && (c= (wc - '0')) <= 9)
>     goto overflow;
> 
>   /* Check that we didn't get an overflow with the last digit */
>@@ -882,15 +916,19 @@
>             const char *str, const char *end, int sequence_type)
> {
>   const char *str0= str;
>-  end--; /* for easier loop condition, because of two bytes per character */
>-  
>+  my_wc_t wc;
>+  int res;
>+
>   switch (sequence_type)
>   {
>   case MY_SEQ_SPACES:
>-    for ( ; str < end; str+= 2)
>+    for (res= cs->cset->mb_wc(cs, &wc,
>+                              (const uchar *) str, (const uchar *) end);
>+         res > 0 && wc == ' ';
>+         str+= res,
>+         res= cs->cset->mb_wc(cs, &wc,
>+                              (const uchar *) str, (const uchar *) end))
>     {
>-      if (str[0] != '\0' || str[1] != ' ')
>-        break;
>     }
>     return (size_t) (str - str0);
>   default:
>@@ -900,11 +938,34 @@
> 
> 
> static void
>-my_fill_mb2(CHARSET_INFO *cs __attribute__((unused)),
>-            char *s, size_t l, int fill)
>+my_fill_mb2(CHARSET_INFO *cs, char *s, size_t slen, int fill)
> {
>-  DBUG_ASSERT(fill <= 0xFFFF);
>-  for ( ; l >= 2; s[0]= (fill >> 8), s[1]= (fill & 0xFF), s+= 2, l-= 2);
>+  char buf[10];
>+  int buflen;
>+
>+  DBUG_ASSERT((slen % 2) == 0);
>+
>+  buflen= cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf,
>+                          (uchar*) buf + sizeof(buf));
>+
>+  DBUG_ASSERT(buflen > 0);
>+
>+  while (slen >= (size_t) buflen)
>+  {
>+    /* Enough space for the characer */
>+    memcpy(s, buf, (size_t) buflen);
>+    s+= buflen;
>+    slen-= buflen;
>+  }

Monty:
I generally prefer loops like:

end= s + slen;
for ( ; s < end; s+=buflen)
  memcpy(s, buf, (size_t) buflen);

Better to only have to decrement one variable instead of two.

>+
>+  /* 
>+    If there are some more space which is not enough
>+    for the whole multibyte character, then add trailing zeros.
>+  */
>+  for ( ; slen; slen--)
>+  {
>+    *s++= 0x00;
>+  }

Monty:
Use instead:

if (slen)
  bzero(s, slen);

> }
> 
> 
>@@ -1018,11 +1079,26 @@
>   DB80..DBFF - Private surrogate high     (128 pages)
>   DC00..DFFF - Surrogate low              (1024 codes in a page)
> */
>+#define MY_UTF16_SURROGATE_HIGH_FIRST 0xD800
>+#define MY_UTF16_SURROGATE_HIGH_LAST  0xDBFF
>+#define MY_UTF16_SURROGATE_LOW_FIRST  0xDC00
>+#define MY_UTF16_SURROGATE_LOW_LAST   0xDFFF
> 
> #define MY_UTF16_HIGH_HEAD(x)  ((((uchar) (x)) & 0xFC) == 0xD8)
> #define MY_UTF16_LOW_HEAD(x)   ((((uchar) (x)) & 0xFC) == 0xDC)
> #define MY_UTF16_SURROGATE(x)  (((x) & 0xF800) == 0xD800)
> 
>+#define MY_UTF16_WC2(a, b)       ((a << 8) + b)
>+
>+/*
>+  a= 110110??  (<< 18)
>+  b= ????????  (<< 10)
>+  c= 110111??  (<<  8)
>+  d= ????????  (<<  0)
>+*/
>+#define MY_UTF16_WC4(a, b, c, d) (((a & 3) << 18) + (b << 10) + \
>+                                  ((c & 3) << 8) + d + 0x10000)
>+
> static int
> my_utf16_uni(CHARSET_INFO *cs __attribute__((unused)),
>              my_wc_t *pwc, const uchar *s, const uchar *e)
>@@ -1044,23 +1120,14 @@
>     if (!MY_UTF16_LOW_HEAD(s[2]))  /* Broken surrigate pair */
>       return MY_CS_ILSEQ;
> 
>-    /*
>-      s[0]= 110110??  (<< 18)
>-      s[1]= ????????  (<< 10)
>-      s[2]= 110111??  (<<  8)
>-      s[3]= ????????  (<<  0)
>-    */ 
>-
>-    *pwc= ((s[0] & 3) << 18) + (s[1] << 10) +
>-          ((s[2] & 3) << 8) + s[3] + 0x10000;
>-
>+    *pwc= MY_UTF16_WC4(s[0], s[1], s[2], s[3]);
>     return 4;
>   }
> 
>   if (MY_UTF16_LOW_HEAD(*s)) /* Low surrogate part without high part */
>     return MY_CS_ILSEQ;
>-  
>-  *pwc= (s[0] << 8) + s[1];
>+
>+  *pwc= MY_UTF16_WC2(s[0], s[1]);
>   return 2;
> }
> 
>@@ -1141,10 +1208,10 @@
>   DBUG_ASSERT(src == dst && srclen == dstlen);
>   
>   while ((src < srcend) &&
>-         (res= my_utf16_uni(cs, &wc, (uchar *)src, (uchar*) srcend)) > 0)
>+         (res= cs->cset->mb_wc(cs, &wc, (uchar *) src, (uchar *) srcend)) > 0)
>   {
>     my_toupper_utf16(uni_plane, &wc);
>-    if (res != my_uni_utf16(cs, wc, (uchar*) src, (uchar*) srcend))
>+    if (res != cs->cset->wc_mb(cs, wc, (uchar *) src, (uchar *) srcend))
>       break;
>     src+= res;
>   }

Monty:
Check the assembler if it would make sence to store cs->cset->mb_wc in
a register.

(It probably would as the assembler can't assume that the pointer is
unchanged over calls).

This applies to all cases where you use 'cs->cset->mb_wc' in a loop.

>@@ -1158,13 +1225,11 @@
> {
>   my_wc_t wc;
>   int res;
>-  const uchar *e= s+slen;
>+  const uchar *e= s + cs->cset->lengthsp(cs, (const char *) s, slen);
>   MY_UNICASE_INFO *const *uni_plane= cs->caseinfo;
> 
>-  while (e > s + 1 && e[-1] == ' ' && e[-2] == '\0')
>-    e-= 2;
>-
>-  while ((s < e) && (res= my_utf16_uni(cs, &wc, (uchar *)s, (uchar*)e)) > 0)
>+  while ((s < e) && (res= cs->cset->mb_wc(cs, &wc,
>+                                          (uchar *) s, (uchar *) e)) > 0)
>   {
>     my_tosort_utf16(uni_plane, &wc);
>     n1[0]^= (((n1[0] & 63) + n2[0]) * (wc & 0xFF)) + (n1[0] << 8);
>@@ -1188,10 +1253,10 @@
>   DBUG_ASSERT(src == dst && srclen == dstlen);
> 
>   while ((src < srcend) &&
>-         (res= my_utf16_uni(cs, &wc, (uchar*) src, (uchar*) srcend)) > 0)
>+         (res= cs->cset->mb_wc(cs, &wc, (uchar *) src, (uchar *) srcend)) > 0)
>   {
>     my_tolower_utf16(uni_plane, &wc);
>-    if (res != my_uni_utf16(cs, wc, (uchar*) src, (uchar*) srcend))
>+    if (res != cs->cset->wc_mb(cs, wc, (uchar *) src, (uchar *) srcend))
>       break;
>     src+= res;
>   }
>@@ -1213,8 +1278,8 @@
> 
>   while (s < se && t < te)
>   {
>-    s_res= my_utf16_uni(cs, &s_wc, s, se);
>-    t_res= my_utf16_uni(cs, &t_wc, t, te);
>+    s_res= cs->cset->mb_wc(cs, &s_wc, s, se);
>+    t_res= cs->cset->mb_wc(cs, &t_wc, t, te);
> 
>     if (s_res <= 0 || t_res <= 0)
>     {
>@@ -1283,8 +1348,8 @@
> 
>   while (s < se && t < te)
>   {
>-    int s_res= my_utf16_uni(cs, &s_wc, s, se);
>-    int t_res= my_utf16_uni(cs, &t_wc, t, te);
>+    int s_res= cs->cset->mb_wc(cs, &s_wc, s, se);
>+    int t_res= cs->cset->mb_wc(cs, &t_wc, t, te);
> 
>     if (s_res <= 0 || t_res <= 0)
>     {
>@@ -1324,7 +1389,7 @@
> 
>     for ( ; s < se; s+= s_res)
>     {
>-      if ((s_res= my_utf16_uni(cs, &s_wc, s, se)) < 0)
>+      if ((s_res= cs->cset->mb_wc(cs, &s_wc, s, se)) < 0)
>       {
>         DBUG_ASSERT(0);
>         return 0;
>@@ -1338,22 +1403,11 @@
> 
> 
> static uint
>-my_ismbchar_utf16(CHARSET_INFO *cs __attribute__((unused)),
>-                  const char *b __attribute__((unused)),
>-                  const char *e __attribute__((unused)))
>+my_ismbchar_utf16(CHARSET_INFO *cs, const char *b, const char *e)
> {
>-  if (b + 2 > e)
>-    return 0;
>-  
>-  if (MY_UTF16_HIGH_HEAD(*b))
>-  {
>-    return (b + 4 <= e) && MY_UTF16_LOW_HEAD(b[2]) ? 4 : 0;
>-  }
>-  
>-  if (MY_UTF16_LOW_HEAD(*b))
>-    return 0;
>-  
>-  return 2;
>+  my_wc_t wc;
>+  int res= cs->cset->mb_wc(cs, &wc, (const uchar *) b, (const uchar *) e);
>+  return (uint) (res > 0 ? res : 0);
> }
> 
> 
>@@ -1361,6 +1415,7 @@
> my_mbcharlen_utf16(CHARSET_INFO *cs  __attribute__((unused)),
>                    uint c __attribute__((unused)))
> {
>+  DBUG_ASSERT(0);
>   return MY_UTF16_HIGH_HEAD(c) ? 4 : 2;
> }
> 
>@@ -1454,8 +1509,8 @@
> 
>   while ( s < se && t < te )
>   {
>-    s_res= my_utf16_uni(cs,&s_wc, s, se);
>-    t_res= my_utf16_uni(cs,&t_wc, t, te);
>+    s_res= cs->cset->mb_wc(cs, &s_wc, s, se);
>+    t_res= cs->cset->mb_wc(cs, &t_wc, t, te);
> 
>     if (s_res <= 0 || t_res <= 0)
>     {
>@@ -1493,8 +1548,8 @@
> 
>   while (s < se && t < te)
>   {
>-    int s_res= my_utf16_uni(cs, &s_wc, s, se);
>-    int t_res= my_utf16_uni(cs, &t_wc, t, te);
>+    int s_res= cs->cset->mb_wc(cs, &s_wc, s, se);
>+    int t_res= cs->cset->mb_wc(cs, &t_wc, t, te);
> 
>     if (s_res <= 0 || t_res <= 0)
>     {
>@@ -1531,7 +1586,7 @@
> 
>     for ( ; s < se; s+= s_res)
>     {
>-      if ((s_res= my_utf16_uni(cs, &s_wc, s, se)) < 0)
>+      if ((s_res= cs->cset->mb_wc(cs, &s_wc, s, se)) < 0)
>       {
>         DBUG_ASSERT(0);
>         return 0;
>@@ -1545,17 +1600,11 @@
> 
> 
> static void
>-my_hash_sort_utf16_bin(CHARSET_INFO *cs __attribute__((unused)),
>-                       const uchar *key, size_t len,ulong *nr1, ulong *nr2)
>+my_hash_sort_utf16_bin(CHARSET_INFO *cs,
>+                       const uchar *pos, size_t len, ulong *nr1, ulong *nr2)
> {
>-  const uchar *pos = key;
>-  
>-  key+= len;
>-
>-  while (key > pos + 1 && key[-1] == ' ' && key[-2] == '\0')
>-    key-= 2;
>-
>-  for (; pos < (uchar*) key ; pos++)
>+  const uchar *end= pos + cs->cset->lengthsp(cs, (const char *) pos, len);
>+  for ( ; pos < end ; pos++)
>   {
>     nr1[0]^= (ulong) ((((uint) nr1[0] & 63) + nr2[0]) * 
>               ((uint)*pos)) + (nr1[0] << 8);
>@@ -1664,7 +1713,7 @@
> struct charset_info_st my_charset_utf16_bin=
> {
>   55,0,0,              /* number       */
>-  MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_NONASCII,
>+  MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
>   "utf16",             /* cs name      */
>   "utf16_bin",         /* name         */
>   "UTF-16 Unicode",    /* comment      */
>@@ -1693,6 +1742,173 @@
>   &my_collation_utf16_bin_handler
> };
> 
>+
>+static int
>+my_utf16le_uni(const CHARSET_INFO *cs __attribute__((unused)),
>+               my_wc_t *pwc, const uchar *s, const uchar *e)
>+{
>+  my_wc_t lo;
>+
>+  if (s + 2 > e)
>+    return MY_CS_TOOSMALL2;
>+
>+  if ((*pwc= uint2korr(s)) < MY_UTF16_SURROGATE_HIGH_FIRST ||
>+      (*pwc > MY_UTF16_SURROGATE_LOW_LAST))
>+    return 2; /* [0000-D7FF,E000-FFFF] */
>+
>+  if (*pwc >= MY_UTF16_SURROGATE_LOW_FIRST)
>+    return MY_CS_ILSEQ; /* [DC00-DFFF] Low surrogate part without high part */
>+
>+  if (s + 4  > e)
>+    return MY_CS_TOOSMALL4;
>+
>+  s+= 2;
>+
>+  if ((lo= uint2korr(s)) < MY_UTF16_SURROGATE_LOW_FIRST ||
>+      lo > MY_UTF16_SURROGATE_LOW_LAST)
>+    return MY_CS_ILSEQ; /* Expected low surrogate part, got something else */
>+
>+  *pwc= 0x10000 + (((*pwc & 0x3FF) << 10) | (lo & 0x3FF));
>+  return 4;
>+}
>+
>+
>+static int
>+my_uni_utf16le(const CHARSET_INFO *cs __attribute__((unused)),
>+               my_wc_t wc, uchar *s, uchar *e)
>+{
>+  if (wc < MY_UTF16_SURROGATE_HIGH_FIRST ||
>+      (wc > MY_UTF16_SURROGATE_LOW_LAST &&
>+       wc <= 0xFFFF))
>+  {
>+    if (s + 2 > e)
>+      return MY_CS_TOOSMALL2;
>+    int2store(s, wc);
>+    return 2; /* [0000-D7FF,E000-FFFF] */
>+  }
>+
>+  if (wc < 0xFFFF || wc > 0x10FFFF)
>+    return MY_CS_ILUNI; /* [D800-DFFF,10FFFF+] */
>+
>+  if (s + 4 > e)
>+    return MY_CS_TOOSMALL4;
>+
>+  wc-= 0x10000;
>+  int2store(s,     (0xD800 | ((wc >> 10) & 0x3FF))); s+= 2;
>+  int2store(s,     (0xDC00 | (wc & 0x3FF)));

Monty:
Use int2store(s+2... for the second row and remove s+2.
Makes the line easier to read...

Note that as int2store is a macro, doing it this is maybe faster:

uint16 first_part, second_part;
uint32 total;
first_part=  (0xD800 | ((wc >> 10) & 0x3FF)));
second_part= (0xDC00 | (wc & 0x3FF)));
total= first_part + (second_part << 16)
int4store(s,     total);

>+  return 4; /* [010000-10FFFF] */
>+}
>+
>+
>+static size_t
>+my_lengthsp_utf16le(const CHARSET_INFO *cs __attribute__((unused)),
>+                    const char *ptr, size_t length)
>+{
>+  const char *end= ptr + length;
>+  while (end > ptr + 1 && uint2korr(end - 2) == 0x20)

Monty
Using ' ' instead of 0x20 is maybe more clear?

>+    end-= 2;
>+  return (size_t) (end - ptr);
>+}
>+
>+
>+static MY_CHARSET_HANDLER my_charset_utf16le_handler=
>+{
>+  NULL,                /* init         */
>+  my_ismbchar_utf16,
>+  my_mbcharlen_utf16,
>+  my_numchars_utf16,
>+  my_charpos_utf16,
>+  my_well_formed_len_utf16,
>+  my_lengthsp_utf16le,
>+  my_numcells_mb,
>+  my_utf16le_uni,      /* mb_wc        */
>+  my_uni_utf16le,      /* wc_mb        */
>+  my_mb_ctype_mb,
>+  my_caseup_str_mb2_or_mb4,
>+  my_casedn_str_mb2_or_mb4,
>+  my_caseup_utf16,
>+  my_casedn_utf16,
>+  my_snprintf_mb2,
>+  my_l10tostr_mb2_or_mb4,
>+  my_ll10tostr_mb2_or_mb4,
>+  my_fill_mb2,
>+  my_strntol_mb2_or_mb4,
>+  my_strntoul_mb2_or_mb4,
>+  my_strntoll_mb2_or_mb4,
>+  my_strntoull_mb2_or_mb4,
>+  my_strntod_mb2_or_mb4,
>+  my_strtoll10_mb2,
>+  my_strntoull10rnd_mb2_or_mb4,
>+  my_scan_mb2
>+};
>+
>+
>+struct charset_info_st my_charset_utf16le_general_ci=
>+{
>+  56,0,0,              /* number       */
>+  MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
>+  "utf16le",           /* cs name    */
>+  "utf16le_general_ci",/* name         */
>+  "UTF-16LE Unicode",  /* comment      */
>+  NULL,                /* tailoring    */
>+  NULL,                /* ctype        */
>+  NULL,                /* to_lower     */
>+  NULL,                /* to_upper     */
>+  NULL,                /* sort_order   */
>+  NULL,                /* contractions */
>+  NULL,                /* sort_order_big*/
>+  NULL,                /* tab_to_uni   */
>+  NULL,                /* tab_from_uni */
>+  my_unicase_default,  /* caseinfo     */
>+  NULL,                /* state_map    */
>+  NULL,                /* ident_map    */
>+  1,                   /* strxfrm_multiply */
>+  1,                   /* caseup_multiply  */
>+  1,                   /* casedn_multiply  */
>+  2,                   /* mbminlen     */
>+  4,                   /* mbmaxlen     */
>+  0,                   /* min_sort_char */
>+  0xFFFF,              /* max_sort_char */
>+  ' ',                 /* pad char      */
>+  0,                   /* escape_with_backslash_is_dangerous */
>+  &my_charset_utf16le_handler,
>+  &my_collation_utf16_general_ci_handler
>+};
>+
>+
>+struct charset_info_st my_charset_utf16le_bin=
>+{
>+  62,0,0,              /* number       */
>+  MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
>+  "utf16le",           /* cs name      */
>+  "utf16le_bin",       /* name         */
>+  "UTF-16LE Unicode",  /* comment      */
>+  NULL,                /* tailoring    */
>+  NULL,                /* ctype        */
>+  NULL,                /* to_lower     */
>+  NULL,                /* to_upper     */
>+  NULL,                /* sort_order   */
>+  NULL,                /* contractions */
>+  NULL,                /* sort_order_big*/
>+  NULL,                /* tab_to_uni   */
>+  NULL,                /* tab_from_uni */
>+  my_unicase_default,  /* caseinfo     */
>+  NULL,                /* state_map    */
>+  NULL,                /* ident_map    */
>+  1,                   /* strxfrm_multiply */
>+  1,                   /* caseup_multiply  */
>+  1,                   /* casedn_multiply  */
>+  2,                   /* mbminlen     */
>+  4,                   /* mbmaxlen     */
>+  0,                   /* min_sort_char */
>+  0xFFFF,              /* max_sort_char */
>+  ' ',                 /* pad char      */
>+  0,                   /* escape_with_backslash_is_dangerous */
>+  &my_charset_utf16le_handler,
>+  &my_collation_utf16_bin_handler
>+};
>+
>+
> #endif /* HAVE_CHARSET_utf16 */
> 
> 
>@@ -2589,7 +2805,7 @@
> struct charset_info_st my_charset_utf32_bin=
> {
>   61,0,0,              /* number       */
>-  MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_NONASCII,
>+  MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
>   "utf32",             /* cs name    */
>   "utf32_bin",         /* name         */
>   "UTF-32 Unicode",    /* comment      */
>@@ -2708,6 +2924,35 @@
> }
> 
> 
>+static inline void
>+my_tolower_ucs2(MY_UNICASE_INFO *const *uni_plane, my_wc_t *wc)
>+{
>+  int page= *wc >> 8;
>+  DBUG_ASSERT(page < 256);

monty: 
make page uint both here and in other places.

>+  if (uni_plane[page])
>+    *wc= uni_plane[page][*wc & 0xFF].tolower;
>+}
>+
>+
>+static inline void
>+my_toupper_ucs2(MY_UNICASE_INFO *const *uni_plane, my_wc_t *wc)
>+{
>+  int page= *wc >> 8;
>+  DBUG_ASSERT(page < 256);
>+  if (uni_plane[page])
>+    *wc= uni_plane[page][*wc & 0xFF].toupper;
>+}
>+
>+
>+static inline void
>+my_tosort_ucs2(MY_UNICASE_INFO *const *uni_plane, my_wc_t *wc)
>+{
>+  int page= *wc >> 8;
>+  DBUG_ASSERT(page < 256);
>+  if (uni_plane[page])
>+    *wc= uni_plane[page][*wc & 0xFF].sort;
>+}
>+
> static size_t my_caseup_ucs2(CHARSET_INFO *cs, char *src, size_t srclen,
>                            char *dst __attribute__((unused)),
>                            size_t dstlen __attribute__((unused)))
>@@ -2721,8 +2966,7 @@
>   while ((src < srcend) &&
>          (res= my_ucs2_uni(cs, &wc, (uchar *)src, (uchar*) srcend)) > 0)
>   {
>-    int plane= (wc>>8) & 0xFF;
>-    wc= uni_plane[plane] ? uni_plane[plane][wc & 0xFF].toupper : wc;
>+    my_toupper_ucs2(uni_plane, &wc);
>     if (res != my_uni_ucs2(cs, wc, (uchar*) src, (uchar*) srcend))
>       break;
>     src+= res;
>@@ -2744,8 +2988,7 @@
> 
>   while ((s < e) && (res=my_ucs2_uni(cs,&wc, (uchar *)s, (uchar*)e)) >0)
>   {
>-    int plane = (wc>>8) & 0xFF;
>-    wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc;
>+    my_tosort_ucs2(uni_plane, &wc);
>     n1[0]^= (((n1[0] & 63)+n2[0])*(wc & 0xFF))+ (n1[0] << 8);
>     n2[0]+=3;
>     n1[0]^= (((n1[0] & 63)+n2[0])*(wc >> 8))+ (n1[0] << 8);
>@@ -2768,8 +3011,7 @@
>   while ((src < srcend) &&
>          (res= my_ucs2_uni(cs, &wc, (uchar*) src, (uchar*) srcend)) > 0)
>   {
>-    int plane= (wc>>8) & 0xFF;
>-    wc= uni_plane[plane] ? uni_plane[plane][wc & 0xFF].tolower : wc;
>+    my_tolower_ucs2(uni_plane, &wc);
>     if (res != my_uni_ucs2(cs, wc, (uchar*) src, (uchar*) srcend))
>       break;
>     src+= res;
>@@ -2778,6 +3020,14 @@
> }
> 
> 
>+static void
>+my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), 
>+             char *s, size_t l, int fill)

monty:
Is it time to make 'fill' an unsigned int?

>+{
>+  DBUG_ASSERT(fill <= 0xFFFF);
>+  for ( ; l >= 2; s[0]= (fill >> 8), s[1]= (fill & 0xFF), s+= 2, l-= 2);
>+}

Monty:
You can make the above faster if you store fill >>8 and fill & 0xff in
registers.

>+
> static int my_strnncoll_ucs2(CHARSET_INFO *cs, 
> 			     const uchar *s, size_t slen, 
>                              const uchar *t, size_t tlen,
>@@ -2791,7 +3041,6 @@
> 
>   while ( s < se && t < te )
>   {
>-    int plane;
>     s_res=my_ucs2_uni(cs,&s_wc, s, se);
>     t_res=my_ucs2_uni(cs,&t_wc, t, te);
>     
>@@ -2801,10 +3050,9 @@
>       return ((int)s[0]-(int)t[0]); 
>     }
>     
>-    plane=(s_wc>>8) & 0xFF;
>-    s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].sort : s_wc;
>-    plane=(t_wc>>8) & 0xFF;
>-    t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
>+    my_tosort_ucs2(uni_plane, &s_wc);
>+    my_tosort_ucs2(uni_plane, &t_wc);
>+
>     if ( s_wc != t_wc )
>     {
>       return  s_wc > t_wc ? 1 : -1;
>@@ -3115,7 +3363,7 @@
>     my_snprintf_mb2,
>     my_l10tostr_mb2_or_mb4,
>     my_ll10tostr_mb2_or_mb4,
>-    my_fill_mb2,
>+    my_fill_ucs2,
>     my_strntol_mb2_or_mb4,
>     my_strntoul_mb2_or_mb4,
>     my_strntoll_mb2_or_mb4,
>

Regards,
Monty

Follow ups