List:Commits« Previous MessageNext Message »
From:Marc Alff Date:June 21 2010 6:38pm
Subject:bzr commit into mysql-next-mr branch (marc.alff:3155)
View as plain text  
#At file:///Users/malff/BZR_TREE/mysql-next-mr-wl4674/ based on revid:marc.alff@strippedmcu8ztrd

 3155 Marc Alff	2010-06-21 [merge]
      Merge mysql-next-mr --> mysql-next-mr-wl4674

    added:
      mysql-test/include/ctype_ascii_order.inc
      mysql-test/include/ctype_pad_space.inc
      mysql-test/include/weight_string.inc
      mysql-test/include/weight_string_8140.inc
      mysql-test/include/weight_string_8EA1.inc
      mysql-test/include/weight_string_8FA2C3.inc
      mysql-test/include/weight_string_A1A1.inc
      mysql-test/include/weight_string_chde.inc
      mysql-test/include/weight_string_euro.inc
      mysql-test/include/weight_string_l1.inc
      mysql-test/include/weight_string_l12.inc
      mysql-test/include/weight_string_l14.inc
      mysql-test/include/weight_string_l2.inc
      mysql-test/include/weight_string_l3.inc
      mysql-test/include/weight_string_l4.inc
      mysql-test/r/func_weight_string.result
      mysql-test/t/func_weight_string.test
    modified:
      include/m_ctype.h
      mysql-test/include/ctype_german.inc
      mysql-test/r/ctype_big5.result
      mysql-test/r/ctype_cp1250_ch.result
      mysql-test/r/ctype_cp1251.result
      mysql-test/r/ctype_cp932_binlog_stm.result
      mysql-test/r/ctype_eucjpms.result*
      mysql-test/r/ctype_euckr.result
      mysql-test/r/ctype_gb2312.result
      mysql-test/r/ctype_gbk.result
      mysql-test/r/ctype_latin1.result
      mysql-test/r/ctype_latin1_de.result
      mysql-test/r/ctype_latin2.result
      mysql-test/r/ctype_latin2_ch.result
      mysql-test/r/ctype_sjis.result
      mysql-test/r/ctype_tis620.result
      mysql-test/r/ctype_uca.result
      mysql-test/r/ctype_ucs.result
      mysql-test/r/ctype_ujis.result
      mysql-test/r/ctype_utf16.result
      mysql-test/r/ctype_utf16_uca.result
      mysql-test/r/ctype_utf32.result
      mysql-test/r/ctype_utf32_uca.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/ctype_utf8mb4.result
      mysql-test/r/ctype_utf8mb4_heap.result
      mysql-test/r/ctype_utf8mb4_innodb.result
      mysql-test/r/ctype_utf8mb4_myisam.result
      mysql-test/r/ctype_utf8mb4_ndb.result
      mysql-test/r/locale.result
      mysql-test/r/variables.result
      mysql-test/suite/sys_vars/r/lc_time_names_basic.result
      mysql-test/suite/sys_vars/t/lc_time_names_basic.test
      mysql-test/t/ctype_big5.test
      mysql-test/t/ctype_cp1250_ch.test
      mysql-test/t/ctype_cp1251.test
      mysql-test/t/ctype_cp932_binlog_stm.test
      mysql-test/t/ctype_eucjpms.test
      mysql-test/t/ctype_euckr.test
      mysql-test/t/ctype_gb2312.test
      mysql-test/t/ctype_gbk.test
      mysql-test/t/ctype_latin1.test
      mysql-test/t/ctype_latin1_de.test
      mysql-test/t/ctype_latin2.test
      mysql-test/t/ctype_latin2_ch.test
      mysql-test/t/ctype_sjis.test
      mysql-test/t/ctype_tis620.test
      mysql-test/t/ctype_uca.test
      mysql-test/t/ctype_ucs.test
      mysql-test/t/ctype_ujis.test
      mysql-test/t/ctype_utf16.test
      mysql-test/t/ctype_utf16_uca.test
      mysql-test/t/ctype_utf32.test
      mysql-test/t/ctype_utf32_uca.test
      mysql-test/t/ctype_utf8.test
      mysql-test/t/locale.test
      mysql-test/t/variables.test
      mysys/charset-def.c
      mysys/charset.c
      scripts/mysqld_safe.sh
      sql/field.cc
      sql/filesort.cc
      sql/item_strfunc.cc
      sql/item_strfunc.h
      sql/lex.h
      sql/sql_locale.cc
      sql/sql_yacc.yy
      storage/ndb/src/common/util/NdbSqlUtil.cpp
      strings/conf_to_src.c
      strings/ctype-big5.c
      strings/ctype-bin.c
      strings/ctype-cp932.c
      strings/ctype-czech.c
      strings/ctype-euc_kr.c
      strings/ctype-eucjpms.c
      strings/ctype-extra.c
      strings/ctype-gb2312.c
      strings/ctype-gbk.c
      strings/ctype-latin1.c
      strings/ctype-mb.c
      strings/ctype-simple.c
      strings/ctype-sjis.c
      strings/ctype-tis620.c
      strings/ctype-uca.c
      strings/ctype-ucs2.c
      strings/ctype-ujis.c
      strings/ctype-utf8.c
      strings/ctype-win1250ch.c
=== modified file 'include/m_ctype.h'
--- a/include/m_ctype.h	2010-03-31 14:05:33 +0000
+++ b/include/m_ctype.h	2010-06-17 07:22:36 +0000
@@ -114,6 +114,39 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
 #define MY_REPERTOIRE_EXTENDED   2 /* Extended characters:  U+0080..U+FFFF */
 #define MY_REPERTOIRE_UNICODE30  3 /* ASCII | EXTENDED:     U+0000..U+FFFF */
 
+/* Flags for strxfrm */
+#define MY_STRXFRM_LEVEL1          0x00000001 /* for primary weights   */
+#define MY_STRXFRM_LEVEL2          0x00000002 /* for secondary weights */
+#define MY_STRXFRM_LEVEL3          0x00000004 /* for tertiary weights  */
+#define MY_STRXFRM_LEVEL4          0x00000008 /* fourth level weights  */
+#define MY_STRXFRM_LEVEL5          0x00000010 /* fifth level weights   */
+#define MY_STRXFRM_LEVEL6          0x00000020 /* sixth level weights   */
+#define MY_STRXFRM_LEVEL_ALL       0x0000003F /* Bit OR for the above six */
+#define MY_STRXFRM_NLEVELS         6          /* Number of possible levels*/
+
+#define MY_STRXFRM_PAD_WITH_SPACE  0x00000040 /* if pad result with spaces */
+#define MY_STRXFRM_PAD_TO_MAXLEN   0x00000080 /* if pad tail(for filesort) */
+
+#define MY_STRXFRM_DESC_LEVEL1     0x00000100 /* if desc order for level1 */
+#define MY_STRXFRM_DESC_LEVEL2     0x00000200 /* if desc order for level2 */
+#define MY_STRXFRM_DESC_LEVEL3     0x00000300 /* if desc order for level3 */
+#define MY_STRXFRM_DESC_LEVEL4     0x00000800 /* if desc order for level4 */
+#define MY_STRXFRM_DESC_LEVEL5     0x00001000 /* if desc order for level5 */
+#define MY_STRXFRM_DESC_LEVEL6     0x00002000 /* if desc order for level6 */
+#define MY_STRXFRM_DESC_SHIFT      8
+
+#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions     */
+#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions     */
+
+#define MY_STRXFRM_REVERSE_LEVEL1  0x00010000 /* if reverse order for level1 */
+#define MY_STRXFRM_REVERSE_LEVEL2  0x00020000 /* if reverse order for level2 */
+#define MY_STRXFRM_REVERSE_LEVEL3  0x00040000 /* if reverse order for level3 */
+#define MY_STRXFRM_REVERSE_LEVEL4  0x00080000 /* if reverse order for level4 */
+#define MY_STRXFRM_REVERSE_LEVEL5  0x00100000 /* if reverse order for level5 */
+#define MY_STRXFRM_REVERSE_LEVEL6  0x00200000 /* if reverse order for level6 */
+#define MY_STRXFRM_REVERSE_SHIFT   16
+
+
 typedef struct my_uni_idx_st
 {
   uint16 from;
@@ -157,9 +190,10 @@ typedef struct my_collation_handler_st
   int     (*strnncollsp)(struct charset_info_st *,
                          const uchar *, size_t, const uchar *, size_t,
                          my_bool diff_if_only_endspace_difference);
-  size_t     (*strnxfrm)(struct charset_info_st *,
-                         uchar *, size_t, const uchar *, size_t);
-  size_t    (*strnxfrmlen)(struct charset_info_st *, size_t); 
+  size_t  (*strnxfrm)(struct charset_info_st *,
+                      uchar *dst, size_t dstlen, uint nweights,
+                      const uchar *src, size_t srclen, uint flags);
+  size_t    (*strnxfrmlen)(struct charset_info_st *, size_t);
   my_bool (*like_range)(struct charset_info_st *,
 			const char *s, size_t s_length,
 			pchar w_prefix, pchar w_one, pchar w_many, 
@@ -302,6 +336,8 @@ typedef struct charset_info_st
   uint16    max_sort_char; /* For LIKE optimization */
   uchar     pad_char;
   my_bool   escape_with_backslash_is_dangerous;
+  uchar     levels_for_compare;
+  uchar     levels_for_order;
   
   MY_CHARSET_HANDLER *cset;
   MY_COLLATION_HANDLER *coll;
@@ -357,8 +393,9 @@ extern CHARSET_INFO my_charset_utf8mb4_u
 
 
 /* declarations for simple charsets */
-extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
-                                 const uchar *, size_t); 
+extern size_t my_strnxfrm_simple(CHARSET_INFO *,
+                                 uchar *dst, size_t dstlen, uint nweights,
+                                 const uchar *src, size_t srclen, uint flags);
 size_t  my_strnxfrmlen_simple(CHARSET_INFO *, size_t); 
 extern int  my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
 				const uchar *, size_t, my_bool);
@@ -535,9 +572,13 @@ int my_strcasecmp_mb_bin(CHARSET_INFO * 
 void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
                          const uchar *key, size_t len,ulong *nr1, ulong *nr2);
 
+size_t my_strnxfrm_mb(CHARSET_INFO *,
+                      uchar *dst, size_t dstlen, uint nweights,
+                      const uchar *src, size_t srclen, uint flags);
+
 size_t my_strnxfrm_unicode(CHARSET_INFO *,
-                           uchar *dst, size_t dstlen,
-                           const uchar *src, size_t srclen);
+                           uchar *dst, size_t dstlen, uint nweights,
+                           const uchar *src, size_t srclen, uint flags);
 
 int my_wildcmp_unicode(CHARSET_INFO *cs,
                        const char *str, const char *str_end,
@@ -559,6 +600,14 @@ my_bool my_charset_is_ascii_based(CHARSE
 my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
 uint my_charset_repertoire(CHARSET_INFO *cs);
 
+
+uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
+void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
+                                 uint flags, uint level);
+size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
+                                       uchar *str, uchar *frmend, uchar *strend,
+                                       uint nweights, uint flags, uint level);
+
 my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
 
 extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
@@ -598,7 +647,8 @@ extern size_t my_vsnprintf_ex(CHARSET_IN
 
 #define my_binary_compare(s)	      ((s)->state  & MY_CS_BINSORT)
 #define use_strnxfrm(s)               ((s)->state  & MY_CS_STRNXFRM)
-#define my_strnxfrm(s, a, b, c, d)    ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
+#define my_strnxfrm(cs, d, dl, s, sl) \
+   ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
 #define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
 #define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
    ((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))

=== added file 'mysql-test/include/ctype_ascii_order.inc'
--- a/mysql-test/include/ctype_ascii_order.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_ascii_order.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,14 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+drop table t1;

=== modified file 'mysql-test/include/ctype_german.inc'
--- a/mysql-test/include/ctype_german.inc	2008-02-11 12:28:33 +0000
+++ b/mysql-test/include/ctype_german.inc	2010-05-05 13:35:35 +0000
@@ -1,3 +1,4 @@
+--echo "BEGIN ctype_german.inc"
 #
 # Bug #27877 incorrect german order in utf8_general_ci
 #
@@ -27,14 +28,30 @@ delete from t1;
 # Populate data
 #
 
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
+
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
 
+# LIGATURE AE
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+# LIGATURE OE
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
+
 #
 # Check order
 #
 select s1, hex(s1) from t1 order by s1, binary s1;
 select group_concat(s1 order by binary s1) from t1 group by s1;
+
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+
 drop table t1;
+
+--echo "END ctype_german.inc"

=== added file 'mysql-test/include/ctype_pad_space.inc'
--- a/mysql-test/include/ctype_pad_space.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/ctype_pad_space.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,5 @@
+SELECT strcmp('a','a ');
+SELECT strcmp('a\0','a' );
+SELECT strcmp('a\0','a ');
+SELECT strcmp('a\t','a' );
+SELECT strcmp('a\t','a ');

=== added file 'mysql-test/include/weight_string.inc'
--- a/mysql-test/include/weight_string.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,31 @@
+select @@collation_connection;
+select hex(weight_string('a'));
+select hex(weight_string('A'));
+select hex(weight_string('abc'));
+select hex(weight_string('abc' as char(2)));
+select hex(weight_string('abc' as char(3)));
+select hex(weight_string('abc' as char(5)));
+
+# Read 2 characters from the source string (the last character is not used).
+select hex(weight_string('abc', 1, 2, 0xC0));
+select hex(weight_string('abc', 2, 2, 0xC0));
+select hex(weight_string('abc', 3, 2, 0xC0));
+select hex(weight_string('abc', 4, 2, 0xC0));
+select hex(weight_string('abc', 5, 2, 0xC0));
+select hex(weight_string('abc',25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used).
+select hex(weight_string('abc', 1, 3, 0xC0));
+select hex(weight_string('abc', 2, 3, 0xC0));
+select hex(weight_string('abc', 3, 3, 0xC0));
+select hex(weight_string('abc', 4, 3, 0xC0));
+select hex(weight_string('abc', 5, 3, 0xC0));
+select hex(weight_string('abc',25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string('abc', 1, 4, 0xC0));
+select hex(weight_string('abc', 2, 4, 0xC0));
+select hex(weight_string('abc', 3, 4, 0xC0));
+select hex(weight_string('abc', 4, 4, 0xC0));
+select hex(weight_string('abc', 5, 4, 0xC0));
+select hex(weight_string('abc',25, 4, 0xC0));

=== added file 'mysql-test/include/weight_string_8140.inc'
--- a/mysql-test/include/weight_string_8140.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_8140.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,36 @@
+select collation(cast(0x8140 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8140 as char)));
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+

=== added file 'mysql-test/include/weight_string_8EA1.inc'
--- a/mysql-test/include/weight_string_8EA1.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_8EA1.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,36 @@
+select collation(cast(0xA1A1 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8EA1 as char)));
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+

=== added file 'mysql-test/include/weight_string_8FA2C3.inc'
--- a/mysql-test/include/weight_string_8FA2C3.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_8FA2C3.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,36 @@
+select collation(cast(0x8FA2C3 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8FA2C3 as char)));
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+

=== added file 'mysql-test/include/weight_string_A1A1.inc'
--- a/mysql-test/include/weight_string_A1A1.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_A1A1.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,36 @@
+select collation(cast(0xA1A1 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0xA1A1 as char)));
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+

=== added file 'mysql-test/include/weight_string_chde.inc'
--- a/mysql-test/include/weight_string_chde.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_chde.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,59 @@
+select @@collation_connection;
+select collation(cast(_latin1 0xDF as char));
+select hex(weight_string('s'));
+select hex(weight_string(cast(_latin1 0xDF as char)));
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+select hex(weight_string('c'));
+select hex(weight_string('h'));
+select hex(weight_string('ch'));
+select hex(weight_string('i'));
+# contraction 'ch' plus expansion 'sharp s'
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+# expansion 'sharp s' plus contraction 'ch'
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+
+# contraction 'ch' plus expansion 'sharp s'
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+
+# expansion 'sharp s' plus contraction 'ch'
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));

=== added file 'mysql-test/include/weight_string_euro.inc'
--- a/mysql-test/include/weight_string_euro.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_euro.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,30 @@
+select @@collation_connection;
+select hex(weight_string(cast(_latin1 0x80 as char)));
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+
+# Read 2 characters from the source string (the last character is not used).
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used).
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));

=== added file 'mysql-test/include/weight_string_l1.inc'
--- a/mysql-test/include/weight_string_l1.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l1.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1));
+select hex(weight_string('A' LEVEL 1));
+select hex(weight_string('abc' LEVEL 1));
+select hex(weight_string('abc' as char(2) LEVEL 1));
+select hex(weight_string('abc' as char(3) LEVEL 1));
+select hex(weight_string('abc' as char(5) LEVEL 1));
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));

=== added file 'mysql-test/include/weight_string_l12.inc'
--- a/mysql-test/include/weight_string_l12.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l12.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,5 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1,2));
+select hex(weight_string('a' LEVEL 1-2));
+select hex(weight_string('A' LEVEL 1,2));
+select hex(weight_string('A' LEVEL 1-2));

=== added file 'mysql-test/include/weight_string_l14.inc'
--- a/mysql-test/include/weight_string_l14.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l14.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,37 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1,3));
+select hex(weight_string('a' LEVEL 1-3));
+select hex(weight_string('A' LEVEL 1,3));
+select hex(weight_string('A' LEVEL 1-3));
+
+select hex(weight_string('a' LEVEL 1,4));
+select hex(weight_string('a' LEVEL 1-4));
+select hex(weight_string('A' LEVEL 1,4));
+select hex(weight_string('A' LEVEL 1-4));
+
+select hex(weight_string('a' LEVEL 2,3));
+select hex(weight_string('a' LEVEL 2-3));
+select hex(weight_string('A' LEVEL 2,3));
+select hex(weight_string('A' LEVEL 2-3));
+
+select hex(weight_string('a' LEVEL 2,4));
+select hex(weight_string('a' LEVEL 2-4));
+select hex(weight_string('A' LEVEL 2,4));
+select hex(weight_string('A' LEVEL 2-4));
+
+select hex(weight_string('a' LEVEL 3,4));
+select hex(weight_string('a' LEVEL 3-4));
+select hex(weight_string('A' LEVEL 3,4));
+select hex(weight_string('A' LEVEL 3-4));
+
+select hex(weight_string('a' LEVEL 1,2,3,4));
+select hex(weight_string('a' LEVEL 2,3,4));
+select hex(weight_string('a' LEVEL 1,3,4));
+select hex(weight_string('a' LEVEL 1,2,3));
+
+# If any number is less than 1, it is treated as 1. 
+select hex(weight_string('a' LEVEL 0));
+
+#If any number is greater than the maximum, it is treated as the maximum. 
+select hex(weight_string('a' LEVEL 8));
+select hex(weight_string('a' LEVEL 1,8));

=== added file 'mysql-test/include/weight_string_l2.inc'
--- a/mysql-test/include/weight_string_l2.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l2.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,7 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 2));
+select hex(weight_string('A' LEVEL 2));
+select hex(weight_string('abc' LEVEL 2));
+select hex(weight_string('abc' as char(2) LEVEL 2));
+select hex(weight_string('abc' as char(3) LEVEL 2));
+select hex(weight_string('abc' as char(5) LEVEL 2));

=== added file 'mysql-test/include/weight_string_l3.inc'
--- a/mysql-test/include/weight_string_l3.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l3.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 3));
+select hex(weight_string('A' LEVEL 3));
+select hex(weight_string('abc' LEVEL 3));
+select hex(weight_string('abc' as char(2) LEVEL 3));
+select hex(weight_string('abc' as char(3) LEVEL 3));
+select hex(weight_string('Abc' as char(5) LEVEL 3));
+select hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE));
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC));
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE));

=== added file 'mysql-test/include/weight_string_l4.inc'
--- a/mysql-test/include/weight_string_l4.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/weight_string_l4.inc	2010-03-22 09:13:41 +0000
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 4));
+select hex(weight_string('A' LEVEL 4));
+select hex(weight_string('abc' LEVEL 4));
+select hex(weight_string('abc' as char(2) LEVEL 4));
+select hex(weight_string('abc' as char(3) LEVEL 4));
+select hex(weight_string('abc' as char(5) LEVEL 4));
+select hex(weight_string('abc' as char(5) LEVEL 4 REVERSE));
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC));
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE));

=== modified file 'mysql-test/r/ctype_big5.result'
--- a/mysql-test/r/ctype_big5.result	2010-01-14 11:17:57 +0000
+++ b/mysql-test/r/ctype_big5.result	2010-03-22 09:13:41 +0000
@@ -160,6 +160,86 @@ a	hex(b)	c
 3	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 4	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 DROP TABLE t1;
+drop table if exists t1;
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '')	GROUP_CONCAT(hex(c1) ORDER BY BINARY c1)
+ 	20
+!	21
+"	22
+#	23
+$	24
+%	25
+&	26
+'	27
+(	28
+)	29
+*	2A
++	2B
+,	2C
+-	2D
+.	2E
+/	2F
+0	30
+1	31
+2	32
+3	33
+4	34
+5	35
+6	36
+7	37
+8	38
+9	39
+:	3A
+;	3B
+<	3C
+=	3D
+>	3E
+?	3F
+@	40
+Aa	41,61
+Bb	42,62
+Cc	43,63
+Dd	44,64
+E`e	45,60,65
+Ff	46,66
+Gg	47,67
+Hh	48,68
+Ii	49,69
+Jj	4A,6A
+Kk	4B,6B
+Ll	4C,6C
+Mm	4D,6D
+Nn	4E,6E
+Oo	4F,6F
+Pp	50,70
+Qq	51,71
+Rr	52,72
+Ss	53,73
+Tt	54,74
+Uu	55,75
+Vv	56,76
+Ww	57,77
+Xx	58,78
+Yy~	59,79,7E
+Zz	5A,7A
+]	5D
+[	5B
+\	5C
+^	5E
+_	5F
+{	7B
+|	7C
+}	7D
+	7F
+drop table t1;
 SET collation_connection='big5_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;
@@ -555,3 +635,398 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names big5;
+select @@collation_connection;
+@@collation_connection
+big5_chinese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+big5_chinese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+big5_chinese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A140
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A140
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A140
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1402020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A140A14020
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A14020
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A140A140
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A140A140
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A140A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A140A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A140A14020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A140A140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A140A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A140A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A140A140A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A140A140A14020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A140A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A140A140
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A140A140A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A140A140A14020202020202020202020202020202020202020
+set collation_connection=big5_bin;
+select @@collation_connection;
+@@collation_connection
+big5_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+big5_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+big5_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_cp1250_ch.result'
--- a/mysql-test/r/ctype_cp1250_ch.result	2008-03-07 21:14:56 +0000
+++ b/mysql-test/r/ctype_cp1250_ch.result	2010-06-07 10:27:50 +0000
@@ -238,3 +238,402 @@ select a from t1 where a like "abcdefgh�a
 abcdefgh�drop table t1;
+set names cp1250 collate cp1250_czech_cs;
+SELECT strcmp('a','a ');
+strcmp('a','a ')
+0
+SELECT strcmp('a\0','a' );
+strcmp('a\0','a' )
+1
+SELECT strcmp('a\0','a ');
+strcmp('a\0','a ')
+1
+SELECT strcmp('a\t','a' );
+strcmp('a\t','a' )
+1
+SELECT strcmp('a\t','a ');
+strcmp('a\t','a ')
+1
+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)
+cp1250_czech_cs	61
+cp1250_czech_cs	6109
+cp1250_czech_cs	6120
+drop table t1;
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+#
+# Note:
+# cp1250_czech_cs does not support WEIGHT_STRING in full extent
+#
+set names cp1250 collate cp1250_czech_cs;
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select hex(weight_string('a'));
+hex(weight_string('a'))
+A402
+select hex(weight_string('A'));
+hex(weight_string('A'))
+A401
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+A4A5A6020202
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+A4A5A6020202
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+A4A5A6020202
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+A4A5A6020202
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+A4A5
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+A4A5A6
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+A4A5A602
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+A4A5A60202
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+A4A5A6020202
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+A4A5A602020200000000000000000000000000000000000000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+A4A5
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+A4A5A6
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+A4A5A602
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+A4A5A60202
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+A4A5A6020202
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+A4A5A602020200000000000000000000000000000000000000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+A4A5
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+A4A5A6
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+A4A5A602
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+A4A5A60202
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+A4A5A6020202
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+A4A5A602020200000000000000000000000000000000000000
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+8123
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+8181
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+818181
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+81818123
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+8181812323
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+81818123232300000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+8181
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+818181
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+81818123
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+8181812323
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+81818123232300000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+8181
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+818181
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+81818123
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+8181812323
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+818181232323
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+81818123232300000000000000000000000000000000000000
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+cp1250_czech_cs
+select hex(weight_string('s'));
+hex(weight_string('s'))
+B902
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+BB01
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+BB01
+select hex(weight_string('c'));
+hex(weight_string('c'))
+A602
+select hex(weight_string('h'));
+hex(weight_string('h'))
+AC02
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+AD03
+select hex(weight_string('i'));
+hex(weight_string('i'))
+AE02
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+ADBB0301
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+BBAD0103
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+ADBB
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+ADBB03
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+ADBB0301000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+ADBB
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+ADBB03
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+ADBB0301000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+ADBB
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+ADBB03
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+ADBB0301
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+ADBB0301000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+BBAD
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+BBAD01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+BBAD0103000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+BBAD
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+BBAD01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+BBAD0103000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+BBAD
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+BBAD01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+BBAD0103
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+BBAD0103000000000000000000000000000000000000000000
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+A4
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+A4
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+A4A5A6
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+A4A5A6
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+A4A5A6
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+A4A5A6
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+A4A5A6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+A4A5A6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+A4A5A6
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select hex(weight_string('a' LEVEL 2));
+hex(weight_string('a' LEVEL 2))
+02
+select hex(weight_string('A' LEVEL 2));
+hex(weight_string('A' LEVEL 2))
+01
+select hex(weight_string('abc' LEVEL 2));
+hex(weight_string('abc' LEVEL 2))
+020202
+select hex(weight_string('abc' as char(2) LEVEL 2));
+hex(weight_string('abc' as char(2) LEVEL 2))
+020202
+select hex(weight_string('abc' as char(3) LEVEL 2));
+hex(weight_string('abc' as char(3) LEVEL 2))
+020202
+select hex(weight_string('abc' as char(5) LEVEL 2));
+hex(weight_string('abc' as char(5) LEVEL 2))
+020202
+select @@collation_connection;
+@@collation_connection
+cp1250_czech_cs
+select hex(weight_string('a' LEVEL 1,2));
+hex(weight_string('a' LEVEL 1,2))
+A402
+select hex(weight_string('a' LEVEL 1-2));
+hex(weight_string('a' LEVEL 1-2))
+A402
+select hex(weight_string('A' LEVEL 1,2));
+hex(weight_string('A' LEVEL 1,2))
+A401
+select hex(weight_string('A' LEVEL 1-2));
+hex(weight_string('A' LEVEL 1-2))
+A401
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_cp1251.result'
--- a/mysql-test/r/ctype_cp1251.result	2010-05-14 05:28:51 +0000
+++ b/mysql-test/r/ctype_cp1251.result	2010-06-17 07:22:36 +0000
@@ -63,7 +63,7 @@ insert into t1 (a) values ('air'),
 ('we'),('g'),('we_toshko'), ('s0urce'),('we_ivo'),('we_iliyan'),
 ('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
 ('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
-select * from t1 where a like 'we_%';
+SELECT * FROM t1 WHERE a LIKE 'we_%' ORDER BY a;
 a	b
 we_iliyan	NULL
 we_ivo	NULL

=== modified file 'mysql-test/r/ctype_cp932_binlog_stm.result'
--- a/mysql-test/r/ctype_cp932_binlog_stm.result	2010-05-26 14:34:25 +0000
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result	2010-06-17 07:22:36 +0000
@@ -19492,3 +19492,398 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names cp932;
+select @@collation_connection;
+@@collation_connection
+cp932_japanese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+cp932_japanese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+cp932_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+81402020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+8140814020
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40814020
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+40408140
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+8140814020
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+81408140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+81408140814020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+81408140814020202020202020202020202020202020202020
+set collation_connection=cp932_bin;
+select @@collation_connection;
+@@collation_connection
+cp932_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+cp932_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+cp932_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+81402020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+8140814020
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40814020
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+40408140
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+8140814020
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+81408140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+81408140814020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+81408140814020202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_eucjpms.result' (properties changed: +x to -x)
--- a/mysql-test/r/ctype_eucjpms.result	2010-02-15 05:57:24 +0000
+++ b/mysql-test/r/ctype_eucjpms.result	2010-03-22 09:13:41 +0000
@@ -32609,3 +32609,746 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names eucjpms;
+select @@collation_connection;
+@@collation_connection
+eucjpms_japanese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+eucjpms_japanese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+eucjpms_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+eucjpms_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8EA12020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8EA18EA120
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408EA120
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8EA18EA120
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8EA18EA1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select collation(cast(0x8FA2C3 as char));
+collation(cast(0x8FA2C3 as char))
+eucjpms_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8FA2C3 as char)));
+hex(weight_string(cast(0x8FA2C3 as char)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(3)))
+8FA2C32020
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)))
+8FA2C38FA2C320
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C3 as char) as char(3)))
+408FA2C320
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)))
+40408FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0))
+8FA2C38FA2C320202020202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+set collation_connection=eucjpms_bin;
+select @@collation_connection;
+@@collation_connection
+eucjpms_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+eucjpms_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+eucjpms_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+eucjpms_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8EA12020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8EA18EA120
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408EA120
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8EA18EA120
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8EA18EA1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select collation(cast(0x8FA2C3 as char));
+collation(cast(0x8FA2C3 as char))
+eucjpms_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8FA2C3 as char)));
+hex(weight_string(cast(0x8FA2C3 as char)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(3)))
+8FA2C32020
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)))
+8FA2C38FA2C320
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C3 as char) as char(3)))
+408FA2C320
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)))
+40408FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0))
+8FA2C38FA2C320202020202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_euckr.result'
--- a/mysql-test/r/ctype_euckr.result	2010-01-14 11:17:57 +0000
+++ b/mysql-test/r/ctype_euckr.result	2010-03-22 09:13:41 +0000
@@ -24602,3 +24602,398 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names euckr;
+select @@collation_connection;
+@@collation_connection
+euckr_korean_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+euckr_korean_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+euckr_korean_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+set collation_connection=euckr_bin;
+select @@collation_connection;
+@@collation_connection
+euckr_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+euckr_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+euckr_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_gb2312.result'
--- a/mysql-test/r/ctype_gb2312.result	2010-01-14 11:17:57 +0000
+++ b/mysql-test/r/ctype_gb2312.result	2010-03-22 09:13:41 +0000
@@ -160,6 +160,87 @@ a	hex(b)	c
 3	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 4	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 DROP TABLE t1;
+drop table if exists t1;
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '')	GROUP_CONCAT(hex(c1) ORDER BY BINARY c1)
+ 	20
+!	21
+"	22
+#	23
+$	24
+%	25
+&	26
+'	27
+(	28
+)	29
+*	2A
++	2B
+,	2C
+-	2D
+.	2E
+/	2F
+0	30
+1	31
+2	32
+3	33
+4	34
+5	35
+6	36
+7	37
+8	38
+9	39
+:	3A
+;	3B
+<	3C
+=	3D
+>	3E
+?	3F
+@	40
+Aa	41,61
+Bb	42,62
+Cc	43,63
+Dd	44,64
+Ee	45,65
+Ff	46,66
+Gg	47,67
+Hh	48,68
+Ii	49,69
+Jj	4A,6A
+Kk	4B,6B
+Ll	4C,6C
+Mm	4D,6D
+Nn	4E,6E
+Oo	4F,6F
+Pp	50,70
+Qq	51,71
+Rr	52,72
+Ss	53,73
+Tt	54,74
+Uu	55,75
+Vv	56,76
+Ww	57,77
+Xx	58,78
+Yy~	59,79,7E
+Zz	5A,7A
+]	5D
+[	5B
+\	5C
+^	5E
+_	5F
+`	60
+{	7B
+|	7C
+}	7D
+	7F
+drop table t1;
 SET collation_connection='gb2312_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;
@@ -548,3 +629,398 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names gb2312;
+select @@collation_connection;
+@@collation_connection
+gb2312_chinese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+gb2312_chinese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gb2312_chinese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+set collation_connection=gb2312_bin;
+select @@collation_connection;
+@@collation_connection
+gb2312_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+gb2312_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gb2312_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_gbk.result'
--- a/mysql-test/r/ctype_gbk.result	2010-01-14 11:17:57 +0000
+++ b/mysql-test/r/ctype_gbk.result	2010-03-22 09:13:41 +0000
@@ -160,6 +160,87 @@ a	hex(b)	c
 3	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 4	F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2F1F2	
 DROP TABLE t1;
+drop table if exists t1;
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '')	GROUP_CONCAT(hex(c1) ORDER BY BINARY c1)
+ 	20
+!	21
+"	22
+#	23
+$	24
+%	25
+&	26
+'	27
+(	28
+)	29
+*	2A
++	2B
+,	2C
+-	2D
+.	2E
+/	2F
+0	30
+1	31
+2	32
+3	33
+4	34
+5	35
+6	36
+7	37
+8	38
+9	39
+:	3A
+;	3B
+<	3C
+=	3D
+>	3E
+?	3F
+@	40
+Aa	41,61
+Bb	42,62
+Cc	43,63
+Dd	44,64
+Ee	45,65
+Ff	46,66
+Gg	47,67
+Hh	48,68
+Ii	49,69
+Jj	4A,6A
+Kk	4B,6B
+Ll	4C,6C
+Mm	4D,6D
+Nn	4E,6E
+Oo	4F,6F
+Pp	50,70
+Qq	51,71
+Rr	52,72
+Ss	53,73
+Tt	54,74
+Uu	55,75
+Vv	56,76
+Ww	57,77
+Xx	58,78
+Yy~	59,79,7E
+Zz	5A,7A
+]	5D
+[	5B
+\	5C
+^	5E
+_	5F
+`	60
+{	7B
+|	7C
+}	7D
+	7F
+drop table t1;
 SET collation_connection='gbk_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;
@@ -580,3 +661,746 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names gbk;
+select @@collation_connection;
+@@collation_connection
+gbk_chinese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+gbk_chinese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gbk_chinese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+810B
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+810B
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+810B
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+810B2020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+810B810B20
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40810B20
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40810B810B
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40810B810B
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+810B81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+810B810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+810B810B20
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+810B810B202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+810B81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+810B810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+810B810B81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+810B810B810B20202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+810B81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+810B810B
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+810B810B81
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+810B810B810B20202020202020202020202020202020202020
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+gbk_chinese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+A2CD
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+A2CD
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+A2CD
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+A2CD2020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+A2CDA2CD20
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40A2CD20
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+40A2CDA2CD
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+40A2CDA2CD
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+4040A2CD
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+A2
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+A2CD
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+A2CDA2
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+A2CDA2CD
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+A2CDA2CD20
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+A2CDA2CD202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+A2
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+A2CD
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+A2CDA2
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+A2CDA2CD
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+A2CDA2CDA2
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+A2CDA2CDA2CD20202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+A2
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+A2CD
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+A2CDA2
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+A2CDA2CD
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+A2CDA2CDA2
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+A2CDA2CDA2CD20202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gbk_chinese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8E08
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8E08
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8E08
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8E082020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8E088E0820
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408E0820
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408E088E08
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408E088E08
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8E088E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8E088E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8E088E0820
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8E088E08202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8E088E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8E088E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8E088E088E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8E088E088E0820202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8E088E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8E088E08
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8E088E088E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8E088E088E0820202020202020202020202020202020202020
+set collation_connection=gbk_bin;
+select @@collation_connection;
+@@collation_connection
+gbk_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+gbk_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gbk_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+gbk_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+81402020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+8140814020
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40814020
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+40408140
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+8140814020
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+81408140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+81408140814020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+81408140814020202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+gbk_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8EA12020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8EA18EA120
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408EA120
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8EA18EA120
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8EA18EA1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_latin1.result'
--- a/mysql-test/r/ctype_latin1.result	2010-05-14 05:28:51 +0000
+++ b/mysql-test/r/ctype_latin1.result	2010-06-17 07:22:36 +0000
@@ -2979,3 +2979,725 @@ drop function f1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set @@collation_connection=latin1_swedish_ci;
+select @@collation_connection;
+@@collation_connection
+latin1_swedish_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_swedish_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+80802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+8080202020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+80802020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+80808020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+80808020202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_swedish_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+set @@collation_connection=latin1_bin;
+select @@collation_connection;
+@@collation_connection
+latin1_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_bin
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+80802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+8080202020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+80802020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+80808020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+80808020202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+set @@collation_connection=latin1_general_cs;
+select @@collation_connection;
+@@collation_connection
+latin1_general_cs
+select hex(weight_string('a'));
+hex(weight_string('a'))
+42
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+425254
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4252
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+425254
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4252542020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+42
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4252
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+425220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+42522020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4252202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+42522020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+42
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4252
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+425254
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+42525420
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4252542020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+42525420202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+42
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4252
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+425254
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+42525420
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4252542020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+42525420202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_general_cs
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+C0
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+C0C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+C0C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+C0C0C02020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+C0C020
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+C0C02020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+C0C0202020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+C0C02020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+C0C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+C0C0C020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+C0C0C02020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+C0C0C020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+C0C0C0
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+C0C0C020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+C0C0C02020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+C0C0C020202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_general_cs
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+42
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+425254
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4252
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+425254
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4252542020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020545242
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BDADABDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFABADBD
+set @@collation_connection=binary;
+select @@collation_connection;
+@@collation_connection
+binary
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162630000
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616200
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61620000
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162000000
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61620000000000000000000000000000000000000000000000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626300
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162630000
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626300000000000000000000000000000000000000000000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626300
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162630000
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626300000000000000000000000000000000000000000000
+select @@collation_connection;
+@@collation_connection
+binary
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+8080800000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+808000
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+80800000
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+8080000000
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+80800000000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+80808000
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+8080800000
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+80808000000000000000000000000000000000000000000000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+80808000
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+8080800000
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+80808000000000000000000000000000000000000000000000
+select @@collation_connection;
+@@collation_connection
+binary
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162630000
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+0000636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CFFFF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+FFFF9C9D9E
+set names latin1;
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_latin1_de.result'
--- a/mysql-test/r/ctype_latin1_de.result	2008-02-11 12:28:33 +0000
+++ b/mysql-test/r/ctype_latin1_de.result	2010-05-05 13:35:35 +0000
@@ -326,41 +326,99 @@ latin1_german2_ci	6109
 latin1_german2_ci	61
 latin1_german2_ci	6120
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 latin1_german2_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
+ad	6164
 ae	6165
 �4
+af	6166
+e	65
 o	6F
+od	6F64
 oe	6F65
 �
+of	6F66
 s	73
 ss	7373
 �DF
 u	75
+ud	7564
 ue	7565
 �uf	7566
+�C6
+�6
+�	8C
+�	9C
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a
+ad
 ae,1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	41
+ad	6164	4144
+ae	6165	4145
+�4	4145
+af	6166	4146
+e	65	45
+o	6F	4F
+od	6F64	4F44
+oe	6F65	4F45
+�	4F45
+of	6F66	4F46
+s	73	53
+ss	7373	5353
+�DF	5353
+u	75	55
+ud	7564	5544
+ue	7565	5545
+�545
+uf	7566	5546
+�C6	5C
+�6	5C
+�	8C	8C
+�	9C	9C
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
+�4
 drop table t1;
+"END ctype_german.inc"
 SET NAMES latin1;
 CREATE TABLE t1 (
 col1 varchar(255) NOT NULL default ''
@@ -379,3 +437,242 @@ select * from t1 where length(s1)=1 and 
 s1
 �rop table t1;
+End of 5.1 tests
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set @@collation_connection=latin1_german2_ci;
+select @@collation_connection;
+@@collation_connection
+latin1_german2_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_german2_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+80802020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+8080202020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+80802020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+80808020202020202020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+80
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+8080
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+808080
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+80808020
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+8080802020
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+80808020202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin1_german2_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select hex(weight_string('�));
+hex(weight_string('�))
+4145
+select hex(weight_string('�);
+hex(weight_string('�)
+4145
+select hex(weight_string('�));
+hex(weight_string('�))
+4F45
+select hex(weight_string('�;
+hex(weight_string('�
+4F45
+select hex(weight_string('�));
+hex(weight_string('�))
+5545
+select hex(weight_string('�+hex(weight_string('�5545
+select hex(weight_string('S'));
+hex(weight_string('S'))
+53
+select hex(weight_string('s'));
+hex(weight_string('s'))
+53
+select hex(weight_string('�));
+hex(weight_string('�))
+5353
+select hex(weight_string('�as char(1)));
+hex(weight_string('�as char(1)))
+41
+select hex(weight_string('�s char(1)));
+hex(weight_string('�s char(1)))
+4F
+select hex(weight_string('�char(1)));
+hex(weight_string('�char(1)))
+55
+select hex(weight_string('� as char(1)));
+hex(weight_string('� as char(1)))
+53
+select hex(weight_string('x�as char(2)));
+hex(weight_string('x�as char(2)))
+5841
+select hex(weight_string('x�s char(2)));
+hex(weight_string('x�s char(2)))
+584F
+select hex(weight_string('x�char(2)));
+hex(weight_string('x�char(2)))
+5855
+select hex(weight_string('x� as char(2)));
+hex(weight_string('x� as char(2)))
+5853
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_latin2.result'
--- a/mysql-test/r/ctype_latin2.result	2005-05-06 13:41:41 +0000
+++ b/mysql-test/r/ctype_latin2.result	2010-03-22 09:13:41 +0000
@@ -381,3 +381,225 @@ _
 �
 drop table t1;
+End of 5.1 tests
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names latin2;
+select @@collation_connection;
+@@collation_connection
+latin2_general_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414445
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4144
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414445
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4144452020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4144
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414420
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41442020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4144202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41442020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4144
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414445
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41444520
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4144452020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41444520202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4144
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414445
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41444520
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4144452020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41444520202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin2_general_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414445
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4144
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414445
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4144452020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020454441
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBBBADFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBABBBE
+set collation_connection=latin2_bin;
+select @@collation_connection;
+@@collation_connection
+latin2_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin2_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_latin2_ch.result'
--- a/mysql-test/r/ctype_latin2_ch.result	2006-04-18 16:10:47 +0000
+++ b/mysql-test/r/ctype_latin2_ch.result	2010-06-07 10:27:50 +0000
@@ -29,3 +29,787 @@ id	tt
 select * from t1 where tt like '%AA%';
 id	tt
 drop table t1;
+set names latin2 collate latin2_czech_cs;
+SELECT strcmp('a','a ');
+strcmp('a','a ')
+0
+SELECT strcmp('a\0','a' );
+strcmp('a\0','a' )
+1
+SELECT strcmp('a\0','a ');
+strcmp('a\0','a ')
+1
+SELECT strcmp('a\t','a' );
+strcmp('a\t','a' )
+0
+SELECT strcmp('a\t','a ');
+strcmp('a\t','a ')
+0
+create table t1 (
+a varchar(2) character set latin2 collate latin2_czech_cs,
+primary key(a)
+);
+insert into t1 set a=0x5ff;
+insert into t1 set a=0xff;
+select hex(a) from t1;
+hex(a)
+05FF
+FF
+drop table t1;
+create table t1 (
+ch varchar(1),
+name varchar(64)
+) character set latin2 collate latin2_czech_cs;
+insert into t1 values (0x6F,'LATIN SMALL LETTER O');
+insert into t1 values (0xF3,'LATIN SMALL LETTER O WITH ACUTE');
+insert into t1 values (0xF4,'LATIN SMALL LETTER O WITH CIRCUMFLEX');
+insert into t1 values (0xF6,'LATIN SMALL LETTER O WITH DIAERESIS');
+insert into t1 values (0xF5,'LATIN SMALL LETTER O WITH DOUBLE ACUTE');
+insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
+insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
+insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
+insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
+insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');
+insert into t1 values (0x75,'LATIN SMALL LETTER U');
+insert into t1 values (0xFA,'LATIN SMALL LETTER U WITH ACUTE');
+insert into t1 values (0xF9,'LATIN SMALL LETTER U WITH RING ABOVE');
+insert into t1 values (0xFC,'LATIN SMALL LETTER U WITH DIAERESIS');
+insert into t1 values (0xFB,'LATIN SMALL LETTER U WITH DOUBLE ACUTE');
+insert into t1 values (0x55,'LATIN CAPITAL LETTER U');
+insert into t1 values (0xDA,'LATIN CAPITAL LETTER U WITH ACUTE');
+insert into t1 values (0xD9,'LATIN CAPITAL LETTER U WITH RING ABOVE');
+insert into t1 values (0xDC,'LATIN CAPITAL LETTER U WITH DIAERESIS');
+insert into t1 values (0xDB,'LATIN CAPITAL LETTER U WITH DOUBLE ACUTE');
+select
+hex(weight_string(ch level 1)) l1,
+hex(weight_string(ch level 2)) l2,
+hex(weight_string(ch level 3)) l3,
+hex(weight_string(ch level 4)) l4,
+name from t1 order by binary l1, binary l2, binary l3, binary l4;
+l1	l2	l3	l4	name
+1401	2701	4C01	4C00	LATIN SMALL LETTER O
+1401	2701	4D01	4D00	LATIN CAPITAL LETTER O
+1401	2801	4E01	4E00	LATIN SMALL LETTER O WITH ACUTE
+1401	2801	4F01	4F00	LATIN CAPITAL LETTER O WITH ACUTE
+1401	2901	5001	5000	LATIN SMALL LETTER O WITH CIRCUMFLEX
+1401	2901	5101	5100	LATIN CAPITAL LETTER O WITH CURCUMFLEX
+1401	2A01	5201	5200	LATIN SMALL LETTER O WITH DIAERESIS
+1401	2A01	5301	5300	LATIN CAPITAL LETTER O WITH DIAERESIS
+1401	2B01	5401	5400	LATIN SMALL LETTER O WITH DOUBLE ACUTE
+1401	2B01	5501	5500	LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+1C01	3801	6E01	6E00	LATIN SMALL LETTER U
+1C01	3801	6F01	6F00	LATIN CAPITAL LETTER U
+1C01	3901	7001	7000	LATIN SMALL LETTER U WITH ACUTE
+1C01	3901	7101	7100	LATIN CAPITAL LETTER U WITH ACUTE
+1C01	3A01	7201	7200	LATIN SMALL LETTER U WITH RING ABOVE
+1C01	3A01	7301	7300	LATIN CAPITAL LETTER U WITH RING ABOVE
+1C01	3B01	7401	7400	LATIN SMALL LETTER U WITH DIAERESIS
+1C01	3B01	7501	7500	LATIN CAPITAL LETTER U WITH DIAERESIS
+1C01	3C01	7601	7600	LATIN SMALL LETTER U WITH DOUBLE ACUTE
+1C01	3C01	7701	7700	LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+drop table t1;
+set names utf8;
+create table t1 (
+ch varchar(1),
+name varchar(64)
+) character set latin2 collate latin2_czech_cs;
+insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
+insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
+insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
+insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
+insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');
+insert into t1 values (0x75,'LATIN _SMALL_ LETTER U');
+insert into t1 values (0xFA,'LATIN _SMALL_ LETTER U WITH ACUTE');
+insert into t1 values (0xF9,'LATIN _SMALL_ LETTER U WITH RING ABOVE');
+insert into t1 values (0xFC,'LATIN _SMALL_ LETTER U WITH DIAERESIS');
+insert into t1 values (0xFB,'LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE');
+select ch,
+hex(weight_string(ch level 1)) l1,
+hex(weight_string(ch level 2)) l2,
+hex(weight_string(ch level 3)) l3,
+hex(weight_string(ch level 4)) l4,
+name from t1 order by ch;
+ch	l1	l2	l3	l4	name
+O	1401	2701	4D01	4D00	LATIN CAPITAL LETTER O
+Ó	1401	2801	4F01	4F00	LATIN CAPITAL LETTER O WITH ACUTE
+Ô	1401	2901	5101	5100	LATIN CAPITAL LETTER O WITH CURCUMFLEX
+Ö	1401	2A01	5301	5300	LATIN CAPITAL LETTER O WITH DIAERESIS
+Ő	1401	2B01	5501	5500	LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+u	1C01	3801	6E01	6E00	LATIN _SMALL_ LETTER U
+ú	1C01	3901	7001	7000	LATIN _SMALL_ LETTER U WITH ACUTE
+ů	1C01	3A01	7201	7200	LATIN _SMALL_ LETTER U WITH RING ABOVE
+ü	1C01	3B01	7401	7400	LATIN _SMALL_ LETTER U WITH DIAERESIS
+ű	1C01	3C01	7601	7600	LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE
+alter table t1 modify ch char(1), modify name char(64);
+select ch,
+hex(weight_string(ch level 1)) l1,
+hex(weight_string(ch level 2)) l2,
+hex(weight_string(ch level 3)) l3,
+hex(weight_string(ch level 4)) l4,
+name from t1 order by ch;
+ch	l1	l2	l3	l4	name
+O	1401	2701	4D01	4D00	LATIN CAPITAL LETTER O
+Ó	1401	2801	4F01	4F00	LATIN CAPITAL LETTER O WITH ACUTE
+Ô	1401	2901	5101	5100	LATIN CAPITAL LETTER O WITH CURCUMFLEX
+Ö	1401	2A01	5301	5300	LATIN CAPITAL LETTER O WITH DIAERESIS
+Ő	1401	2B01	5501	5500	LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+u	1C01	3801	6E01	6E00	LATIN _SMALL_ LETTER U
+ú	1C01	3901	7001	7000	LATIN _SMALL_ LETTER U WITH ACUTE
+ů	1C01	3A01	7201	7200	LATIN _SMALL_ LETTER U WITH RING ABOVE
+ü	1C01	3B01	7401	7400	LATIN _SMALL_ LETTER U WITH DIAERESIS
+ű	1C01	3C01	7601	7600	LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE
+select ch,
+hex(weight_string(ch level 1)) l1,
+hex(weight_string(ch level 2)) l2,
+hex(weight_string(ch level 3)) l3,
+hex(weight_string(ch level 4)) l4,
+name from t1 order by concat(ch);
+ch	l1	l2	l3	l4	name
+O	1401	2701	4D01	4D00	LATIN CAPITAL LETTER O
+Ô	1401	2901	5101	5100	LATIN CAPITAL LETTER O WITH CURCUMFLEX
+Ö	1401	2A01	5301	5300	LATIN CAPITAL LETTER O WITH DIAERESIS
+Ő	1401	2B01	5501	5500	LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+u	1C01	3801	6E01	6E00	LATIN _SMALL_ LETTER U
+ú	1C01	3901	7001	7000	LATIN _SMALL_ LETTER U WITH ACUTE
+ů	1C01	3A01	7201	7200	LATIN _SMALL_ LETTER U WITH RING ABOVE
+ü	1C01	3B01	7401	7400	LATIN _SMALL_ LETTER U WITH DIAERESIS
+ű	1C01	3C01	7601	7600	LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE
+drop table t1;
+SET collation_connection=latin2_czech_cs;
+CREATE TABLE t1 ENGINE=MYISAM AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+DROP TABLE t1;
+CREATE TABLE t1 ENGINE=INNODB AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+DROP TABLE t1;
+CREATE TABLE t1 ENGINE=FALCON AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+DROP TABLE t1;
+CREATE TABLE t1 ENGINE=MARIA AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+SELECT * FROM t1 ORDER BY s1;
+s1
+x
+X
+y
+Y
+z
+Z
+DROP TABLE t1;
+SET NAMES latin2;
+CREATE TABLE t2(colours SET('red','blue','yellow'))CHARACTER SET latin2 COLLATE
+latin2_czech_cs;
+CREATE TABLE t1(continent ENUM('Asia', 'Europe','Africa','Antartica'))CHARACTER SET latin2
+COLLATE latin2_czech_cs;
+INSERT INTO t1 VALUES('Asia');
+INSERT INTO t2 VALUES('blue');
+SELECT * FROM t1;
+continent
+Asia
+SELECT * FROM t2;
+colours
+blue
+DROP TABLE t1, t2;
+CREATE TABLE `t1` (
+`ID` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
+`Post` enum('','B','O','Z','U') COLLATE latin2_czech_cs DEFAULT NULL,
+PRIMARY KEY (`ID`)
+) ENGINE=MyISAM AUTO_INCREMENT=135 DEFAULT CHARSET=latin2;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `ID` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
+  `Post` enum('','B','O','Z','U') CHARACTER SET latin2 COLLATE latin2_czech_cs DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=MyISAM AUTO_INCREMENT=135 DEFAULT CHARSET=latin2
+INSERT INTO t1 (ID,Post) VALUES (00041,'');
+SELECT ID, Post, HEX(WEIGHT_STRING(Post)) FROM t1;
+ID	Post	HEX(WEIGHT_STRING(Post))
+00041		01010100
+DROP TABLE t1;
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names latin2 collate latin2_czech_cs;
+SELECT strcmp('a','a ');
+strcmp('a','a ')
+0
+SELECT strcmp('a\0','a' );
+strcmp('a\0','a' )
+1
+SELECT strcmp('a\0','a ');
+strcmp('a\0','a ')
+1
+SELECT strcmp('a\t','a' );
+strcmp('a\t','a' )
+0
+SELECT strcmp('a\t','a ');
+strcmp('a\t','a ')
+0
+#
+# Note:
+# latin2_czech_cs does not support WEIGHT_STRING in full extent
+#
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0301030103010300
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0301030104010400
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+0304050103090A01030F1101030F1100
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+0304050103090A01030F1101030F1100
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+0304050103090A01030F1101030F1100
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+0304050103090A01030F1101030F1100
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+03
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0304
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+030405
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+03040501
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0304050103
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+0304050103090A01030F1101030F1100202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+03
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0304
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+030405
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+03040501
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0304050103
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+0304050103090A01030F1101030F1100202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+03
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0304
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+030405
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+03040501
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0304050103
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+0304050103090A01030F1101030F1100202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+latin2_czech_cs
+select hex(weight_string('s'));
+hex(weight_string('s'))
+1901310160016000
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+010101E200
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+010101E200
+select hex(weight_string('c'));
+hex(weight_string('c'))
+05010A0111011100
+select hex(weight_string('h'));
+hex(weight_string('h'))
+0B0118012D012D00
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+0C0119012F012F00
+select hex(weight_string('i'));
+hex(weight_string('i'))
+0D011A0132013200
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+0C0119012F012FE200
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+0C0119012F012FE200
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+0C0119012F012FE200
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+0C0119012F012FE200
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+0C0119012F012FE200
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+0C0119012F01E22F00
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+0C0119012F01E22F00
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+0C0119012F01E22F00
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+0C0119012F01E22F00
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+0C0119012F01E22F00
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+0C
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+0C0119012F012FE20020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+0C
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+0C0119012F012FE20020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+0C
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+0C0119012F012FE20020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+0C
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+0C0119012F01E22F0020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+0C
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+0C0119012F01E22F0020202020202020202020202020202020
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+0C
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+0C01
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+0C0119
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+0C011901
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+0C0119012F01E22F0020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0301
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0301
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+03040501
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+03040501
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+03040501
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+03040501
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+03040501
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+03040501
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+03040501
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 2));
+hex(weight_string('a' LEVEL 2))
+0301
+select hex(weight_string('A' LEVEL 2));
+hex(weight_string('A' LEVEL 2))
+0301
+select hex(weight_string('abc' LEVEL 2));
+hex(weight_string('abc' LEVEL 2))
+03090A01
+select hex(weight_string('abc' as char(2) LEVEL 2));
+hex(weight_string('abc' as char(2) LEVEL 2))
+03090A01
+select hex(weight_string('abc' as char(3) LEVEL 2));
+hex(weight_string('abc' as char(3) LEVEL 2))
+03090A01
+select hex(weight_string('abc' as char(5) LEVEL 2));
+hex(weight_string('abc' as char(5) LEVEL 2))
+03090A01
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 3));
+hex(weight_string('a' LEVEL 3))
+0301
+select hex(weight_string('A' LEVEL 3));
+hex(weight_string('A' LEVEL 3))
+0401
+select hex(weight_string('abc' LEVEL 3));
+hex(weight_string('abc' LEVEL 3))
+030F1101
+select hex(weight_string('abc' as char(2) LEVEL 3));
+hex(weight_string('abc' as char(2) LEVEL 3))
+030F1101
+select hex(weight_string('abc' as char(3) LEVEL 3));
+hex(weight_string('abc' as char(3) LEVEL 3))
+030F1101
+select hex(weight_string('Abc' as char(5) LEVEL 3));
+hex(weight_string('Abc' as char(5) LEVEL 3))
+040F1101
+select hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE));
+hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE))
+040F1101
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC));
+hex(weight_string('Abc' as char(5) LEVEL 3 DESC))
+040F1101
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE));
+hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE))
+040F1101
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 4));
+hex(weight_string('a' LEVEL 4))
+0300
+select hex(weight_string('A' LEVEL 4));
+hex(weight_string('A' LEVEL 4))
+0400
+select hex(weight_string('abc' LEVEL 4));
+hex(weight_string('abc' LEVEL 4))
+030F1100
+select hex(weight_string('abc' as char(2) LEVEL 4));
+hex(weight_string('abc' as char(2) LEVEL 4))
+030F1100
+select hex(weight_string('abc' as char(3) LEVEL 4));
+hex(weight_string('abc' as char(3) LEVEL 4))
+030F1100
+select hex(weight_string('abc' as char(5) LEVEL 4));
+hex(weight_string('abc' as char(5) LEVEL 4))
+030F1100
+select hex(weight_string('abc' as char(5) LEVEL 4 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 4 REVERSE))
+030F1100
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC));
+hex(weight_string('abc' as char(5) LEVEL 4 DESC))
+030F1100
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE))
+030F1100
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1,2));
+hex(weight_string('a' LEVEL 1,2))
+03010301
+select hex(weight_string('a' LEVEL 1-2));
+hex(weight_string('a' LEVEL 1-2))
+03010301
+select hex(weight_string('A' LEVEL 1,2));
+hex(weight_string('A' LEVEL 1,2))
+03010301
+select hex(weight_string('A' LEVEL 1-2));
+hex(weight_string('A' LEVEL 1-2))
+03010301
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1,3));
+hex(weight_string('a' LEVEL 1,3))
+03010301
+select hex(weight_string('a' LEVEL 1-3));
+hex(weight_string('a' LEVEL 1-3))
+030103010301
+select hex(weight_string('A' LEVEL 1,3));
+hex(weight_string('A' LEVEL 1,3))
+03010401
+select hex(weight_string('A' LEVEL 1-3));
+hex(weight_string('A' LEVEL 1-3))
+030103010401
+select hex(weight_string('a' LEVEL 1,4));
+hex(weight_string('a' LEVEL 1,4))
+03010300
+select hex(weight_string('a' LEVEL 1-4));
+hex(weight_string('a' LEVEL 1-4))
+0301030103010300
+select hex(weight_string('A' LEVEL 1,4));
+hex(weight_string('A' LEVEL 1,4))
+03010400
+select hex(weight_string('A' LEVEL 1-4));
+hex(weight_string('A' LEVEL 1-4))
+0301030104010400
+select hex(weight_string('a' LEVEL 2,3));
+hex(weight_string('a' LEVEL 2,3))
+03010301
+select hex(weight_string('a' LEVEL 2-3));
+hex(weight_string('a' LEVEL 2-3))
+03010301
+select hex(weight_string('A' LEVEL 2,3));
+hex(weight_string('A' LEVEL 2,3))
+03010401
+select hex(weight_string('A' LEVEL 2-3));
+hex(weight_string('A' LEVEL 2-3))
+03010401
+select hex(weight_string('a' LEVEL 2,4));
+hex(weight_string('a' LEVEL 2,4))
+03010300
+select hex(weight_string('a' LEVEL 2-4));
+hex(weight_string('a' LEVEL 2-4))
+030103010300
+select hex(weight_string('A' LEVEL 2,4));
+hex(weight_string('A' LEVEL 2,4))
+03010400
+select hex(weight_string('A' LEVEL 2-4));
+hex(weight_string('A' LEVEL 2-4))
+030104010400
+select hex(weight_string('a' LEVEL 3,4));
+hex(weight_string('a' LEVEL 3,4))
+03010300
+select hex(weight_string('a' LEVEL 3-4));
+hex(weight_string('a' LEVEL 3-4))
+03010300
+select hex(weight_string('A' LEVEL 3,4));
+hex(weight_string('A' LEVEL 3,4))
+04010400
+select hex(weight_string('A' LEVEL 3-4));
+hex(weight_string('A' LEVEL 3-4))
+04010400
+select hex(weight_string('a' LEVEL 1,2,3,4));
+hex(weight_string('a' LEVEL 1,2,3,4))
+0301030103010300
+select hex(weight_string('a' LEVEL 2,3,4));
+hex(weight_string('a' LEVEL 2,3,4))
+030103010300
+select hex(weight_string('a' LEVEL 1,3,4));
+hex(weight_string('a' LEVEL 1,3,4))
+030103010300
+select hex(weight_string('a' LEVEL 1,2,3));
+hex(weight_string('a' LEVEL 1,2,3))
+030103010301
+select hex(weight_string('a' LEVEL 0));
+hex(weight_string('a' LEVEL 0))
+0301
+select hex(weight_string('a' LEVEL 8));
+hex(weight_string('a' LEVEL 8))
+0300
+select hex(weight_string('a' LEVEL 1,8));
+hex(weight_string('a' LEVEL 1,8))
+03010300
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_sjis.result'
--- a/mysql-test/r/ctype_sjis.result	2010-02-15 05:57:24 +0000
+++ b/mysql-test/r/ctype_sjis.result	2010-03-22 09:13:41 +0000
@@ -14556,3 +14556,398 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names sjis;
+select @@collation_connection;
+@@collation_connection
+sjis_japanese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+sjis_japanese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+sjis_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+81402020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+8140814020
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40814020
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+40408140
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+8140814020
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+81408140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+81408140814020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+81408140814020202020202020202020202020202020202020
+set collation_connection=sjis_bin;
+select @@collation_connection;
+@@collation_connection
+sjis_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+sjis_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0x8140 as char));
+collation(cast(0x8140 as char))
+sjis_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8140 as char)));
+hex(weight_string(cast(0x8140 as char)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+hex(weight_string(cast(0x8140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+hex(weight_string(cast(0x81408140 as char) as char(1)))
+8140
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+hex(weight_string(cast(0x8140 as char) as char(3)))
+81402020
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+hex(weight_string(cast(0x81408140 as char) as char(3)))
+8140814020
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+hex(weight_string(cast(0x408140 as char) as char(3)))
+40814020
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+hex(weight_string(cast(0x4081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+hex(weight_string(cast(0x40814081408140 as char) as char(3)))
+4081408140
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+hex(weight_string(cast(0x4040814081408140 as char) as char(3)))
+40408140
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0))
+8140814020
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0))
+81408140202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0))
+81408140814020202020202020202020202020202020202020
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0))
+81
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0))
+8140
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0))
+814081
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0))
+81408140
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0))
+8140814081
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0))
+81408140814020202020202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_tis620.result'
--- a/mysql-test/r/ctype_tis620.result	2006-02-22 09:09:59 +0000
+++ b/mysql-test/r/ctype_tis620.result	2010-03-22 09:13:41 +0000
@@ -2965,6 +2965,88 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+drop table if exists t1;
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR '')	GROUP_CONCAT(hex(c1) ORDER BY BINARY c1)
+ 	20
+!	21
+"	22
+#	23
+$	24
+%	25
+&	26
+'	27
+(	28
+)	29
+*	2A
++	2B
+,	2C
+-	2D
+.	2E
+/	2F
+0	30
+1	31
+2	32
+3	33
+4	34
+5	35
+6	36
+7	37
+8	38
+9	39
+:	3A
+;	3B
+<	3C
+=	3D
+>	3E
+?	3F
+@	40
+[	5B
+\	5C
+]	5D
+^	5E
+_	5F
+`	60
+Aa	41,61
+Bb	42,62
+Cc	43,63
+Dd	44,64
+Ee	45,65
+Ff	46,66
+Gg	47,67
+Hh	48,68
+Ii	49,69
+Jj	4A,6A
+Kk	4B,6B
+Ll	4C,6C
+Mm	4D,6D
+Nn	4E,6E
+Oo	4F,6F
+Pp	50,70
+Qq	51,71
+Rr	52,72
+Ss	53,73
+Tt	54,74
+Uu	55,75
+Vv	56,76
+Ww	57,77
+Xx	58,78
+Yy	59,79
+Zz	5A,7A
+{	7B
+|	7C
+}	7D
+~	7E
+	7F
+drop table t1;
 SET collation_connection='tis620_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;
@@ -2993,3 +3075,237 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names tis620;
+set collation_connection=tis620_thai_ci;
+select @@collation_connection;
+@@collation_connection
+tis620_thai_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+61
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+tis620_thai_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+61
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select hex(weight_string(cast(0xE0A1 as char)));
+hex(weight_string(cast(0xE0A1 as char)))
+A1E0
+select hex(weight_string(cast(0xE0A1 as char) as char(1)));
+hex(weight_string(cast(0xE0A1 as char) as char(1)))
+A1
+set collation_connection=tis620_bin;
+select @@collation_connection;
+@@collation_connection
+tis620_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+tis620_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select hex(weight_string(cast(0xE0A1 as char)));
+hex(weight_string(cast(0xE0A1 as char)))
+E0A1
+select hex(weight_string(cast(0xE0A1 as char) as char(1)));
+hex(weight_string(cast(0xE0A1 as char) as char(1)))
+E0
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_uca.result'
--- a/mysql-test/r/ctype_uca.result	2008-03-26 09:51:16 +0000
+++ b/mysql-test/r/ctype_uca.result	2010-05-28 08:13:40 +0000
@@ -2121,6 +2121,112 @@ Z,z,Ź,ź,Ż,ż,Ž,ž
 ǁ
 ǂ
 ǃ
+select group_concat(c1 order by c1) from t1 group by c1 collate utf8_german2_ci;
+group_concat(c1 order by c1)
+÷
+×
+A,a,À,Á,Â,Ã,Å,à,á,â,ã,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ
+AA,Aa,aA,aa
+Ä,Æ,ä,æ
+Ǣ,ǣ,Ǽ,ǽ
+B,b
+ƀ
+Ɓ
+Ƃ,ƃ
+C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č
+CH,Ch,cH,ch
+Ƈ,ƈ
+D,d,Ď,ď
+DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz
+Đ,đ
+Ɖ
+Ɗ
+Ƌ,ƌ
+Ð,,ě
+Ǝ,ǝ
+Ə
+Ɛ
+F,f
+Ƒ,ƒ
+G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ
+Ǥ,ǥ
+Ɠ
+Ɣ
+Ƣ,ƣ
+H,h,Ĥ,ĥ
+ƕ,Ƕ
+,İ,Ǐ,ǐ
+IJ,Ij,iJ,ij,IJ,ij
+ı
+Ɨ
+Ɩ
+J,j,Ĵ,ĵ,ǰ
+K,k,Ķ,ķ,Ǩ,ǩ
+Ƙ,ƙ
+L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ
+Ŀ,ŀ
+LJ,Lj,lJ,lj,LJ,Lj,lj
+LL,Ll,lL,ll
+Ł,ł
+ƚ
+ƛ
+M,m
+N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ
+NJ,Nj,nJ,nj,NJ,Nj,nj
+Ɲ
+ƞ
+Ŋ,ŋ
+O,o,Ò,Ó,Ô,Õ,ò,ó,ô,õ,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ
+OE,Oe,oE,oe,Ö,ö,Œ,œ
+Ø,ø,Ǿ,ǿ
+Ɔ
+Ɵ
+P,p
+Ƥ,ƥ
+Q,q
+ĸ
+R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř
+RR,Rr,rR,rr
+Ʀ
+S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ
+SS,Ss,sS,ss,ß
+Ʃ
+ƪ
+T,t,Ţ,ţ,Ť,ť
+ƾ
+Ŧ,ŧ
+ƫ
+Ƭ,ƭ
+Ʈ
+U,u,Ù,Ú,Û,ù,ú,û,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,
+Ʋ
+W,w,Ŵ,ŵ
+X,x
+Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ
+Ƴ,ƴ
+Z,z,ƿ,Ƿ
+ƻ
+Ƨ,ƨ
+Ƽ,ƽ
+Ƅ,ƅ
+ʼn
+ǀ
+ǁ
+ǂ
+ǃ
 drop table t1;
 SET NAMES utf8;
 CREATE TABLE t1 (c varchar(255) NOT NULL COLLATE utf8_general_ci, INDEX (c));
@@ -2534,6 +2640,138 @@ HEX(CONVERT(col1 USING ucs2))
 064A06A9062F064A06AF0631
 064A06A9064A
 DROP TABLE t1;
+CREATE TABLE t1 (
+a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_persian_ci,
+offs INT NOT NULL
+);
+INSERT INTO t1 VALUES
+(_ucs2 0x066D, 1),(_ucs2 0x064E, 2),(_ucs2 0xFE76, 3),(_ucs2 0xFE77, 4),
+(_ucs2 0x0650, 5),(_ucs2 0xFE7A, 6),(_ucs2 0xFE7B, 7),(_ucs2 0x064F, 8),
+(_ucs2 0xFE78, 9),(_ucs2 0xFE79,10),(_ucs2 0x064B,11),(_ucs2 0xFE70,12),
+(_ucs2 0xFE71,13),(_ucs2 0x064D,14),(_ucs2 0xFE74,15),(_ucs2 0x064C,16),
+(_ucs2 0xFE72,17),
+(_ucs2 0xFE7F, 1),(_ucs2 0x0653, 2),(_ucs2 0x0654, 3),(_ucs2 0x0655, 4),
+(_ucs2 0x0670, 5),
+(_ucs2 0x0669, 1),(_ucs2 0x0622, 2),(_ucs2 0x0627, 3),(_ucs2 0x0671, 4),
+(_ucs2 0x0621, 5),(_ucs2 0x0623, 6),(_ucs2 0x0625, 7),(_ucs2 0x0624, 8),
+(_ucs2 0x0626, 9),
+(_ucs2 0x0642, 1),(_ucs2 0x06A9, 2),(_ucs2 0x0643, 3),
+(_ucs2 0x0648, 1),(_ucs2 0x0647, 2),(_ucs2 0x0629, 3),(_ucs2 0x06C0, 4),
+(_ucs2 0x06CC, 5),(_ucs2 0x0649, 6),(_ucs2 0x064A, 7),
+(_ucs2 0xFE80, 1),(_ucs2 0xFE81, 2),(_ucs2 0xFE82, 3),(_ucs2 0xFE8D, 4),
+(_ucs2 0xFE8E, 5),(_ucs2 0xFB50, 6),(_ucs2 0xFB51, 7),(_ucs2 0xFE80, 8),
+(_ucs2 0xFE83, 9),(_ucs2 0xFE84,10),(_ucs2 0xFE87,11),(_ucs2 0xFE88,12),
+(_ucs2 0xFE85,13),(_ucs2 0xFE86,14),(_ucs2 0x0689,16),(_ucs2 0x068A,17),
+(_ucs2 0xFEAE, 1),(_ucs2 0xFDFC, 2),
+(_ucs2 0xFED8, 1),(_ucs2 0xFB8E, 2),(_ucs2 0xFB8F, 3),(_ucs2 0xFB90, 4),
+(_ucs2 0xFB91, 5),(_ucs2 0xFED9, 6),(_ucs2 0xFEDA, 7),(_ucs2 0xFEDB, 8),
+(_ucs2 0xFEDC, 9),
+(_ucs2 0xFEEE, 1),(_ucs2 0xFEE9, 2),(_ucs2 0xFEEA, 3),(_ucs2 0xFEEB, 4),
+(_ucs2 0xFEEC, 5),(_ucs2 0xFE93, 6),(_ucs2 0xFE94, 7),(_ucs2 0xFBA4, 8),
+(_ucs2 0xFBA5, 9),(_ucs2 0xFBFC,10),(_ucs2 0xFBFD,11),(_ucs2 0xFBFE,12),
+(_ucs2 0xFBFF,13),(_ucs2 0xFEEF,14),(_ucs2 0xFEF0,15),(_ucs2 0xFEF1,16),
+(_ucs2 0xFEF2,17),(_ucs2 0xFEF3,18),(_ucs2 0xFEF4,19),(_ucs2 0xFEF5,20),
+(_ucs2 0xFEF6,21),(_ucs2 0xFEF7,22),(_ucs2 0xFEF8,23),(_ucs2 0xFEF9,24),
+(_ucs2 0xFEFA,25),(_ucs2 0xFEFB,26),(_ucs2 0xFEFC,27);
+SELECT HEX(CONVERT(a USING ucs2)), offs, hex(weight_string(a)), a
+FROM t1 ORDER BY a, offs, BINARY a;
+HEX(CONVERT(a USING ucs2))	offs	hex(weight_string(a))	a
+0653	2	0001	ٓ
+0654	3	0002	ٔ
+0655	4	0003	ٕ
+0670	5	0004	ٰ
+FE7F	1		ﹿ
+066D	1	02CB	٭
+064E	2	02CC	َ
+FE76	3	02CD	ﹶ
+FE77	4	02CE	ﹷ
+0650	5	02CF	ِ
+FE7A	6	02D0	ﹺ
+FE7B	7	02D1	ﹻ
+064F	8	02D2	ُ
+FE78	9	02D3	ﹸ
+FE79	10	02D4	064D	14	02D8	ٍ
+FE74	15	02D9	ﹴ
+064C	16	02DA	ٌ
+FE72	17	02DB	ﹲ
+0669	1	0E32	٩
+0622	2	0E33	آ
+0627	3	0E34	ا
+0671	4	0E35	ٱ
+0621	5	0E36	ء
+0623	6	0E37	أ
+0625	7	0E38	إ
+0624	8	0E39	ؤ
+0626	9	0E3A	ئ
+FE81	2	1348	0	6	134C	ﭐ
+FB51	7	134D	ﭑ
+FE80	1	134E	ﺀ
+FE80	8	134E	ﺀ
+FE83	9	134F	ﺃ
+FE84	10	1350	ﺄ
+FE87	11	1351	+0689	16	1355	ډ
+068A	17	1356	ڊ
+FEAE	1	1375	ﺮ
+FDFC	2	1376	﷼
+0642	1	139B	ق
+FED8	1	139B	ﻘ
+06A9	2	139C	ک
+FB8E	2	139C	ﮎ
+0643	3	139D	ك
+FB8F	3	139D	ﮏ
+FB90	4	139E	ﮐ
+FB91	5	139F	ﮑ
+FED9	6	13A0	ﻙ
+FEDA	7	13A1	ﻚ
+FEDB	8	13A2	ﻛ
+FEDC	9	13A3	ﻜ
+0648	1	13BD	و
+FEEE	1	13BD	ﻮ
+0647	2	13BE	ه
+FEE9	2	13BE	ﻩ
+0629	3	13BF	ة
+FEEA	3	13BF	ﻪ
+06C0	4	13C0	ۀ
+FEEB	4	13C0	6	13C2	ﺓ
+064A	7	13C3	ي
+FE94	7	13C3	ﺔ
+FBA4	8	13C4	ﮤ
+FBA5	9	13C5	ﮥ
+FBFC	10	13C6	ﯼ
+FBFD	11	13C7	ﯽ
+FBFE	12	13C8	ﯾ
+FBFF	13	13C9	ﯿ
+FEEF	14	13CA	ﻯ
+FEF0	15	13CB	ﻰ
+FEF1	16	13CC	ﻱ
+FEF2	17	13CD	ﻲ
+FEF3	18	13CE	ﻳ
+FEF4	19	13CF	ﻴ
+FEF5	20	13D0	ﻵ
+FEF6	21	13D1	ﻶ
+FEF7	22	13D2	ﻷ
+FEF8	23	13D3	ﻸ
+FEF9	24	13D4	ﻹ
+FEFA	25	13D5	ﻺ
+FEFB	26	13D6	ﻻ
+FEFC	27	13D7	 @test_collation= 'utf8_swedish_ci';
 SET @safe_character_set_server= @@character_set_server;
@@ -2666,41 +2904,96 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8_unicode_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+Æ	C386
+æ	C3A6
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+Œ	C592
+œ	C593
+of	6F66
 s	73
 ss	7373
 ß	C39F
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+Æ,æ
+e
 o,ö
-oe
+od
+oe,Œ,œ
+of
 s
 ss,g(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0E33
+ä	C3A4	0E33
+ad	6164	0E330E6D
+ae	6165	0E330E8B
+af	6166	0E330EB9
+Æ	C386	0E38
+æ	C3A6	0E38
+e	65	0E8B
+o	6F	0F82
+ö	C3B6	0F82
+od	6F64	0F820E6D
+oe	6F65	0F820E8B
+Œ	C592	0F820E8B
+œ	C593	0F820E8B
+of	6F66	0F820EB9
+s	73	0FEA
+ss	7373	0FEA0FEA
+ß	C39F	0FEA0FEA
+u	75	101F
+ü	C3BC	101F
+ud	7564	101F0E6D
+ue	7565	101F0E8B
+uf	7566	101F0EB9
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 CREATE TABLE t1 (id int, a varchar(30) character set utf8);
 INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131);
 INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049);
@@ -2888,3 +3181,676 @@ a	hex(b)	c
 DROP TABLE t1;
 set names utf8;
 End for 5.0 tests
+End of 5.1 tests
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=ucs2_unicode_ci;
+select @@collation_connection;
+@@collation_connection
+ucs2_unicode_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0E33
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0E33
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+0E330E4A
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+0E330E4A0E6002090209
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+0E
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0E330E4A02
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+0E330E4A020902090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+0E
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+0E
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+ucs2_unicode_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+0E230E230E2302090209
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+0E230E2302
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+0E230E23020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+ucs2_unicode_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0E33
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0E33
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+0E330E4A
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+0E330E4A0E6002090209
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+09020902600E4A0E330E
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+F1CCF1B5F19FFDF6FDF6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+F6FDF6FD9FF1B5F1CCF1
+set @@collation_connection=utf8_unicode_ci;
+select @@collation_connection;
+@@collation_connection
+utf8_unicode_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0E33
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0E33
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+0E330E4A
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+0E330E4A0E6002090209
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+0E
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0E330E4A02
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+0E330E4A020902090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+0E
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+0E
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+utf8_unicode_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+0E230E230E2302090209
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+0E230E2302
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+0E230E23020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+utf8_unicode_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0E33
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0E33
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+0E330E4A
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+0E330E4A0E6002090209
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+09020902600E4A0E330E
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+F1CCF1B5F19FFDF6FDF6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+F6FDF6FD9FF1B5F1CCF1
+set @@collation_connection=utf8_czech_ci;
+select @@collation_connection;
+@@collation_connection
+utf8_czech_ci
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+utf8_czech_ci
+select hex(weight_string('s'));
+hex(weight_string('s'))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+0FEA
+select hex(weight_string('c'));
+hex(weight_string('c'))
+0E60
+select hex(weight_string('h'));
+hex(weight_string('h'))
+0EE1
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+0EE2
+select hex(weight_string('i'));
+hex(weight_string('i'))
+0EFB
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+0EE20FEA0FEA0209
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+0FEA0FEA0EE20209
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+0EE20FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+0FEA0FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+set @@collation_connection=ucs2_czech_ci;
+select @@collation_connection;
+@@collation_connection
+ucs2_czech_ci
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+ucs2_czech_ci
+select hex(weight_string('s'));
+hex(weight_string('s'))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+0FEA
+select hex(weight_string('c'));
+hex(weight_string('c'))
+0E60
+select hex(weight_string('h'));
+hex(weight_string('h'))
+0EE1
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+0EE2
+select hex(weight_string('i'));
+hex(weight_string('i'))
+0EFB
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+0EE20FEA0FEA0209
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+0FEA0FEA0EE20209
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+0EE20FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+0FEA0FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+#
+# Bug#53064 garbled data when using utf8_german2_ci collation
+#
+CREATE TABLE t1 (s1 VARCHAR(10) COLLATE utf8_german2_ci);
+INSERT INTO t1 VALUES ('a'),('ae'),('af');
+SELECT s1,hex(s1),hex(weight_string(s1)) FROM t1 ORDER BY s1;
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0E33
+ae	6165	0E330E8B
+af	6166	0E330EB9
+DROP TABLE t1;
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_ucs.result'
--- a/mysql-test/r/ctype_ucs.result	2010-05-20 12:41:01 +0000
+++ b/mysql-test/r/ctype_ucs.result	2010-06-17 07:22:36 +0000
@@ -726,41 +726,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 ucs2_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	0061
 �0E4
+ad	00610064
 ae	00610065
+af	00610066
+e	0065
 o	006F
 �F6
+od	006F0064
 oe	006F0065
+of	006F0066
 s	0073
 �00DF
 ss	00730073
 u	0075
 �
+ud	00750064
 ue	00750065
+uf	00750066
+�00C6
+�0E6
+�	0152
+�	0153
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,�ad
 ae
+af
+e
 o,�d
 oe
+of
 s,� ss
 u,� ue
+uf
+���,�
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	0061	0041
+�0E4	0041
+ad	00610064	00410044
+ae	00610065	00410045
+af	00610066	00410046
+e	0065	0045
+o	006F	004F
+�F6	004F
+od	006F0064	004F0044
+oe	006F0065	004F0045
+of	006F0066	004F0046
+s	0073	0053
+�00DF	0053
+ss	00730073	00530053
+u	0075	0055
+�	0055
+ud	00750064	00550044
+ue	00750065	00550045
+uf	00750066	00550046
+�00C6	00C6
+�0E6	00C6
+�	0152	0152
+�	0153	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	00610065
 drop table t1;
+"END ctype_german.inc"
 CREATE TABLE t1 AS
 SELECT 10 AS a, REPEAT('a',20) AS b, REPEAT('a',8) AS c, REPEAT('a',8) AS d;
 ALTER TABLE t1 ADD PRIMARY KEY(a), ADD KEY(b);
@@ -3812,3 +3868,408 @@ SET NAMES latin1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=ucs2_general_ci;
+select @@collation_connection;
+@@collation_connection
+ucs2_general_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0041
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+004100420043
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00410042
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+004100420043
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00410042004300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0041
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+004100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00410042002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0041
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+004100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00410042004300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0041
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+004100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00410042004300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+ucs2_general_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+ucs2_general_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0041
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00410042
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00410042004300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000430042004100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FFBEFFBDFFBCFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFFBCFFBDFFBEFF
+set collation_connection=ucs2_bin;
+select @@collation_connection;
+@@collation_connection
+ucs2_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0061
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+006100620063
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00610062
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+006100620063
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00610062006300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0061
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+006100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00610062002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0061
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+006100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00610062006300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0061
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+006100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00610062006300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+ucs2_bin
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+ucs2_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0061
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00610062
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00610062006300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000630062006100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FF9EFF9DFF9CFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFF9CFF9DFF9EFF
+#
+# Bug #36418 Character sets: crash if char(256 using utf32)
+#
+select hex(char(0x01 using ucs2));
+hex(char(0x01 using ucs2))
+0001
+select hex(char(0x0102 using ucs2));
+hex(char(0x0102 using ucs2))
+0102
+select hex(char(0x010203 using ucs2));
+hex(char(0x010203 using ucs2))
+00010203
+select hex(char(0x01020304 using ucs2));
+hex(char(0x01020304 using ucs2))
+01020304
+#
+# Bug#10094 Displays wrong error message for UNIQUE key index on CHAR(255) Unicode datatype
+#
+CREATE TABLE t1 (f1 CHAR(255) unicode);
+INSERT INTO t1 values ('abc'),('bcd'),('abc');
+ALTER TABLE t1 ADD UNIQUE Index_1 (f1);
+ERROR 23000: Duplicate entry 'abc' for key 'Index_1'
+DROP TABLE t1;
+#
+# Test how character set works with date/time
+#
+SET collation_connection=ucs2_general_ci;
+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	0032003000300038002D00300037002D00310038
+08:42:04	00300038003A00340032003A00300034
+2008-07-18 08:42:04	0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034
+DROP TABLE t1;
+SET timestamp=0;
+SET NAMES latin1;
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_ujis.result'
--- a/mysql-test/r/ctype_ujis.result	2010-02-15 05:57:24 +0000
+++ b/mysql-test/r/ctype_ujis.result	2010-03-22 09:13:41 +0000
@@ -2377,6 +2377,7 @@ DROP TABLE t2;
 set names default;
 set character_set_database=default;
 set character_set_server=default;
+End of 5.1 tests
 #
 # Start of 5.5 tests
 #
@@ -24906,3 +24907,746 @@ DROP TABLE t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names ujis;
+select @@collation_connection;
+@@collation_connection
+ujis_japanese_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+41
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+414243
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+4142
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+414243
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+4142432020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+41
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+4142
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+414220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+41422020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+4142202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+41422020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+41
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+4142
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+414243
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+41424320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+41
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+4142
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+414243
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+41424320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+4142432020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+41424320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+ujis_japanese_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+41
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+414243
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+4142
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+414243
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+4142432020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020434241
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+BEBDBCDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDFBCBDBE
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+ujis_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+ujis_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8EA12020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8EA18EA120
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408EA120
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8EA18EA120
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8EA18EA1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select collation(cast(0x8FA2C3 as char));
+collation(cast(0x8FA2C3 as char))
+ujis_japanese_ci
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+4141
+select hex(weight_string(cast(0x8FA2C3 as char)));
+hex(weight_string(cast(0x8FA2C3 as char)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(3)))
+8FA2C32020
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)))
+8FA2C38FA2C320
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C3 as char) as char(3)))
+408FA2C320
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)))
+40408FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0))
+8FA2C38FA2C320202020202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+set collation_connection=ujis_bin;
+select @@collation_connection;
+@@collation_connection
+ujis_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+61
+select hex(weight_string('A'));
+hex(weight_string('A'))
+41
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+616263
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+6162
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+616263
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+6162632020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+61
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+6162
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+616220
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+61622020
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+6162202020
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+61622020202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+61
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+6162
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+616263
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+61626320202020202020202020202020202020202020202020
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+61
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+6162
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+616263
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+61626320
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+6162632020
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+61626320202020202020202020202020202020202020202020
+select @@collation_connection;
+@@collation_connection
+ujis_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+61
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+41
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+616263
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+6162
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+616263
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+6162632020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+2020636261
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+9E9D9CDFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFDF9C9D9E
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+ujis_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0xA1A1 as char)));
+hex(weight_string(cast(0xA1A1 as char)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)))
+A1A1
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1 as char) as char(3)))
+A1A12020
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)))
+A1A1A1A120
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1 as char) as char(3)))
+40A1A120
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)))
+40A1A1A1A1
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)))
+4040A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0))
+A1A1A1A120
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0))
+A1A1A1A1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0))
+A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0))
+A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0))
+A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0))
+A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0))
+A1A1A1A1A1
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0))
+A1A1A1A1A1A120202020202020202020202020202020202020
+select collation(cast(0xA1A1 as char));
+collation(cast(0xA1A1 as char))
+ujis_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8EA1 as char)));
+hex(weight_string(cast(0x8EA1 as char)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(1)))
+8EA1
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA1 as char) as char(3)))
+8EA12020
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x8EA18EA1 as char) as char(3)))
+8EA18EA120
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA1 as char) as char(3)))
+408EA120
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)))
+408EA18EA1
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)))
+40408EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0))
+8EA18EA120
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0))
+8EA18EA1202020202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0))
+8E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0))
+8EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0))
+8EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0))
+8EA18EA1
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0))
+8EA18EA18E
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0))
+8EA18EA18EA120202020202020202020202020202020202020
+select collation(cast(0x8FA2C3 as char));
+collation(cast(0x8FA2C3 as char))
+ujis_bin
+select hex(weight_string(cast(0x6141 as char)));
+hex(weight_string(cast(0x6141 as char)))
+6141
+select hex(weight_string(cast(0x8FA2C3 as char)));
+hex(weight_string(cast(0x8FA2C3 as char)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C3 as char) as char(3)))
+8FA2C32020
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)))
+8FA2C38FA2C320
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C3 as char) as char(3)))
+408FA2C320
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)))
+408FA2C38FA2C3
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)))
+40408FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0))
+8FA2C38FA2C320202020202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0))
+8F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0))
+8FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0))
+8FA2C3
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0))
+8FA2C38F
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0))
+8FA2C38FA2
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0))
+8FA2C38FA2C38FA2C320202020202020202020202020202020
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf16.result'
--- a/mysql-test/r/ctype_utf16.result	2010-06-02 12:23:50 +0000
+++ b/mysql-test/r/ctype_utf16.result	2010-06-17 07:22:36 +0000
@@ -1079,3 +1079,374 @@ DROP TABLE t1, t2;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=utf16_general_ci;
+select @@collation_connection;
+@@collation_connection
+utf16_general_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0041
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+004100420043
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00410042
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+004100420043
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00410042004300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0041
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+004100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00410042002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0041
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+004100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00410042004300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0041
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+004100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00410042004300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf16_general_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(_utf16 0xD800DC00));
+hex(weight_string(_utf16 0xD800DC00))
+FFFD
+select hex(weight_string(_utf16 0xD800DC01));
+hex(weight_string(_utf16 0xD800DC01))
+FFFD
+select @@collation_connection;
+@@collation_connection
+utf16_general_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0041
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00410042
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00410042004300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000430042004100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FFBEFFBDFFBCFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFFBCFFBDFFBEFF
+set collation_connection=utf16_bin;
+select @@collation_connection;
+@@collation_connection
+utf16_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0061
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+006100620063
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00610062
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+006100620063
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00610062006300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0061
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+006100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00610062002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0061
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+006100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00610062006300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0061
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+006100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00610062006300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf16_bin
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf16_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0061
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00610062
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00610062006300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000630062006100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FF9EFF9DFF9CFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFF9CFF9DFF9EFF
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf16_uca.result'
--- a/mysql-test/r/ctype_utf16_uca.result	2010-02-24 09:15:34 +0000
+++ b/mysql-test/r/ctype_utf16_uca.result	2010-05-05 13:35:35 +0000
@@ -2371,3 +2371,438 @@ drop table t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=utf16_unicode_ci;
+select @@collation_connection;
+@@collation_connection
+utf16_unicode_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0E33
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0E33
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+0E330E4A
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+0E330E4A0E6002090209
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+0E
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0E330E4A02
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+0E330E4A020902090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+0E
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+0E
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+utf16_unicode_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+0E230E230E2302090209
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+0E230E2302
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+0E230E23020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(_utf16 0xD800DC00 collate utf16_unicode_ci));
+hex(weight_string(_utf16 0xD800DC00 collate utf16_unicode_ci))
+FFFD
+select hex(weight_string(_utf16 0xD800DC01 collate utf16_unicode_ci));
+hex(weight_string(_utf16 0xD800DC01 collate utf16_unicode_ci))
+FFFD
+select @@collation_connection;
+@@collation_connection
+utf16_unicode_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0E33
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0E33
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+0E330E4A
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+0E330E4A0E6002090209
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+09020902600E4A0E330E
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+F1CCF1B5F19FFDF6FDF6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+F6FDF6FD9FF1B5F1CCF1
+set @@collation_connection=utf16_czech_ci;
+select @@collation_connection;
+@@collation_connection
+utf16_czech_ci
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+utf16_czech_ci
+select hex(weight_string('s'));
+hex(weight_string('s'))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+0FEA
+select hex(weight_string('c'));
+hex(weight_string('c'))
+0E60
+select hex(weight_string('h'));
+hex(weight_string('h'))
+0EE1
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+0EE2
+select hex(weight_string('i'));
+hex(weight_string('i'))
+0EFB
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+0EE20FEA0FEA0209
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+0FEA0FEA0EE20209
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+0EE20FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+0FEA0FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+SET NAMES utf8;
+SET collation_connection=utf16_german2_ci;
+"BEGIN ctype_german.inc"
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf16_german2_ci
+delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	0061
+ad	00610064
+ae	00610065
+Æ	00C6
+ä	00E4
+æ	00E6
+af	00610066
+e	0065
+o	006F
+od	006F0064
+oe	006F0065
+ö	00F6
+Œ	0152
+œ	0153
+of	006F0066
+s	0073
+ss	00730073
+ß	00DF
+u	0075
+ud	00750064
+ue	00750065
+ü	00FC
+uf	00750066
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a
+ad
+ae,Æ,ä,æ
+af
+e
+o
+od
+oe,ö,Œ,œ
+of
+s
+ss,ß
+u
+ud
+ue,ü
+uf
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	0061	0E33
+ad	00610064	0E330E6D
+ae	00610065	0E330E8B
+Æ	00C6	0E330E8B
+ä	00E4	0E330E8B
+æ	00E6	0E330E8B
+af	00610066	0E330EB9
+e	0065	0E8B
+o	006F	0F82
+od	006F0064	0F820E6D
+oe	006F0065	0F820E8B
+ö	00F6	0F820E8B
+Œ	0152	0F820E8B
+œ	0153	0F820E8B
+of	006F0066	0F820EB9
+s	0073	0FEA
+ss	00730073	0FEA0FEA
+ß	00DF	0FEA0FEA
+u	0075	101F
+ud	00750064	101F0E6D
+ue	00750065	101F0E8B
+ü	00FC	101F0E8B
+uf	00750066	101F0EB9
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	00610065
+Æ	00C6
+ä	00E4
+æ	00E6
+drop table t1;
+"END ctype_german.inc"
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf32.result'
--- a/mysql-test/r/ctype_utf32.result	2010-06-02 12:23:50 +0000
+++ b/mysql-test/r/ctype_utf32.result	2010-06-17 07:22:36 +0000
@@ -1093,3 +1093,374 @@ DROP TABLE t1, t2;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=utf32_general_ci;
+select @@collation_connection;
+@@collation_connection
+utf32_general_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0041
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+004100420043
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00410042
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+004100420043
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00410042004300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0041
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+004100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00410042002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0041
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+004100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00410042004300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0041
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+004100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00410042004300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf32_general_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(_utf32 0x10000));
+hex(weight_string(_utf32 0x10000))
+FFFD
+select hex(weight_string(_utf32 0x10001));
+hex(weight_string(_utf32 0x10001))
+FFFD
+select @@collation_connection;
+@@collation_connection
+utf32_general_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0041
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00410042
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00410042004300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000430042004100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FFBEFFBDFFBCFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFFBCFFBDFFBEFF
+set collation_connection=utf32_bin;
+select @@collation_connection;
+@@collation_connection
+utf32_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0061
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+006100620063
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00610062
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+006100620063
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00610062006300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0061
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+006100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00610062002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0061
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+006100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00610062006300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0061
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+006100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00610062006300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf32_bin
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf32_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0061
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00610062
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00610062006300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000630062006100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FF9EFF9DFF9CFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFF9CFF9DFF9EFF
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf32_uca.result'
--- a/mysql-test/r/ctype_utf32_uca.result	2010-02-24 09:15:34 +0000
+++ b/mysql-test/r/ctype_utf32_uca.result	2010-05-05 13:35:35 +0000
@@ -2371,3 +2371,438 @@ drop table t1;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set collation_connection=utf32_unicode_ci;
+select @@collation_connection;
+@@collation_connection
+utf32_unicode_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0E33
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0E33
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+0E330E4A
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+0E330E4A0E6002090209
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+0E
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0E330E4A02
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+0E330E4A020902090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+0E
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+0E
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0E33
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+0E330E
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+0E330E4A
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0E330E4A0E
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+0E330E4A0E6002090209020902090209020902090209020902
+select @@collation_connection;
+@@collation_connection
+utf32_unicode_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+0E230E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+0E230E230E2302090209
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+0E230E2302
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+0E230E23020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+0E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+0E230E
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+0E230E23
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+0E230E230E
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+0E230E230E2302090209020902090209020902090209020902
+select hex(weight_string(_utf32 0x10000 collate utf32_unicode_ci));
+hex(weight_string(_utf32 0x10000 collate utf32_unicode_ci))
+FFFD
+select hex(weight_string(_utf32 0x10001 collate utf32_unicode_ci));
+hex(weight_string(_utf32 0x10001 collate utf32_unicode_ci))
+FFFD
+select @@collation_connection;
+@@collation_connection
+utf32_unicode_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0E33
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0E33
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+0E330E4A
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+0E330E4A0E60
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+0E330E4A0E6002090209
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+09020902600E4A0E330E
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+F1CCF1B5F19FFDF6FDF6
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+F6FDF6FD9FF1B5F1CCF1
+set @@collation_connection=utf32_czech_ci;
+select @@collation_connection;
+@@collation_connection
+utf32_czech_ci
+select collation(cast(_latin1 0xDF as char));
+collation(cast(_latin1 0xDF as char))
+utf32_czech_ci
+select hex(weight_string('s'));
+hex(weight_string('s'))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+0FEA
+select hex(weight_string('c'));
+hex(weight_string('c'))
+0E60
+select hex(weight_string('h'));
+hex(weight_string('h'))
+0EE1
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+0EE2
+select hex(weight_string('i'));
+hex(weight_string('i'))
+0EFB
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+0EE20FEA0FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+0EE20FEA0FEA0209
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+0FEA0FEA0EE2
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+0FEA0FEA0EE20209
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0))
+0EE20FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0))
+0E
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0))
+0EE2
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0))
+0EE20F
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0))
+0EE20FEA
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0))
+0EE20FEA0FEA02090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0))
+0FEA0FEA020902090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0))
+0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0))
+0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0))
+0FEA0F
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0))
+0FEA0FEA
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
+hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0))
+0FEA0FEA0EE202090209020902090209020902090209020902
+SET NAMES utf8;
+SET collation_connection=utf32_german2_ci;
+"BEGIN ctype_german.inc"
+drop table if exists t1;
+create table t1 as select repeat(' ', 64) as s1;
+select collation(s1) from t1;
+collation(s1)
+utf32_german2_ci
+delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
+insert into t1 values ('a'),('ae'),(_latin1 0xE4);
+insert into t1 values ('o'),('oe'),(_latin1 0xF6);
+insert into t1 values ('s'),('ss'),(_latin1 0xDF);
+insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
+select s1, hex(s1) from t1 order by s1, binary s1;
+s1	hex(s1)
+a	00000061
+ad	0000006100000064
+ae	0000006100000065
+Æ	000000C6
+ä	000000E4
+æ	000000E6
+af	0000006100000066
+e	00000065
+o	0000006F
+od	0000006F00000064
+oe	0000006F00000065
+ö	000000F6
+Œ	00000152
+œ	00000153
+of	0000006F00000066
+s	00000073
+ss	0000007300000073
+ß	000000DF
+u	00000075
+ud	0000007500000064
+ue	0000007500000065
+ü	000000FC
+uf	0000007500000066
+select group_concat(s1 order by binary s1) from t1 group by s1;
+group_concat(s1 order by binary s1)
+a
+ad
+ae,Æ,ä,æ
+af
+e
+o
+od
+oe,ö,Œ,œ
+of
+s
+ss,ß
+u
+ud
+ue,ü
+uf
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	00000061	0E33
+ad	0000006100000064	0E330E6D
+ae	0000006100000065	0E330E8B
+Æ	000000C6	0E330E8B
+ä	000000E4	0E330E8B
+æ	000000E6	0E330E8B
+af	0000006100000066	0E330EB9
+e	00000065	0E8B
+o	0000006F	0F82
+od	0000006F00000064	0F820E6D
+oe	0000006F00000065	0F820E8B
+ö	000000F6	0F820E8B
+00066	0F820EB9
+s	00000073	0FEA
+ss	0000007300000073	0FEA0FEA
+ß	000000DF	0FEA0FEA
+u	00000075	101F
+ud	0000007500000064	101F0E6D
+ue	0000007500000065	101F0E8B
+ü	000000FC	101F0E8B
+uf	0000007500000066	101F0EB9
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	0000006100000065
+Æ	000000C6
+ä	000000E4
+æ	000000E6
+drop table t1;
+"END ctype_german.inc"
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2010-06-02 12:23:50 +0000
+++ b/mysql-test/r/ctype_utf8.result	2010-06-17 07:22:36 +0000
@@ -939,41 +939,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+Œ	C592
+œ	C593
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ü
+ud
 ue
+uf
+Æ,æ
+Œ,œ
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+ü	C3BC	0055
+ud	7564	00550044
+ue	7565	00550045
+uf	7566	00550046
+Æ	C386	00C6
+æ	C3A6	00C6
+Œ	C592	0152
+œ	C593	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;
@@ -1541,6 +1597,41 @@ substr(Z.a,-1)	a
 3	123
 6	456
 drop table t1;
+SET CHARACTER SET utf8;
+SHOW VARIABLES LIKE 'character\_set\_%';
+Variable_name	Value
+character_set_client	utf8
+character_set_connection	latin1
+character_set_database	latin1
+character_set_filesystem	binary
+character_set_results	utf8
+character_set_server	latin1
+character_set_system	utf8
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+crash
+35
+36
+37
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	crashtest	ALL	NULL	NULL	NULL	NULL	4	Using filesort
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+crash
+-1000
+35
+36
+37
+Warnings:
+Warning	1300	Invalid utf8 character string: 'FFFFFC'
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
 CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8;
 INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
 SELECT id FROM t1;
@@ -2090,3 +2181,390 @@ DROP TABLE t1, t2;
 #
 # End of 5.5 tests
 #
+#
+# Start of 5.6 tests
+#
+#
+# WL#3664 WEIGHT_STRING
+#
+set names utf8;
+select @@collation_connection;
+@@collation_connection
+utf8_general_ci
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0041
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+004100420043
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00410042
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+004100420043
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00410042004300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0041
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+004100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00410042002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0041
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+004100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00410042004300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0041
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+004100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00410042
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0041004200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00410042004300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf8_general_ci
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf8_general_ci
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0041
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00410042
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+004100420043
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00410042004300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000430042004100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FFBEFFBDFFBCFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFFBCFFBDFFBEFF
+set @@collation_connection=utf8_bin;
+select @@collation_connection;
+@@collation_connection
+utf8_bin
+select hex(weight_string('a'));
+hex(weight_string('a'))
+0061
+select hex(weight_string('A'));
+hex(weight_string('A'))
+0041
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+006100620063
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+00610062
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+006100620063
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+00610062006300200020
+select hex(weight_string('abc', 1, 2, 0xC0));
+hex(weight_string('abc', 1, 2, 0xC0))
+00
+select hex(weight_string('abc', 2, 2, 0xC0));
+hex(weight_string('abc', 2, 2, 0xC0))
+0061
+select hex(weight_string('abc', 3, 2, 0xC0));
+hex(weight_string('abc', 3, 2, 0xC0))
+006100
+select hex(weight_string('abc', 4, 2, 0xC0));
+hex(weight_string('abc', 4, 2, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 2, 0xC0));
+hex(weight_string('abc', 5, 2, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 2, 0xC0));
+hex(weight_string('abc',25, 2, 0xC0))
+00610062002000200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 3, 0xC0));
+hex(weight_string('abc', 1, 3, 0xC0))
+00
+select hex(weight_string('abc', 2, 3, 0xC0));
+hex(weight_string('abc', 2, 3, 0xC0))
+0061
+select hex(weight_string('abc', 3, 3, 0xC0));
+hex(weight_string('abc', 3, 3, 0xC0))
+006100
+select hex(weight_string('abc', 4, 3, 0xC0));
+hex(weight_string('abc', 4, 3, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 3, 0xC0));
+hex(weight_string('abc', 5, 3, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 3, 0xC0));
+hex(weight_string('abc',25, 3, 0xC0))
+00610062006300200020002000200020002000200020002000
+select hex(weight_string('abc', 1, 4, 0xC0));
+hex(weight_string('abc', 1, 4, 0xC0))
+00
+select hex(weight_string('abc', 2, 4, 0xC0));
+hex(weight_string('abc', 2, 4, 0xC0))
+0061
+select hex(weight_string('abc', 3, 4, 0xC0));
+hex(weight_string('abc', 3, 4, 0xC0))
+006100
+select hex(weight_string('abc', 4, 4, 0xC0));
+hex(weight_string('abc', 4, 4, 0xC0))
+00610062
+select hex(weight_string('abc', 5, 4, 0xC0));
+hex(weight_string('abc', 5, 4, 0xC0))
+0061006200
+select hex(weight_string('abc',25, 4, 0xC0));
+hex(weight_string('abc',25, 4, 0xC0))
+00610062006300200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf8_bin
+select hex(weight_string(cast(_latin1 0x80 as char)));
+hex(weight_string(cast(_latin1 0x80 as char)))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+hex(weight_string(cast(_latin1 0x808080 as char)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(2)))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(3)))
+20AC20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+hex(weight_string(cast(_latin1 0x808080 as char) as char(5)))
+20AC20AC20AC00200020
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0))
+20AC20AC00
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0))
+20AC20AC002000200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0))
+20
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0))
+20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0))
+20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0))
+20AC20AC
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0))
+20AC20AC20
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
+hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0))
+20AC20AC20AC00200020002000200020002000200020002000
+select @@collation_connection;
+@@collation_connection
+utf8_bin
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+0061
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+0041
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+00610062
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+006100620063
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+00610062006300200020
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+20002000630062006100
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+FF9EFF9DFF9CFFDFFFDF
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+DFFFDFFF9CFF9DFF9EFF
+#
+# Checking strnxfrm() with odd length
+#
+set max_sort_length=5;
+select @@max_sort_length;
+@@max_sort_length
+5
+create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+a
+a
+b
+c
+alter table t1 modify a varchar(128) character set utf8 collate utf8_bin;
+select * from t1 order by a;
+a
+a
+b
+c
+drop table t1;
+set max_sort_length=default;
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/ctype_utf8mb4.result'
--- a/mysql-test/r/ctype_utf8mb4.result	2010-06-02 12:23:50 +0000
+++ b/mysql-test/r/ctype_utf8mb4.result	2010-06-17 07:22:36 +0000
@@ -942,41 +942,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8mb4_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+Œ	C592
+œ	C593
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ü
+ud
 ue
+uf
+Æ,æ
+Œ,œ
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+ü	C3BC	0055
+ud	7564	00550044
+ue	7565	00550045
+uf	7566	00550046
+Æ	C386	00C6
+æ	C3A6	00C6
+Œ	C592	0152
+œ	C593	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8mb4_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;

=== modified file 'mysql-test/r/ctype_utf8mb4_heap.result'
--- a/mysql-test/r/ctype_utf8mb4_heap.result	2010-03-05 08:17:19 +0000
+++ b/mysql-test/r/ctype_utf8mb4_heap.result	2010-05-05 13:35:35 +0000
@@ -881,41 +881,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8mb4_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+Œ	C592
+œ	C593
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ü
+ud
 ue
+uf
+Æ,æ
+ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+00550046
+Æ	C386	00C6
+æ	C3A6	00C6
+Œ	C592	0152
+œ	C593	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8mb4_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;

=== modified file 'mysql-test/r/ctype_utf8mb4_innodb.result'
--- a/mysql-test/r/ctype_utf8mb4_innodb.result	2010-03-05 08:17:19 +0000
+++ b/mysql-test/r/ctype_utf8mb4_innodb.result	2010-05-05 13:35:35 +0000
@@ -942,41 +942,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8mb4_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ht_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+ü	C3BC	0055
+ud	7564	00550044
+ue	7565	00550045
+uf	7566	00550046
+Æ	C386	00C6
+æ	C3A6	00C6
+Œ	C592	0152
+œ	C593	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8mb4_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;

=== modified file 'mysql-test/r/ctype_utf8mb4_myisam.result'
--- a/mysql-test/r/ctype_utf8mb4_myisam.result	2010-03-05 08:17:19 +0000
+++ b/mysql-test/r/ctype_utf8mb4_myisam.result	2010-05-05 13:35:35 +0000
@@ -942,41 +942,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8mb4_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+Œ	C592
+œ	C593
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ü
+ud
 ue
+uf
+Æ,æ
+Œ,œ
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+ü	C3BC	0055
+ud	7564	00550044
+ue	7565	00550045
+uf	7566	00550046
+LECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8mb4_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;

=== modified file 'mysql-test/r/ctype_utf8mb4_ndb.result'
--- a/mysql-test/r/ctype_utf8mb4_ndb.result	2010-03-05 08:17:19 +0000
+++ b/mysql-test/r/ctype_utf8mb4_ndb.result	2010-05-05 13:35:35 +0000
@@ -505,41 +505,97 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+"BEGIN ctype_german.inc"
 drop table if exists t1;
 create table t1 as select repeat(' ', 64) as s1;
 select collation(s1) from t1;
 collation(s1)
 utf8mb4_general_ci
 delete from t1;
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
 insert into t1 values ('a'),('ae'),(_latin1 0xE4);
 insert into t1 values ('o'),('oe'),(_latin1 0xF6);
 insert into t1 values ('s'),('ss'),(_latin1 0xDF);
 insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
 select s1, hex(s1) from t1 order by s1, binary s1;
 s1	hex(s1)
 a	61
 ä	C3A4
+ad	6164
 ae	6165
+af	6166
+e	65
 o	6F
 ö	C3B6
+od	6F64
 oe	6F65
+of	6F66
 s	73
 ß	C39F
 ss	7373
 u	75
 ü	C3BC
+ud	7564
 ue	7565
+uf	7566
+Æ	C386
+æ	C3A6
+Œ	C592
+œ	C593
 select group_concat(s1 order by binary s1) from t1 group by s1;
 group_concat(s1 order by binary s1)
 a,ä
+ad
 ae
+af
+e
 o,ö
+od
 oe
+of
 s,ß
 ss
 u,ü
+ud
 ue
+uf
+Æ,æ
+Œ,œ
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+s1	hex(s1)	hex(weight_string(s1))
+a	61	0041
+ä	C3A4	0041
+ad	6164	00410044
+ae	6165	00410045
+af	6166	00410046
+e	65	0045
+o	6F	004F
+ö	C3B6	004F
+od	6F64	004F0044
+oe	6F65	004F0045
+of	6F66	004F0046
+s	73	0053
+ß	C39F	0053
+ss	7373	00530053
+u	75	0055
+ü	C3BC	0055
+ud	7564	00550044
+ue	7565	00550045
+uf	7566	00550046
+Æ	C386	00C6
+æ	C3A6	00C6
+Œ	C592	0152
+œ	C593	0152
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+s1	hex(s1)
+ae	6165
 drop table t1;
+"END ctype_german.inc"
 SET collation_connection='utf8mb4_bin';
 create table t1 select repeat('a',4000) a;
 delete from t1;

=== added file 'mysql-test/r/func_weight_string.result'
--- a/mysql-test/r/func_weight_string.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/func_weight_string.result	2010-03-22 09:13:41 +0000
@@ -0,0 +1,78 @@
+drop table if exists t1;
+set names latin1;
+select hex(weight_string(0x010203));
+hex(weight_string(0x010203))
+010203
+select hex(weight_string('aa' as char(3)));
+hex(weight_string('aa' as char(3)))
+414120
+select hex(weight_string('a' as char(-1)));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1)))' at line 1
+select hex(weight_string('a' as char(0)));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0)))' at line 1
+select hex(weight_string('a' as char(1)));
+hex(weight_string('a' as char(1)))
+41
+select hex(weight_string('ab' as char(1)));
+hex(weight_string('ab' as char(1)))
+41
+select hex(weight_string('ab'));
+hex(weight_string('ab'))
+4142
+select hex(weight_string('aa' as binary(3)));
+hex(weight_string('aa' as binary(3)))
+616100
+select hex(weight_string(cast('aa' as binary(3))));
+hex(weight_string(cast('aa' as binary(3))))
+616100
+select hex(weight_string('ab' level 1-1 ASC));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC))' at line 1
+select hex(weight_string('ab' level 1-1 DESC));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC))' at line 1
+select hex(weight_string('ab' level 1-1 REVERSE));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REVERSE))' at line 1
+select hex(weight_string('ab' level 1 ASC));
+hex(weight_string('ab' level 1 ASC))
+4142
+select hex(weight_string('ab' level 1 DESC));
+hex(weight_string('ab' level 1 DESC))
+BEBD
+select hex(weight_string('ab' level 1 REVERSE));
+hex(weight_string('ab' level 1 REVERSE))
+4241
+select hex(weight_string('ab' level 1 DESC REVERSE));
+hex(weight_string('ab' level 1 DESC REVERSE))
+BDBE
+create table t1 select weight_string('test') as w;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `w` varbinary(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select weight_string(repeat('t',66000)) as w;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `w` longblob
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select weight_string(NULL);
+weight_string(NULL)
+NULL
+select 1 as weight_string, 2 as reverse;
+weight_string	reverse
+1	2
+select coercibility(weight_string('test'));
+coercibility(weight_string('test'))
+4
+select coercibility(weight_string('test' collate latin1_swedish_ci));
+coercibility(weight_string('test' collate latin1_swedish_ci))
+0
+create table t1 (s1 varchar(5));
+insert into t1 values ('a'),(null);
+select hex(weight_string(s1)) from t1 order by s1;
+hex(weight_string(s1))
+NULL
+41
+drop table t1;

=== modified file 'mysql-test/r/locale.result'
--- a/mysql-test/r/locale.result	2010-02-24 13:52:27 +0000
+++ b/mysql-test/r/locale.result	2010-03-25 06:36:22 +0000
@@ -90,3 +90,99 @@ SELECT DATE_FORMAT('2001-01-07', '%w %a 
 DATE_FORMAT('2001-01-07', '%w %a %W')
 0 Du Duminică
 End of 5.4 tests
+#
+# Start of 5.6 tests
+#
+#
+# WL#5303 Romansh locale for DAYNAME, MONTHNAME, DATE_FORMAT
+#
+SET NAMES utf8;
+SET @old_50915_lc_time_names := @@lc_time_names;
+SET lc_time_names=en_US;
+SELECT DATE_FORMAT('2001-01-01', '%w %a %W');
+DATE_FORMAT('2001-01-01', '%w %a %W')
+1 Mon Monday
+SELECT DATE_FORMAT('2001-03-01', '%c %b %M');
+DATE_FORMAT('2001-03-01', '%c %b %M')
+3 Mar March
+SET lc_time_names=rm_CH;
+SELECT DATE_FORMAT('2001-01-01', '%w %a %W');
+DATE_FORMAT('2001-01-01', '%w %a %W')
+1 gli glindesdi
+SELECT DATE_FORMAT('2001-01-02', '%w %a %W');
+DATE_FORMAT('2001-01-02', '%w %a %W')
+2 ma mardi
+SELECT DATE_FORMAT('2001-01-03', '%w %a %W');
+DATE_FORMAT('2001-01-03', '%w %a %W')
+3 me mesemna
+SELECT DATE_FORMAT('2001-01-04', '%w %a %W');
+DATE_FORMAT('2001-01-04', '%w %a %W')
+4 gie gievgia
+SELECT DATE_FORMAT('2001-01-05', '%w %a %W');
+DATE_FORMAT('2001-01-05', '%w %a %W')
+5 ve venderdi
+SELECT DATE_FORMAT('2001-01-06', '%w %a %W');
+DATE_FORMAT('2001-01-06', '%w %a %W')
+6 so sonda
+SELECT DATE_FORMAT('2001-01-07', '%w %a %W');
+DATE_FORMAT('2001-01-07', '%w %a %W')
+0 du dumengia
+SELECT DATE_FORMAT('2001-01-01', '%c %b %M');
+DATE_FORMAT('2001-01-01', '%c %b %M')
+1 schan schaner
+SELECT DATE_FORMAT('2001-02-01', '%c %b %M');
+DATE_FORMAT('2001-02-01', '%c %b %M')
+2 favr favrer
+SELECT DATE_FORMAT('2001-03-01', '%c %b %M');
+DATE_FORMAT('2001-03-01', '%c %b %M')
+3 mars mars
+SELECT DATE_FORMAT('2001-04-01', '%c %b %M');
+DATE_FORMAT('2001-04-01', '%c %b %M')
+4 avr avrigl
+SELECT DATE_FORMAT('2001-05-01', '%c %b %M');
+DATE_FORMAT('2001-05-01', '%c %b %M')
+5 matg matg
+SELECT DATE_FORMAT('2001-06-01', '%c %b %M');
+DATE_FORMAT('2001-06-01', '%c %b %M')
+6 zercl zercladur
+SELECT DATE_FORMAT('2001-07-01', '%c %b %M');
+DATE_FORMAT('2001-07-01', '%c %b %M')
+7 fan fanadur
+SELECT DATE_FORMAT('2001-08-01', '%c %b %M');
+DATE_FORMAT('2001-08-01', '%c %b %M')
+8 avust avust
+SELECT DATE_FORMAT('2001-09-01', '%c %b %M');
+DATE_FORMAT('2001-09-01', '%c %b %M')
+9 sett settember
+SELECT DATE_FORMAT('2001-10-01', '%c %b %M');
+DATE_FORMAT('2001-10-01', '%c %b %M')
+10 oct october
+SELECT DATE_FORMAT('2001-11-01', '%c %b %M');
+DATE_FORMAT('2001-11-01', '%c %b %M')
+11 nov november
+SELECT DATE_FORMAT('2001-12-01', '%c %b %M');
+DATE_FORMAT('2001-12-01', '%c %b %M')
+12 dec december
+SET lc_time_names=de_CH;
+SELECT DATE_FORMAT('2001-01-06', '%w %a %W');
+DATE_FORMAT('2001-01-06', '%w %a %W')
+6 Sa Samstag
+SELECT DATE_FORMAT('2001-09-01', '%c %b %M');
+DATE_FORMAT('2001-09-01', '%c %b %M')
+9 Sep September
+SELECT DATE_FORMAT('2010-03-23 11:00:00','%h %p');
+DATE_FORMAT('2010-03-23 11:00:00','%h %p')
+11 AM
+SELECT DATE_FORMAT('2010-03-23 13:00:00','%h %p');
+DATE_FORMAT('2010-03-23 13:00:00','%h %p')
+01 PM
+SELECT format(123456789,2,'rm_CH');
+format(123456789,2,'rm_CH')
+123'456'789,00
+SET lc_messages=rm_CH;
+SELECT * FROM non_existent;
+ERROR 42S02: Table 'test.non_existent' doesn't exist
+SET lc_time_names=@old_50915_lc_time_names;
+#
+# End of 5.6 tests
+#

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2010-06-07 07:51:51 +0000
+++ b/mysql-test/r/variables.result	2010-06-17 07:22:36 +0000
@@ -814,16 +814,16 @@ select @@lc_time_names;
 @@lc_time_names
 en_US
 LC_TIME_NAMES: testing locale with the last ID:
-set lc_time_names=109;
+set lc_time_names=110;
 select @@lc_time_names;
 @@lc_time_names
-el_GR
+rm_CH
 LC_TIME_NAMES: testing a number beyond the valid ID range:
-set lc_time_names=110;
-ERROR HY000: Unknown locale: '110'
+set lc_time_names=111;
+ERROR HY000: Unknown locale: '111'
 select @@lc_time_names;
 @@lc_time_names
-el_GR
+rm_CH
 LC_TIME_NAMES: testing that 0 is en_US:
 set lc_time_names=0;
 select @@lc_time_names;

=== modified file 'mysql-test/suite/sys_vars/r/lc_time_names_basic.result'
--- a/mysql-test/suite/sys_vars/r/lc_time_names_basic.result	2010-02-18 17:10:39 +0000
+++ b/mysql-test/suite/sys_vars/r/lc_time_names_basic.result	2010-05-06 07:24:49 +0000
@@ -1022,7 +1022,11 @@ SELECT @@lc_time_names;
 @@lc_time_names
 el_GR
 SET @@lc_time_names = 110;
-ERROR HY000: Unknown locale: '110'
+SELECT @@lc_time_names;
+@@lc_time_names
+rm_CH
+SET @@lc_time_names = 111;
+ERROR HY000: Unknown locale: '111'
 '#--------------------FN_DYNVARS_060_10-------------------------#'
 SET @@lc_time_names = en_EN;
 ERROR HY000: Unknown locale: 'en_EN'

=== modified file 'mysql-test/suite/sys_vars/t/lc_time_names_basic.test'
--- a/mysql-test/suite/sys_vars/t/lc_time_names_basic.test	2009-12-22 09:35:56 +0000
+++ b/mysql-test/suite/sys_vars/t/lc_time_names_basic.test	2010-05-06 07:24:49 +0000
@@ -622,8 +622,10 @@ SET @@lc_time_names = 108;
 SELECT @@lc_time_names;
 SET @@lc_time_names = 109;
 SELECT @@lc_time_names;
---Error ER_UNKNOWN_LOCALE
 SET @@lc_time_names = 110;
+SELECT @@lc_time_names;
+--Error ER_UNKNOWN_LOCALE
+SET @@lc_time_names = 111;
 
 --echo '#--------------------FN_DYNVARS_060_10-------------------------#'
 #############################################################################

=== modified file 'mysql-test/t/ctype_big5.test'
--- a/mysql-test/t/ctype_big5.test	2010-01-14 11:17:57 +0000
+++ b/mysql-test/t/ctype_big5.test	2010-03-22 09:13:41 +0000
@@ -17,6 +17,7 @@ SET collation_connection='big5_chinese_c
 -- source include/ctype_innodb_like.inc
 -- source include/ctype_like_escape.inc
 -- source include/ctype_like_range_f1f2.inc
+-- source include/ctype_ascii_order.inc
 SET collation_connection='big5_bin';
 -- source include/ctype_filesort.inc
 -- source include/ctype_innodb_like.inc
@@ -81,6 +82,7 @@ let $MYSQLD_DATADIR= `select @@datadir`;
 load data infile 't1.txt' into table t1;
 select hex(a) from t1;
 --remove_file $MYSQLD_DATADIR/test/t1.txt
+
 drop table t1;
 
 --echo End of 5.0 tests
@@ -145,3 +147,26 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names big5;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+set collation_connection=big5_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_cp1250_ch.test'
--- a/mysql-test/t/ctype_cp1250_ch.test	2008-03-07 11:28:51 +0000
+++ b/mysql-test/t/ctype_cp1250_ch.test	2010-06-07 10:27:50 +0000
@@ -71,4 +71,34 @@ insert into t1 values("��;
 select a from t1 where a like "abcdefgh�
 drop table t1;
 
+set names cp1250 collate cp1250_czech_cs;
+--source include/ctype_pad_space.inc
+--source include/ctype_filesort.inc
+
 # End of 4.1 tests
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+--echo #
+--echo # Note:
+--echo # cp1250_czech_cs does not support WEIGHT_STRING in full extent
+--echo #
+
+set names cp1250 collate cp1250_czech_cs;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_chde.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_l2.inc
+--source include/weight_string_l12.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_cp1251.test'
--- a/mysql-test/t/ctype_cp1251.test	2010-02-11 04:17:25 +0000
+++ b/mysql-test/t/ctype_cp1251.test	2010-03-22 09:13:41 +0000
@@ -44,7 +44,7 @@ insert into t1 (a) values ('air'),
   ('we_martin'),('vw_grado'),('vw_vasko'),('tn_vili'),('tn_kalina'),
   ('tn_fakira'),('vw_silvia'),('vw_starshi'),('vw_geo'),('vw_b0x1');
 
-select * from t1 where a like 'we_%';
+SELECT * FROM t1 WHERE a LIKE 'we_%' ORDER BY a;
 drop table t1;
 
 #

=== modified file 'mysql-test/t/ctype_cp932_binlog_stm.test'
--- a/mysql-test/t/ctype_cp932_binlog_stm.test	2010-05-26 14:34:25 +0000
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test	2010-06-17 07:22:36 +0000
@@ -140,3 +140,26 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names cp932;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_8140.inc
+
+set collation_connection=cp932_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_8140.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_eucjpms.test'
--- a/mysql-test/t/ctype_eucjpms.test	2010-02-15 05:57:24 +0000
+++ b/mysql-test/t/ctype_eucjpms.test	2010-03-22 09:13:41 +0000
@@ -484,3 +484,29 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names eucjpms;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8EA1.inc
+--source include/weight_string_8FA2C3.inc
+
+set collation_connection=eucjpms_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8EA1.inc
+--source include/weight_string_8FA2C3.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_euckr.test'
--- a/mysql-test/t/ctype_euckr.test	2010-01-14 11:17:57 +0000
+++ b/mysql-test/t/ctype_euckr.test	2010-03-22 09:13:41 +0000
@@ -172,3 +172,26 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+set names euckr;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+set collation_connection=euckr_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+

=== modified file 'mysql-test/t/ctype_gb2312.test'
--- a/mysql-test/t/ctype_gb2312.test	2010-01-14 11:17:57 +0000
+++ b/mysql-test/t/ctype_gb2312.test	2010-03-22 09:13:41 +0000
@@ -17,6 +17,7 @@ SET collation_connection='gb2312_chinese
 -- source include/ctype_innodb_like.inc
 -- source include/ctype_like_escape.inc
 -- source include/ctype_like_range_f1f2.inc
+-- source include/ctype_ascii_order.inc
 SET collation_connection='gb2312_bin';
 -- source include/ctype_filesort.inc
 -- source include/ctype_innodb_like.inc
@@ -124,3 +125,27 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names gb2312;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+set collation_connection=gb2312_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_gbk.test'
--- a/mysql-test/t/ctype_gbk.test	2010-01-14 11:17:57 +0000
+++ b/mysql-test/t/ctype_gbk.test	2010-03-22 09:13:41 +0000
@@ -17,6 +17,7 @@ SET collation_connection='gbk_chinese_ci
 -- source include/ctype_innodb_like.inc
 -- source include/ctype_like_escape.inc
 -- source include/ctype_like_range_f1f2.inc
+-- source include/ctype_ascii_order.inc
 SET collation_connection='gbk_bin';
 -- source include/ctype_filesort.inc
 -- source include/ctype_innodb_like.inc
@@ -159,3 +160,30 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names gbk;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8140.inc
+--source include/weight_string_8EA1.inc
+
+set collation_connection=gbk_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8140.inc
+--source include/weight_string_8EA1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_latin1.test'
--- a/mysql-test/t/ctype_latin1.test	2010-02-11 04:17:25 +0000
+++ b/mysql-test/t/ctype_latin1.test	2010-03-22 09:13:41 +0000
@@ -128,7 +128,7 @@ select hex(cast(_ascii 0x7f as char(1) c
 
 --echo End of 5.0 tests
 
-                                                                               
+
 --echo #
 --echo # Start of 5.5 tests
 --echo #
@@ -138,3 +138,39 @@ select hex(cast(_ascii 0x7f as char(1) c
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set @@collation_connection=latin1_swedish_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=latin1_bin;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=latin1_general_cs;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=binary;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set names latin1;
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_latin1_de.test'
--- a/mysql-test/t/ctype_latin1_de.test	2008-02-11 12:28:33 +0000
+++ b/mysql-test/t/ctype_latin1_de.test	2010-03-22 09:13:41 +0000
@@ -143,3 +143,40 @@ create table t1 (s1 char(5) character se
 insert into t1 values (0xf6) /* this is o-umlaut */;
 select * from t1 where length(s1)=1 and s1='oe';
 drop table t1;
+
+--echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set @@collation_connection=latin1_german2_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+select hex(weight_string('�));
+select hex(weight_string('�);
+select hex(weight_string('�));
+select hex(weight_string('�;
+select hex(weight_string('�));
+select hex(weight_string('�+select hex(weight_string('S'));
+select hex(weight_string('s'));
+select hex(weight_string('�));
+select hex(weight_string('�as char(1)));
+select hex(weight_string('�s char(1)));
+select hex(weight_string('�char(1)));
+select hex(weight_string('� as char(1)));
+select hex(weight_string('x�as char(2)));
+select hex(weight_string('xselect hex(weight_string('x� as char(2)));
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_latin2.test'
--- a/mysql-test/t/ctype_latin2.test	2005-07-28 00:22:47 +0000
+++ b/mysql-test/t/ctype_latin2.test	2010-03-22 09:13:41 +0000
@@ -50,3 +50,26 @@ SELECT group_concat(a collate latin2_cro
 drop table t1;
 
 # End of 4.1 tests
+
+--echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names latin2;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set collation_connection=latin2_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_latin2_ch.test'
--- a/mysql-test/t/ctype_latin2_ch.test	2006-04-18 16:10:47 +0000
+++ b/mysql-test/t/ctype_latin2_ch.test	2010-06-07 10:27:50 +0000
@@ -27,6 +27,212 @@ select * from t1 where tt like 'AA%';
 select * from t1 ignore index (primary) where tt like 'AA%';
 select * from t1 where tt like '%AA%';
 
+drop table t1;
+
 # End of 4.1 tests
 
+set names latin2 collate latin2_czech_cs;
+--source include/ctype_pad_space.inc
+
+# We can not use ctype_filesort.inc because
+# order of SPACE and TAB is not strict
+#--source include/ctype_filesort.inc
+#
+
+#
+# Bug#29459 server died handling latin2 collate latin2_czech_cs
+#
+create table t1 (
+  a varchar(2) character set latin2 collate latin2_czech_cs,
+  primary key(a)
+);
+insert into t1 set a=0x5ff;
+insert into t1 set a=0xff;
+select hex(a) from t1;
+drop table t1;
+
+#
+# Bug#33452 Primary difference between capital and small letters U and O
+#
+create table t1 (
+  ch varchar(1),
+  name varchar(64)
+) character set latin2 collate latin2_czech_cs;
+
+insert into t1 values (0x6F,'LATIN SMALL LETTER O');
+insert into t1 values (0xF3,'LATIN SMALL LETTER O WITH ACUTE');
+insert into t1 values (0xF4,'LATIN SMALL LETTER O WITH CIRCUMFLEX');
+insert into t1 values (0xF6,'LATIN SMALL LETTER O WITH DIAERESIS');
+insert into t1 values (0xF5,'LATIN SMALL LETTER O WITH DOUBLE ACUTE');
+insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
+insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
+insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
+insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
+insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');
+
+insert into t1 values (0x75,'LATIN SMALL LETTER U');
+insert into t1 values (0xFA,'LATIN SMALL LETTER U WITH ACUTE');
+insert into t1 values (0xF9,'LATIN SMALL LETTER U WITH RING ABOVE');
+insert into t1 values (0xFC,'LATIN SMALL LETTER U WITH DIAERESIS');
+insert into t1 values (0xFB,'LATIN SMALL LETTER U WITH DOUBLE ACUTE');
+insert into t1 values (0x55,'LATIN CAPITAL LETTER U');
+insert into t1 values (0xDA,'LATIN CAPITAL LETTER U WITH ACUTE');
+insert into t1 values (0xD9,'LATIN CAPITAL LETTER U WITH RING ABOVE');
+insert into t1 values (0xDC,'LATIN CAPITAL LETTER U WITH DIAERESIS');
+insert into t1 values (0xDB,'LATIN CAPITAL LETTER U WITH DOUBLE ACUTE');
+select
+hex(weight_string(ch level 1)) l1,
+hex(weight_string(ch level 2)) l2,
+hex(weight_string(ch level 3)) l3,
+hex(weight_string(ch level 4)) l4,
+name from t1 order by binary l1, binary l2, binary l3, binary l4;
+drop table t1;
+
+#
+# Bug#33791 Wrong ORDER BY with latin2_czech_cs
+#
+set names utf8;
+create table t1 (
+ch varchar(1),
+name varchar(64)
+) character set latin2 collate latin2_czech_cs;
+insert into t1 values (0x4F,'LATIN CAPITAL LETTER O');
+insert into t1 values (0xD3,'LATIN CAPITAL LETTER O WITH ACUTE');
+insert into t1 values (0xD4,'LATIN CAPITAL LETTER O WITH CURCUMFLEX');
+insert into t1 values (0xD6,'LATIN CAPITAL LETTER O WITH DIAERESIS');
+insert into t1 values (0xD5,'LATIN CAPITAL LETTER O WITH DOUBLE ACUTE');
+insert into t1 values (0x75,'LATIN _SMALL_ LETTER U');
+insert into t1 values (0xFA,'LATIN _SMALL_ LETTER U WITH ACUTE');
+insert into t1 values (0xF9,'LATIN _SMALL_ LETTER U WITH RING ABOVE');
+insert into t1 values (0xFC,'LATIN _SMALL_ LETTER U WITH DIAERESIS');
+insert into t1 values (0xFB,'LATIN _SMALL_ LETTER U WITH DOUBLE ACUTE');
+# Testing order by Field_varchar
+select ch,
+  hex(weight_string(ch level 1)) l1,
+  hex(weight_string(ch level 2)) l2,
+  hex(weight_string(ch level 3)) l3,
+  hex(weight_string(ch level 4)) l4,
+  name from t1 order by ch;
+alter table t1 modify ch char(1), modify name char(64);
+# Testing order by Field_char
+select ch,
+  hex(weight_string(ch level 1)) l1,
+  hex(weight_string(ch level 2)) l2,
+  hex(weight_string(ch level 3)) l3,
+  hex(weight_string(ch level 4)) l4,
+  name from t1 order by ch;
+# Testing order by Item
+select ch,
+  hex(weight_string(ch level 1)) l1,
+  hex(weight_string(ch level 2)) l2,
+  hex(weight_string(ch level 3)) l3,
+  hex(weight_string(ch level 4)) l4,
+  name from t1 order by concat(ch);
 drop table t1;
+
+#
+# Bug #30462 Character sets: search failures with case sensitive collations
+#
+SET collation_connection=latin2_czech_cs;
+CREATE TABLE t1 ENGINE=MYISAM AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+
+--disable_warnings
+CREATE TABLE t1 ENGINE=INNODB AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+--enable_warnings
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+
+--disable_warnings
+CREATE TABLE t1 ENGINE=FALCON AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+--enable_warnings
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+
+--disable_warnings
+CREATE TABLE t1 ENGINE=MARIA AS SELECT repeat('a', 5) AS s1 LIMIT 0;
+--enable_warnings
+INSERT INTO t1 VALUES ('x'),('y'),('z'),('X'),('Y'),('Z');
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+CREATE INDEX i1 ON t1 (s1);
+SELECT * FROM t1 GROUP BY s1;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+
+SET NAMES latin2;
+
+#
+# Bug#37854 Test fails/aborts for collate latin2_czech_cs used with SET and ENUM datatypes
+#
+CREATE TABLE t2(colours SET('red','blue','yellow'))CHARACTER SET latin2 COLLATE
+latin2_czech_cs;
+CREATE TABLE t1(continent ENUM('Asia', 'Europe','Africa','Antartica'))CHARACTER SET latin2
+COLLATE latin2_czech_cs;
+INSERT INTO t1 VALUES('Asia');
+INSERT INTO t2 VALUES('blue');
+SELECT * FROM t1;
+SELECT * FROM t2;
+DROP TABLE t1, t2;
+
+#
+# Bug#40805 Cannot restore table
+#
+CREATE TABLE `t1` (
+  `ID` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
+  `Post` enum('','B','O','Z','U') COLLATE latin2_czech_cs DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=MyISAM AUTO_INCREMENT=135 DEFAULT CHARSET=latin2;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (ID,Post) VALUES (00041,'');
+SELECT ID, Post, HEX(WEIGHT_STRING(Post)) FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names latin2 collate latin2_czech_cs;
+--source include/ctype_pad_space.inc
+# We can not use ctype_filesort.inc because
+# order of SPACE and TAB is not strict
+#--source include/ctype_filesort.inc
+
+--echo #
+--echo # Note:
+--echo # latin2_czech_cs does not support WEIGHT_STRING in full extent
+--echo #
+--source include/weight_string.inc
+--source include/weight_string_chde.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_l2.inc
+--source include/weight_string_l3.inc
+--source include/weight_string_l4.inc
+--source include/weight_string_l12.inc
+--source include/weight_string_l14.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+

=== modified file 'mysql-test/t/ctype_sjis.test'
--- a/mysql-test/t/ctype_sjis.test	2010-02-15 05:57:24 +0000
+++ b/mysql-test/t/ctype_sjis.test	2010-03-22 09:13:41 +0000
@@ -182,3 +182,29 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names sjis;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_8140.inc
+
+
+set collation_connection=sjis_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_8140.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+
+

=== modified file 'mysql-test/t/ctype_tis620.test'
--- a/mysql-test/t/ctype_tis620.test	2005-09-21 18:10:51 +0000
+++ b/mysql-test/t/ctype_tis620.test	2010-03-22 09:13:41 +0000
@@ -156,8 +156,35 @@ DROP TABLE t1;
 SET collation_connection='tis620_thai_ci';
 -- source include/ctype_filesort.inc
 -- source include/ctype_like_escape.inc
+--source include/ctype_ascii_order.inc
 SET collation_connection='tis620_bin';
 -- source include/ctype_filesort.inc
 -- source include/ctype_like_escape.inc
 
 # End of 4.1 tests
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names tis620;
+set collation_connection=tis620_thai_ci;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+select hex(weight_string(cast(0xE0A1 as char)));
+select hex(weight_string(cast(0xE0A1 as char) as char(1)));
+
+set collation_connection=tis620_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+select hex(weight_string(cast(0xE0A1 as char)));
+select hex(weight_string(cast(0xE0A1 as char) as char(1)));
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_uca.test'
--- a/mysql-test/t/ctype_uca.test	2008-02-20 18:49:26 +0000
+++ b/mysql-test/t/ctype_uca.test	2010-05-28 08:13:40 +0000
@@ -213,6 +213,7 @@ select group_concat(c1 order by c1) from
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci;
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_esperanto_ci;
 select group_concat(c1 order by c1) from t1 group by c1 collate utf8_hungarian_ci;
+select group_concat(c1 order by c1) from t1 group by c1 collate utf8_german2_ci;
 
 drop table t1;
 
@@ -443,6 +444,55 @@ INSERT INTO t1 VALUES (CONVERT(_ucs2 0x0
 SELECT HEX(CONVERT(col1 USING ucs2)) FROM t1 ORDER BY col1 COLLATE utf8_persian_ci, col1 COLLATE utf8_bin;
 DROP TABLE t1;
 
+#
+# Test all characters that appear in utf8_persia_ci tailoring
+#
+CREATE TABLE t1 (
+  a VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_persian_ci,
+  offs INT NOT NULL
+);
+INSERT INTO t1 VALUES
+(_ucs2 0x066D, 1),(_ucs2 0x064E, 2),(_ucs2 0xFE76, 3),(_ucs2 0xFE77, 4),
+(_ucs2 0x0650, 5),(_ucs2 0xFE7A, 6),(_ucs2 0xFE7B, 7),(_ucs2 0x064F, 8),
+(_ucs2 0xFE78, 9),(_ucs2 0xFE79,10),(_ucs2 0x064B,11),(_ucs2 0xFE70,12),
+(_ucs2 0xFE71,13),(_ucs2 0x064D,14),(_ucs2 0xFE74,15),(_ucs2 0x064C,16),
+(_ucs2 0xFE72,17),
+
+(_ucs2 0xFE7F, 1),(_ucs2 0x0653, 2),(_ucs2 0x0654, 3),(_ucs2 0x0655, 4),
+(_ucs2 0x0670, 5),
+
+(_ucs2 0x0669, 1),(_ucs2 0x0622, 2),(_ucs2 0x0627, 3),(_ucs2 0x0671, 4),
+(_ucs2 0x0621, 5),(_ucs2 0x0623, 6),(_ucs2 0x0625, 7),(_ucs2 0x0624, 8),
+(_ucs2 0x0626, 9),
+
+(_ucs2 0x0642, 1),(_ucs2 0x06A9, 2),(_ucs2 0x0643, 3),
+
+(_ucs2 0x0648, 1),(_ucs2 0x0647, 2),(_ucs2 0x0629, 3),(_ucs2 0x06C0, 4),
+(_ucs2 0x06CC, 5),(_ucs2 0x0649, 6),(_ucs2 0x064A, 7),
+
+(_ucs2 0xFE80, 1),(_ucs2 0xFE81, 2),(_ucs2 0xFE82, 3),(_ucs2 0xFE8D, 4),
+(_ucs2 0xFE8E, 5),(_ucs2 0xFB50, 6),(_ucs2 0xFB51, 7),(_ucs2 0xFE80, 8),
+(_ucs2 0xFE83, 9),(_ucs2 0xFE84,10),(_ucs2 0xFE87,11),(_ucs2 0xFE88,12),
+(_ucs2 0xFE85,13),(_ucs2 0xFE86,14),(_ucs2 0x0689,16),(_ucs2 0x068A,17),
+
+(_ucs2 0xFEAE, 1),(_ucs2 0xFDFC, 2),
+
+(_ucs2 0xFED8, 1),(_ucs2 0xFB8E, 2),(_ucs2 0xFB8F, 3),(_ucs2 0xFB90, 4),
+(_ucs2 0xFB91, 5),(_ucs2 0xFED9, 6),(_ucs2 0xFEDA, 7),(_ucs2 0xFEDB, 8),
+(_ucs2 0xFEDC, 9),
+
+(_ucs2 0xFEEE, 1),(_ucs2 0xFEE9, 2),(_ucs2 0xFEEA, 3),(_ucs2 0xFEEB, 4),
+(_ucs2 0xFEEC, 5),(_ucs2 0xFE93, 6),(_ucs2 0xFE94, 7),(_ucs2 0xFBA4, 8),
+(_ucs2 0xFBA5, 9),(_ucs2 0xFBFC,10),(_ucs2 0xFBFD,11),(_ucs2 0xFBFE,12),
+(_ucs2 0xFBFF,13),(_ucs2 0xFEEF,14),(_ucs2 0xFEF0,15),(_ucs2 0xFEF1,16),
+(_ucs2 0xFEF2,17),(_ucs2 0xFEF3,18),(_ucs2 0xFEF4,19),(_ucs2 0xFEF5,20),
+(_ucs2 0xFEF6,21),(_ucs2 0xFEF7,22),(_ucs2 0xFEF8,23),(_ucs2 0xFEF9,24),
+(_ucs2 0xFEFA,25),(_ucs2 0xFEFB,26),(_ucs2 0xFEFC,27);
+
+SELECT HEX(CONVERT(a USING ucs2)), offs, hex(weight_string(a)), a
+FROM t1 ORDER BY a, offs, BINARY a;
+DROP TABLE t1;
+
 SET @test_character_set= 'utf8';
 SET @test_collation= 'utf8_swedish_ci';
 -- source include/ctype_common.inc
@@ -545,3 +595,40 @@ set collation_connection=ucs2_unicode_ci
 set names utf8;
 
 -- echo End for 5.0 tests
+--echo End of 5.1 tests
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=ucs2_unicode_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf8_unicode_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf8_czech_ci;
+--source include/weight_string_chde.inc
+
+set @@collation_connection=ucs2_czech_ci;
+--source include/weight_string_chde.inc
+
+--echo #
+--echo # Bug#53064 garbled data when using utf8_german2_ci collation
+--echo #
+CREATE TABLE t1 (s1 VARCHAR(10) COLLATE utf8_german2_ci); 
+INSERT INTO t1 VALUES ('a'),('ae'),('af');                 
+SELECT s1,hex(s1),hex(weight_string(s1)) FROM t1 ORDER BY s1; 
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_ucs.test'
--- a/mysql-test/t/ctype_ucs.test	2010-04-11 07:17:42 +0000
+++ b/mysql-test/t/ctype_ucs.test	2010-06-17 07:22:36 +0000
@@ -756,3 +756,51 @@ SET NAMES latin1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=ucs2_general_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set collation_connection=ucs2_bin;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+--echo #
+--echo # Bug #36418 Character sets: crash if char(256 using utf32)
+--echo #
+select hex(char(0x01 using ucs2));
+select hex(char(0x0102 using ucs2));
+select hex(char(0x010203 using ucs2));
+select hex(char(0x01020304 using ucs2));
+
+--echo #
+--echo # Bug#10094 Displays wrong error message for UNIQUE key index on CHAR(255) Unicode datatype
+--echo #
+CREATE TABLE t1 (f1 CHAR(255) unicode);
+INSERT INTO t1 values ('abc'),('bcd'),('abc');
+--error ER_DUP_ENTRY
+ALTER TABLE t1 ADD UNIQUE Index_1 (f1);
+DROP TABLE t1;
+
+--echo #
+--echo # Test how character set works with date/time
+--echo #
+SET collation_connection=ucs2_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_ujis.test'
--- a/mysql-test/t/ctype_ujis.test	2010-02-15 05:57:24 +0000
+++ b/mysql-test/t/ctype_ujis.test	2010-03-22 09:13:41 +0000
@@ -1213,6 +1213,7 @@ set names default;
 set character_set_database=default;
 set character_set_server=default;
 
+--echo End of 5.1 tests
 
 --echo #
 --echo # Start of 5.5 tests
@@ -1314,3 +1315,30 @@ DROP TABLE t1;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names ujis;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8EA1.inc
+--source include/weight_string_8FA2C3.inc
+
+set collation_connection=ujis_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+--source include/weight_string_A1A1.inc
+--source include/weight_string_8EA1.inc
+--source include/weight_string_8FA2C3.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_utf16.test'
--- a/mysql-test/t/ctype_utf16.test	2010-06-02 12:23:50 +0000
+++ b/mysql-test/t/ctype_utf16.test	2010-06-17 07:22:36 +0000
@@ -752,3 +752,29 @@ DROP TABLE t1, t2;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=utf16_general_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+select hex(weight_string(_utf16 0xD800DC00));
+select hex(weight_string(_utf16 0xD800DC01));
+--source include/weight_string_l1.inc
+
+set collation_connection=utf16_bin;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+

=== modified file 'mysql-test/t/ctype_utf16_uca.test'
--- a/mysql-test/t/ctype_utf16_uca.test	2010-02-24 09:15:34 +0000
+++ b/mysql-test/t/ctype_utf16_uca.test	2010-03-22 09:13:41 +0000
@@ -288,3 +288,35 @@ set collation_connection=utf16_unicode_c
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=utf16_unicode_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+select hex(weight_string(_utf16 0xD800DC00 collate utf16_unicode_ci));
+select hex(weight_string(_utf16 0xD800DC01 collate utf16_unicode_ci));
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf16_czech_ci;
+--source include/weight_string_chde.inc
+
+#
+# WL#4013 Unicode german2 collation
+#
+SET NAMES utf8;
+SET collation_connection=utf16_german2_ci;
+--source include/ctype_german.inc
+
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_utf32.test'
--- a/mysql-test/t/ctype_utf32.test	2010-06-02 12:23:50 +0000
+++ b/mysql-test/t/ctype_utf32.test	2010-06-17 07:22:36 +0000
@@ -803,3 +803,30 @@ DROP TABLE t1, t2;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=utf32_general_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+select hex(weight_string(_utf32 0x10000));
+select hex(weight_string(_utf32 0x10001));
+--source include/weight_string_l1.inc
+
+set collation_connection=utf32_bin;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+
+

=== modified file 'mysql-test/t/ctype_utf32_uca.test'
--- a/mysql-test/t/ctype_utf32_uca.test	2010-02-24 09:15:34 +0000
+++ b/mysql-test/t/ctype_utf32_uca.test	2010-03-22 09:13:41 +0000
@@ -289,3 +289,33 @@ set collation_connection=utf32_unicode_c
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set collation_connection=utf32_unicode_ci;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+select hex(weight_string(_utf32 0x10000 collate utf32_unicode_ci));
+select hex(weight_string(_utf32 0x10001 collate utf32_unicode_ci));
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf32_czech_ci;
+--source include/weight_string_chde.inc
+
+#
+# WL#4013 Unicode german2 collation
+#
+SET NAMES utf8;
+SET collation_connection=utf32_german2_ci;
+--source include/ctype_german.inc
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/ctype_utf8.test'
--- a/mysql-test/t/ctype_utf8.test	2010-06-02 12:23:50 +0000
+++ b/mysql-test/t/ctype_utf8.test	2010-06-17 07:22:36 +0000
@@ -1161,6 +1161,26 @@ explain
 select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
 drop table t1;
 
+#
+# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes
+# MySQL to hang
+#
+
+SET CHARACTER SET utf8;
+SHOW VARIABLES LIKE 'character\_set\_%';
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8);
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+
 # End of 4.1 tests
 
 #
@@ -1508,3 +1528,39 @@ DROP TABLE t1, t2;
 --echo #
 --echo # End of 5.5 tests
 --echo #
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#3664 WEIGHT_STRING
+--echo #
+
+set names utf8;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf8_bin;
+--source include/weight_string.inc
+--source include/weight_string_euro.inc
+--source include/weight_string_l1.inc
+
+--echo #
+--echo # Checking strnxfrm() with odd length
+--echo #
+set max_sort_length=5;
+select @@max_sort_length;
+create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+alter table t1 modify a varchar(128) character set utf8 collate utf8_bin;
+select * from t1 order by a;
+drop table t1;
+set max_sort_length=default;
+
+--echo #
+--echo # End of 5.6 tests
+--echo #
+

=== added file 'mysql-test/t/func_weight_string.test'
--- a/mysql-test/t/func_weight_string.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/func_weight_string.test	2010-03-22 09:13:41 +0000
@@ -0,0 +1,106 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set names latin1;
+
+#
+# If it's BLOB or BINARY or VARBINARY, then output = input.
+#
+select hex(weight_string(0x010203));
+
+#
+# "AS CHAR ( int )" causes padding on the right. The pad
+# character is always space, that is, 0x20 or 0x0020.
+# The padding occurs before the conversion to a weight.
+# The value of "int" is the number of characters, not the number of bytes.
+#
+select hex(weight_string('aa' as char(3)));
+
+#
+# The minimum value of 'int' is 1.
+#
+--error 1064
+select hex(weight_string('a' as char(-1)));
+--error 1064
+select hex(weight_string('a' as char(0)));
+select hex(weight_string('a' as char(1)));
+
+#
+# If 'int' is smaller than the length of 'string',
+# truncation will occur with no warning.
+#
+select hex(weight_string('ab' as char(1)));
+
+#
+# If "AS CHAR ( int )" is omitted, there is no padding and no truncation.
+#
+select hex(weight_string('ab'));
+
+#
+# "AS BINARY ( int )" is like CHAR(int) but causes padding of 0x00
+# so one doesn't have to use "CAST(string AS BINARY(int))".
+#
+select hex(weight_string('aa' as binary(3)));
+select hex(weight_string(cast('aa' as binary(3))));
+
+#
+# If and only if one specifies "LEVEL numeric-list" (not "range"),
+# one may follow any "number" with [ASC|DESC][REVERSE]
+#
+--error 1064
+select hex(weight_string('ab' level 1-1 ASC));
+--error 1064
+select hex(weight_string('ab' level 1-1 DESC));
+--error 1064
+select hex(weight_string('ab' level 1-1 REVERSE));
+
+#
+# If one says "DESC", then the weights come out NOTed
+# or negated for that level. 
+# If one says "REVERSE", then the weights come out in
+# reverse order for that level, that is, starting with
+# the last character and ending with the first character.
+#
+select hex(weight_string('ab' level 1 ASC));
+select hex(weight_string('ab' level 1 DESC));
+select hex(weight_string('ab' level 1 REVERSE));
+select hex(weight_string('ab' level 1 DESC REVERSE));
+
+#
+# If the result length is less than or equal to the
+# maximum possible length for the VARBINARY data type,
+# then the result data type is VARBINARY. Otherwise
+# the result data type is BLOB.
+#
+create table t1 select weight_string('test') as w;
+show create table t1;
+drop table t1;
+create table t1 select weight_string(repeat('t',66000)) as w;
+show create table t1;
+drop table t1;
+
+#
+# If input is NULL, then output is NULL.
+#
+select weight_string(NULL);
+
+#    
+# WEIGHT_STRING and REVERSE will not be a new reserved word.
+#
+select 1 as weight_string, 2 as reverse;
+
+#
+# Check that collation derivation is copied from the argument
+#
+select coercibility(weight_string('test'));
+select coercibility(weight_string('test' collate latin1_swedish_ci));
+
+#
+# Bug#33663 Character sets: weight_string function,
+# varchar column, wrong result
+#
+create table t1 (s1 varchar(5));
+insert into t1 values ('a'),(null);
+select hex(weight_string(s1)) from t1 order by s1;
+drop table t1;

=== modified file 'mysql-test/t/locale.test'
--- a/mysql-test/t/locale.test	2009-11-06 09:52:45 +0000
+++ b/mysql-test/t/locale.test	2010-03-25 06:36:22 +0000
@@ -54,3 +54,60 @@ SELECT DATE_FORMAT('2001-01-05', '%w %a 
 SELECT DATE_FORMAT('2001-01-06', '%w %a %W');
 SELECT DATE_FORMAT('2001-01-07', '%w %a %W');
 --echo End of 5.4 tests
+
+
+--echo #
+--echo # Start of 5.6 tests
+--echo #
+
+--echo #
+--echo # WL#5303 Romansh locale for DAYNAME, MONTHNAME, DATE_FORMAT
+--echo #
+
+SET NAMES utf8;
+SET @old_50915_lc_time_names := @@lc_time_names;
+SET lc_time_names=en_US;
+SELECT DATE_FORMAT('2001-01-01', '%w %a %W');
+SELECT DATE_FORMAT('2001-03-01', '%c %b %M');
+SET lc_time_names=rm_CH;
+SELECT DATE_FORMAT('2001-01-01', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-02', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-03', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-04', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-05', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-06', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-07', '%w %a %W');
+SELECT DATE_FORMAT('2001-01-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-02-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-03-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-04-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-05-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-06-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-07-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-08-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-09-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-10-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-11-01', '%c %b %M');
+SELECT DATE_FORMAT('2001-12-01', '%c %b %M');
+SET lc_time_names=de_CH;
+SELECT DATE_FORMAT('2001-01-06', '%w %a %W');
+SELECT DATE_FORMAT('2001-09-01', '%c %b %M');
+
+# Checking AM/PM
+SELECT DATE_FORMAT('2010-03-23 11:00:00','%h %p');
+SELECT DATE_FORMAT('2010-03-23 13:00:00','%h %p');
+
+# Checking numeric format
+SELECT format(123456789,2,'rm_CH');
+
+# Checking that error messages point to en_US.
+SET lc_messages=rm_CH;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM non_existent;
+
+SET lc_time_names=@old_50915_lc_time_names;
+
+
+--echo #
+--echo # End of 5.6 tests
+--echo #

=== modified file 'mysql-test/t/variables.test'
--- a/mysql-test/t/variables.test	2010-06-04 16:09:50 +0000
+++ b/mysql-test/t/variables.test	2010-06-17 07:22:36 +0000
@@ -564,11 +564,11 @@ set lc_time_names=NULL;
 set lc_time_names=-1;
 select @@lc_time_names;
 --echo LC_TIME_NAMES: testing locale with the last ID:
-set lc_time_names=109;
+set lc_time_names=110;
 select @@lc_time_names;
 --echo LC_TIME_NAMES: testing a number beyond the valid ID range:
 --error ER_UNKNOWN_LOCALE
-set lc_time_names=110;
+set lc_time_names=111;
 select @@lc_time_names;
 --echo LC_TIME_NAMES: testing that 0 is en_US:
 set lc_time_names=0;

=== modified file 'mysys/charset-def.c'
--- a/mysys/charset-def.c	2010-02-24 09:15:34 +0000
+++ b/mysys/charset-def.c	2010-03-22 09:13:41 +0000
@@ -24,6 +24,7 @@
 #ifdef HAVE_UCA_COLLATIONS
 
 #ifdef HAVE_CHARSET_ucs2
+extern CHARSET_INFO my_charset_ucs2_german2_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_icelandic_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_latvian_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_romanian_uca_ci;
@@ -43,10 +44,11 @@ extern CHARSET_INFO my_charset_ucs2_pers
 extern CHARSET_INFO my_charset_ucs2_esperanto_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_hungarian_uca_ci;
 extern CHARSET_INFO my_charset_ucs2_sinhala_uca_ci;
-#endif
+#endif /* HAVE_CHARSET_ucs2 */
 
 
 #ifdef HAVE_CHARSET_utf32
+extern CHARSET_INFO my_charset_utf32_german2_uca_ci;
 extern CHARSET_INFO my_charset_utf32_icelandic_uca_ci;
 extern CHARSET_INFO my_charset_utf32_latvian_uca_ci;
 extern CHARSET_INFO my_charset_utf32_romanian_uca_ci;
@@ -70,6 +72,7 @@ extern CHARSET_INFO my_charset_utf32_sin
 
 
 #ifdef HAVE_CHARSET_utf16
+extern CHARSET_INFO my_charset_utf16_german2_uca_ci;
 extern CHARSET_INFO my_charset_utf16_icelandic_uca_ci;
 extern CHARSET_INFO my_charset_utf16_latvian_uca_ci;
 extern CHARSET_INFO my_charset_utf16_romanian_uca_ci;
@@ -93,6 +96,7 @@ extern CHARSET_INFO my_charset_utf16_sin
 
 
 #ifdef HAVE_CHARSET_utf8
+extern CHARSET_INFO my_charset_utf8_german2_uca_ci;
 extern CHARSET_INFO my_charset_utf8_icelandic_uca_ci;
 extern CHARSET_INFO my_charset_utf8_latvian_uca_ci;
 extern CHARSET_INFO my_charset_utf8_romanian_uca_ci;
@@ -118,6 +122,7 @@ extern CHARSET_INFO my_charset_utf8_gene
 #endif
 
 #ifdef HAVE_CHARSET_utf8mb4
+extern CHARSET_INFO my_charset_utf8mb4_german2_uca_ci;
 extern CHARSET_INFO my_charset_utf8mb4_icelandic_uca_ci;
 extern CHARSET_INFO my_charset_utf8mb4_latvian_uca_ci;
 extern CHARSET_INFO my_charset_utf8mb4_romanian_uca_ci;
@@ -205,6 +210,7 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_ucs2_bin);
 #ifdef HAVE_UCA_COLLATIONS
   add_compiled_collation(&my_charset_ucs2_unicode_ci);
+  add_compiled_collation(&my_charset_ucs2_german2_uca_ci);
   add_compiled_collation(&my_charset_ucs2_icelandic_uca_ci);
   add_compiled_collation(&my_charset_ucs2_latvian_uca_ci);
   add_compiled_collation(&my_charset_ucs2_romanian_uca_ci);
@@ -240,6 +246,7 @@ my_bool init_compiled_charsets(myf flags
 #endif
 #ifdef HAVE_UCA_COLLATIONS
   add_compiled_collation(&my_charset_utf8_unicode_ci);
+  add_compiled_collation(&my_charset_utf8_german2_uca_ci);
   add_compiled_collation(&my_charset_utf8_icelandic_uca_ci);
   add_compiled_collation(&my_charset_utf8_latvian_uca_ci);
   add_compiled_collation(&my_charset_utf8_romanian_uca_ci);
@@ -268,6 +275,7 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf8mb4_bin);
 #ifdef HAVE_UCA_COLLATIONS
   add_compiled_collation(&my_charset_utf8mb4_unicode_ci);
+  add_compiled_collation(&my_charset_utf8mb4_german2_uca_ci);
   add_compiled_collation(&my_charset_utf8mb4_icelandic_uca_ci);
   add_compiled_collation(&my_charset_utf8mb4_latvian_uca_ci);
   add_compiled_collation(&my_charset_utf8mb4_romanian_uca_ci);
@@ -296,6 +304,7 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf16_bin);
 #ifdef HAVE_UCA_COLLATIONS
   add_compiled_collation(&my_charset_utf16_unicode_ci);
+  add_compiled_collation(&my_charset_utf16_german2_uca_ci);
   add_compiled_collation(&my_charset_utf16_icelandic_uca_ci);
   add_compiled_collation(&my_charset_utf16_latvian_uca_ci);
   add_compiled_collation(&my_charset_utf16_romanian_uca_ci);
@@ -324,6 +333,7 @@ my_bool init_compiled_charsets(myf flags
   add_compiled_collation(&my_charset_utf32_bin);
 #ifdef HAVE_UCA_COLLATIONS
   add_compiled_collation(&my_charset_utf32_unicode_ci);
+  add_compiled_collation(&my_charset_utf32_german2_uca_ci);
   add_compiled_collation(&my_charset_utf32_icelandic_uca_ci);
   add_compiled_collation(&my_charset_utf32_latvian_uca_ci);
   add_compiled_collation(&my_charset_utf32_romanian_uca_ci);

=== modified file 'mysys/charset.c'
--- a/mysys/charset.c	2010-03-24 15:03:44 +0000
+++ b/mysys/charset.c	2010-06-17 07:22:36 +0000
@@ -246,7 +246,9 @@ static int add_collation(CHARSET_INFO *c
         return MY_XML_ERROR;
 
       newcs->caseup_multiply= newcs->casedn_multiply= 1;
-
+      newcs->levels_for_compare= 1;
+      newcs->levels_for_order= 1;
+      
       if (!strcmp(cs->csname,"ucs2") )
       {
 #if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS)

=== modified file 'scripts/mysqld_safe.sh'
--- a/scripts/mysqld_safe.sh	2010-05-20 12:41:01 +0000
+++ b/scripts/mysqld_safe.sh	2010-06-16 13:39:30 +0000
@@ -704,7 +704,7 @@ fi
 
 cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
 
-plugin_dir="${PLUGIN_DIR:-$MY_BASEDIR_VERSION/lib/plugin}${PLUGIN_VARIANT}"
+plugin_dir="${PLUGIN_DIR:-$MY_BASEDIR_VERSION/lib/mysql/plugin}${PLUGIN_VARIANT}"
 
 for i in  "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \
   "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION"

=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-06-07 09:14:56 +0000
+++ b/sql/field.cc	2010-06-17 07:22:36 +0000
@@ -6575,7 +6575,11 @@ int Field_string::cmp(const uchar *a_ptr
 void Field_string::sort_string(uchar *to,uint length)
 {
   uint tmp __attribute__((unused))=
-    my_strnxfrm(field_charset, to, length, ptr, field_length);
+    field_charset->coll->strnxfrm(field_charset,
+                                  to, length, char_length(),
+                                  ptr, field_length,
+                                  MY_STRXFRM_PAD_WITH_SPACE |
+                                  MY_STRXFRM_PAD_TO_MAXLEN);
   DBUG_ASSERT(tmp == length);
 }
 
@@ -7029,9 +7033,11 @@ void Field_varstring::sort_string(uchar 
     length-= length_bytes;
   }
  
-  tot_length= my_strnxfrm(field_charset,
-			  to, length, ptr + length_bytes,
-			  tot_length);
+  tot_length= field_charset->coll->strnxfrm(field_charset,
+                                            to, length, char_length(),
+                                            ptr + length_bytes, tot_length,
+                                            MY_STRXFRM_PAD_WITH_SPACE |
+                                            MY_STRXFRM_PAD_TO_MAXLEN);
   DBUG_ASSERT(tot_length == length);
 }
 
@@ -7742,8 +7748,11 @@ void Field_blob::sort_string(uchar *to,u
     }
     memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
     
-    blob_length=my_strnxfrm(field_charset,
-                            to, length, blob, blob_length);
+    blob_length= field_charset->coll->strnxfrm(field_charset,
+                                               to, length, length,
+                                               blob, blob_length,
+                                               MY_STRXFRM_PAD_WITH_SPACE |
+                                               MY_STRXFRM_PAD_TO_MAXLEN);
     DBUG_ASSERT(blob_length == length);
   }
 }

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2010-04-29 20:33:06 +0000
+++ b/sql/filesort.cc	2010-06-17 07:22:36 +0000
@@ -836,8 +836,11 @@ static void make_sortkey(register SORTPA
             memcpy(param->tmp_buffer,from,length);
             from=param->tmp_buffer;
           }
-          tmp_length= my_strnxfrm(cs,to,sort_field->length,
-                                  (uchar*) from, length);
+          tmp_length= cs->coll->strnxfrm(cs, to, sort_field->length,
+                                         item->max_char_length(),
+                                         (uchar*) from, length,
+                                         MY_STRXFRM_PAD_WITH_SPACE |
+                                         MY_STRXFRM_PAD_TO_MAXLEN);
           DBUG_ASSERT(tmp_length == sort_field->length);
         }
         else

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2010-05-12 07:09:20 +0000
+++ b/sql/item_strfunc.cc	2010-06-17 07:22:36 +0000
@@ -3076,6 +3076,61 @@ String *Item_func_collation::val_str(Str
 }
 
 
+void Item_func_weight_string::fix_length_and_dec()
+{
+  CHARSET_INFO *cs= args[0]->collation.collation;
+  collation.set(&my_charset_bin, args[0]->collation.derivation);
+  flags= my_strxfrm_flag_normalize(flags, cs->levels_for_order);
+  /* 
+    Use result_length if it was given explicitly in constructor,
+    otherwise calculate max_length using argument's max_length
+    and "nweights".
+  */
+  max_length= result_length ? result_length :
+              cs->mbmaxlen * max(args[0]->max_length, nweights);
+  maybe_null= 1;
+}
+
+
+/* Return a weight_string according to collation */
+String *Item_func_weight_string::val_str(String *str)
+{
+  String *res;
+  CHARSET_INFO *cs= args[0]->collation.collation;
+  uint tmp_length, frm_length;
+  DBUG_ASSERT(fixed == 1);
+
+  if (args[0]->result_type() != STRING_RESULT ||
+      !(res= args[0]->val_str(str)))
+    goto nl;
+  
+  /*
+    Use result_length if it was given in constructor
+    explicitly, otherwise calculate result length
+    from argument and "nweights".
+  */
+  tmp_length= result_length ? result_length :
+              cs->coll->strnxfrmlen(cs, cs->mbmaxlen *
+                                    max(res->length(), nweights));
+
+  if (tmp_value.alloc(tmp_length))
+    goto nl;
+
+  frm_length= cs->coll->strnxfrm(cs,
+                                 (uchar*) tmp_value.ptr(), tmp_length,
+                                 nweights ? nweights : tmp_length,
+                                 (const uchar*) res->ptr(), res->length(),
+                                 flags);
+  tmp_value.length(frm_length);
+  null_value= 0;
+  return &tmp_value;
+
+nl:
+  null_value= 1;
+  return 0;
+}
+
+
 String *Item_func_hex::val_str(String *str)
 {
   String *res;

=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h	2010-04-27 10:01:45 +0000
+++ b/sql/item_strfunc.h	2010-06-17 07:22:36 +0000
@@ -831,6 +831,26 @@ public:
   table_map not_null_tables() const { return 0; }
 };
 
+class Item_func_weight_string :public Item_str_func
+{
+  String tmp_value;
+  uint flags;
+  uint nweights;
+  uint result_length;
+public:
+  Item_func_weight_string(Item *a, uint result_length_arg,
+                          uint nweights_arg, uint flags_arg)
+  :Item_str_func(a)
+  {
+    nweights= nweights_arg;
+    flags= flags_arg;
+    result_length= result_length_arg;
+  }
+  const char *func_name() const { return "weight_string"; }
+  String *val_str(String *);
+  void fix_length_and_dec();
+};
+
 class Item_func_crc32 :public Item_int_func
 {
   String value;

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2010-02-20 09:40:21 +0000
+++ b/sql/lex.h	2010-03-22 09:13:41 +0000
@@ -462,6 +462,7 @@ static SYMBOL symbols[] = {
   { "RESUME",           SYM(RESUME_SYM)},
   { "RETURN",           SYM(RETURN_SYM)},
   { "RETURNS",		SYM(RETURNS_SYM)},
+  { "REVERSE",		SYM(REVERSE_SYM)},
   { "REVOKE",		SYM(REVOKE)},
   { "RIGHT",		SYM(RIGHT)},
   { "RLIKE",		SYM(REGEXP)},	/* Like in mSQL2 */
@@ -602,6 +603,7 @@ static SYMBOL symbols[] = {
   { "WAIT",		SYM(WAIT_SYM)},
   { "WARNINGS",		SYM(WARNINGS)},
   { "WEEK",		SYM(WEEK_SYM)},
+  { "WEIGHT_STRING",	SYM(WEIGHT_STRING_SYM)},
   { "WHEN",		SYM(WHEN_SYM)},
   { "WHERE",		SYM(WHERE)},
   { "WHILE",            SYM(WHILE_SYM)},

=== modified file 'sql/sql_locale.cc'
--- a/sql/sql_locale.cc	2010-03-31 14:05:33 +0000
+++ b/sql/sql_locale.cc	2010-06-17 07:22:36 +0000
@@ -3247,6 +3247,75 @@ MY_LOCALE my_locale_el_GR
 );
 /***** LOCALE END el_GR *****/
 
+
+/***** LOCALE BEGIN rm_CH: Romansh - Switzerland *****/
+static const char *my_locale_month_names_rm_CH[13]=
+{
+  "schaner", "favrer", "mars",      "avrigl",  "matg",     "zercladur",
+  "fanadur", "avust",  "settember", "october", "november", "december", NullS
+};
+
+static const char *my_locale_ab_month_names_rm_CH[13]=
+{
+  "schan", "favr",  "mars", "avr", "matg", "zercl",
+  "fan",   "avust", "sett", "oct", "nov",  "dec", NullS
+};
+
+static const char *my_locale_day_names_rm_CH[8]=
+{
+  "glindesdi", "mardi", "mesemna", "gievgia",
+  "venderdi",  "sonda", "dumengia", NullS
+};
+
+static const char *my_locale_ab_day_names_rm_CH[8]=
+{
+  "gli", "ma", "me", "gie", "ve", "so", "du", NullS
+};
+
+static TYPELIB my_locale_typelib_month_names_rm_CH=
+{
+  array_elements(my_locale_month_names_rm_CH) - 1,
+  "", my_locale_month_names_rm_CH, NULL
+};
+
+static TYPELIB my_locale_typelib_ab_month_names_rm_CH=
+{
+  array_elements(my_locale_ab_month_names_rm_CH) - 1,
+  "", my_locale_ab_month_names_rm_CH, NULL
+};
+
+static TYPELIB my_locale_typelib_day_names_rm_CH=
+{
+  array_elements(my_locale_day_names_rm_CH) - 1,
+   "", my_locale_day_names_rm_CH, NULL
+};
+
+static TYPELIB my_locale_typelib_ab_day_names_rm_CH=
+{
+  array_elements(my_locale_ab_day_names_rm_CH) - 1,
+  "", my_locale_ab_day_names_rm_CH, NULL
+};
+
+MY_LOCALE my_locale_rm_CH
+(
+  110,
+  "rm_CH",
+  "Romansh - Switzerland",
+  FALSE,
+  &my_locale_typelib_month_names_rm_CH,
+  &my_locale_typelib_ab_month_names_rm_CH,
+  &my_locale_typelib_day_names_rm_CH,
+  &my_locale_typelib_ab_day_names_rm_CH,
+  9,          /* max mon name length */ 
+  9,          /* max day name length */
+  ',',        /* decimal point rm_CH */
+  '\'',       /* thousands_sep rm_CH */
+  "\x03\x03", /* grouping      rm_CH */
+  &global_errmsgs[en_US]
+);
+/***** LOCALE END rm_CH *****/
+
+
 /*
   The list of all locales.
   Note, locales must be ordered according to their
@@ -3365,6 +3434,7 @@ MY_LOCALE *my_locales[]=
     &my_locale_sv_FI,
     &my_locale_zh_HK,
     &my_locale_el_GR,
+    &my_locale_rm_CH,
     NULL 
   };
 

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-06-15 08:16:08 +0000
+++ b/sql/sql_yacc.yy	2010-06-17 07:22:36 +0000
@@ -1224,6 +1224,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  RESUME_SYM
 %token  RETURNS_SYM                   /* SQL-2003-R */
 %token  RETURN_SYM                    /* SQL-2003-R */
+%token  REVERSE_SYM
 %token  REVOKE                        /* SQL-2003-R */
 %token  RIGHT                         /* SQL-2003-R */
 %token  ROLLBACK_SYM                  /* SQL-2003-R */
@@ -1369,6 +1370,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  WAIT_SYM
 %token  WARNINGS
 %token  WEEK_SYM
+%token  WEIGHT_STRING_SYM
 %token  WHEN_SYM                      /* SQL-2003-R */
 %token  WHERE                         /* SQL-2003-R */
 %token  WHILE_SYM
@@ -1443,6 +1445,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %type <ulong_num>
         ulong_num real_ulong_num merge_insert_types
+        ws_nweights
+        ws_level_flag_desc ws_level_flag_reverse ws_level_flags
+        opt_ws_levels ws_level_list ws_level_list_item ws_level_number
+        ws_level_range ws_level_list_or_range  
 
 %type <ulonglong_number>
         ulonglong_num real_ulonglong_num size_number
@@ -5868,6 +5874,73 @@ opt_bin_mod:
         | BINARY { Lex->type|= BINCMP_FLAG; }
         ;
 
+ws_nweights:
+        '(' real_ulong_num
+        {
+          if ($2 == 0)
+          {
+            my_parse_error(ER(ER_SYNTAX_ERROR));
+            MYSQL_YYABORT;
+          }
+        }
+        ')'
+        { $$= $2; }
+        ;
+
+ws_level_flag_desc:
+        ASC { $$= 0; }
+        | DESC { $$= 1 << MY_STRXFRM_DESC_SHIFT; }
+        ;
+
+ws_level_flag_reverse:
+        REVERSE_SYM { $$= 1 << MY_STRXFRM_REVERSE_SHIFT; } ;
+
+ws_level_flags:
+        /* empty */ { $$= 0; }
+        | ws_level_flag_desc { $$= $1; }
+        | ws_level_flag_desc ws_level_flag_reverse { $$= $1 | $2; }
+        | ws_level_flag_reverse { $$= $1 ; }
+        ;
+
+ws_level_number:
+        real_ulong_num
+        {
+          $$= $1 < 1 ? 1 : ($1 > MY_STRXFRM_NLEVELS ? MY_STRXFRM_NLEVELS : $1);
+          $$--;
+        }
+        ;
+
+ws_level_list_item:
+        ws_level_number ws_level_flags
+        {
+          $$= (1 | $2) << $1;
+        }
+        ;
+
+ws_level_list:
+        ws_level_list_item { $$= $1; }
+        | ws_level_list ',' ws_level_list_item { $$|= $3; }
+        ;
+
+ws_level_range:
+        ws_level_number '-' ws_level_number
+        {
+          uint start= $1;
+          uint end= $3;
+          for ($$= 0; start <= end; start++)
+            $$|= (1 << start);
+        }
+        ;
+
+ws_level_list_or_range:
+        ws_level_list { $$= $1; }
+        | ws_level_range { $$= $1; }
+        ;
+
+opt_ws_levels:
+        /* empty*/ { $$= 0; }
+        | LEVEL_SYM ws_level_list_or_range { $$= $2; }
+        ;
 
 opt_primary:
           /* empty */
@@ -8423,6 +8496,12 @@ function_call_conflict:
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
+        | REVERSE_SYM '(' expr ')'
+          {
+            $$= new (YYTHD->mem_root) Item_func_reverse($3);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
         | TRUNCATE_SYM '(' expr ',' expr ')'
           {
             $$= new (YYTHD->mem_root) Item_func_round($3,$5,1);
@@ -8447,6 +8526,36 @@ function_call_conflict:
             if ($$ == NULL)
               MYSQL_YYABORT;
           }
+        | WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
+          {
+            $$= new (YYTHD->mem_root) Item_func_weight_string($3, 0, 0, $4);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        | WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
+          {
+            $$= new (YYTHD->mem_root)
+                Item_func_weight_string($3, 0, $6,
+                                        $7 | MY_STRXFRM_PAD_WITH_SPACE);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        | WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
+          {
+            Item *item= new (YYTHD->mem_root) Item_char_typecast($3, $6, &my_charset_bin);
+            if (item == NULL)
+              MYSQL_YYABORT;
+            $$= new (YYTHD->mem_root)
+                Item_func_weight_string(item, 0, $6, MY_STRXFRM_PAD_WITH_SPACE);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
+        | WEIGHT_STRING_SYM '(' expr ',' ulong_num ',' ulong_num ',' ulong_num ')'
+          {
+            $$= new (YYTHD->mem_root) Item_func_weight_string($3, $5, $7, $9);
+            if ($$ == NULL)
+              MYSQL_YYABORT;
+          }
         | geometry_function
           {
 #ifdef HAVE_SPATIAL
@@ -12464,6 +12573,7 @@ keyword_sp:
         | RESOURCES                {}
         | RESUME_SYM               {}
         | RETURNS_SYM              {}
+        | REVERSE_SYM              {}
         | ROLLUP_SYM               {}
         | ROUTINE_SYM              {}
         | ROWS_SYM                 {}
@@ -12532,6 +12642,7 @@ keyword_sp:
         | WAIT_SYM                 {}
         | WEEK_SYM                 {}
         | WORK_SYM                 {}
+        | WEIGHT_STRING_SYM        {}
         | X509_SYM                 {}
         | XML_SYM                  {}
         | YEAR_SYM                 {}

=== modified file 'storage/ndb/src/common/util/NdbSqlUtil.cpp'
--- a/storage/ndb/src/common/util/NdbSqlUtil.cpp	2007-02-23 11:28:34 +0000
+++ b/storage/ndb/src/common/util/NdbSqlUtil.cpp	2010-03-22 09:13:41 +0000
@@ -997,13 +997,15 @@ NdbSqlUtil::strnxfrm_bug7284(CHARSET_INF
   if (n1 <= 0)
     return -1;
   // strxfrm to binary
-  int n2 = (*cs->coll->strnxfrm)(cs, xsp, sizeof(xsp), nsp, n1);
+  int n2 = (*cs->coll->strnxfrm)(cs, xsp, sizeof(xsp), sizeof(xsp),
+                                 nsp, n1, MY_STRXFRM_PAD_WITH_SPACE);
   if (n2 <= 0)
     return -1;
   // XXX bug workaround - strnxfrm may not write full string
   memset(dst, 0x0, dstLen);
   // strxfrm argument string - returns no error indication
-  int n3 = (*cs->coll->strnxfrm)(cs, dst, dstLen, src, srcLen);
+  int n3 = (*cs->coll->strnxfrm)(cs, dst, dstLen, dstLen,
+                                 src, srcLen, MY_STRXFRM_PAD_WITH_SPACE);
   // pad with strxfrm-ed space chars
   int n4 = n3;
   while (n4 < (int)dstLen) {

=== modified file 'strings/conf_to_src.c'
--- a/strings/conf_to_src.c	2009-10-15 10:17:32 +0000
+++ b/strings/conf_to_src.c	2010-03-22 09:13:41 +0000
@@ -238,6 +238,8 @@ void dispcset(FILE *f,CHARSET_INFO *cs)
   fprintf(f,"  255,                        /* max_sort_char */\n");
   fprintf(f,"  ' ',                        /* pad_char      */\n");
   fprintf(f,"  0,                          /* escape_with_backslash_is_dangerous */\n");
+  fprintf(f,"  1,                          /* levels_for_compare */\n");
+  fprintf(f,"  1,                          /* levels_for_order   */\n");
   
   fprintf(f,"  &my_charset_8bit_handler,\n");
   if (cs->state & MY_CS_BINSORT)

=== modified file 'strings/ctype-big5.c'
--- a/strings/ctype-big5.c	2010-01-14 11:17:57 +0000
+++ b/strings/ctype-big5.c	2010-03-22 09:13:41 +0000
@@ -918,80 +918,36 @@ static int my_strnncollsp_big5(CHARSET_I
 }
 
 
-static size_t my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)),
-                               uchar *dest, size_t len, 
-                               const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_big5(CHARSET_INFO *cs,
+                 uchar *dst, size_t dstlen, uint nweights,
+                 const uchar *src, size_t srclen, uint flags)
 {
-  uint16 e;
-  size_t dstlen= len;
-  uchar *dest_end= dest + dstlen;
-
-  len = srclen;
-  while (len-- && dest < dest_end)
-  {
-    if ((len > 0) && isbig5code(*src, *(src+1)))
-    {
-      e = big5strokexfrm((uint16) big5code(*src, *(src+1)));
-      *dest++ = big5head(e);
-      if (dest < dest_end)
-        *dest++ = big5tail(e);
-      src +=2;
-      len--;
-    } else
-      *dest++ = sort_order_big5[(uchar) *src++];
-  }
-  if (dstlen > srclen)
-    bfill(dest, dstlen - srclen, ' ');
-  return dstlen;
-}
-
-#if 0
-static int my_strcoll_big5(const uchar *s1, const uchar *s2)
-{
-
-  while (*s1 && *s2)
-  {
-    if (*(s1+1) && *(s2+1) && isbig5code(*s1,*(s1+1)) && isbig5code(*s2, *(s2+1)))
-    {
-      if (*s1 != *s2 || *(s1+1) != *(s2+1))
-	return ((int) big5code(*s1,*(s1+1)) -
-		(int) big5code(*s2,*(s2+1)));
-      s1 +=2;
-      s2 +=2;
-    } else if (sort_order_big5[(uchar) *s1++] != sort_order_big5[(uchar) *s2++])
-      return ((int) sort_order_big5[(uchar) s1[-1]] -
-	      (int) sort_order_big5[(uchar) s2[-1]]);
-  }
-  return 0;
-}
-
-static int my_strxfrm_big5(uchar *dest, const uchar *src, int len)
-{
-  uint16 e;
-  uchar *d = dest;
-
-  if (len < 1) return 0;
-  if (!*src)
-  {
-    *d = '\0';
-    return 0;
-  }
-  while (*src && (len > 1))
+  uchar *d0= dst;
+  uchar *de= dst + dstlen;
+  const uchar *se= src + srclen;
+  const uchar *sort_order= cs->sort_order;
+  
+  for (; dst < de && src < se && nweights; nweights--)
   {
-    if (*(src+1) && isbig5code(*src, *(src+1)))
+    if (cs->cset->ismbchar(cs, (const char*) src, (const char*) se))
     {
-      e = big5strokexfrm((uint16) big5code(*src, *(src+1)));
-      *d++ = big5head(e);
-      *d++ = big5tail(e);
-      src +=2;
-      len--;
-    } else
-      *d++ = sort_order_big5[(uchar) *src++];
+      /*
+        Note, it is safe not to check (src < se)
+        in the code below, because ismbchar() would
+        not return TRUE if src was too short
+      */
+      uint16 e= big5strokexfrm((uint16) big5code(*src, *(src + 1)));
+      *dst++= big5head(e);
+      if (dst < de)
+        *dst++= big5tail(e);
+      src+= 2;
+    }
+    else
+      *dst++= sort_order ? sort_order[*src++] : *src++;
   }
-  *d = '\0';
-  return (int) (d-dest);
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
-#endif
 
 
 /*
@@ -7022,6 +6978,8 @@ CHARSET_INFO my_charset_big5_chinese_ci=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_big5_handler,
     &my_collation_big5_chinese_ci_handler
 };
@@ -7055,6 +7013,8 @@ CHARSET_INFO my_charset_big5_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_big5_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-bin.c'
--- a/strings/ctype-bin.c	2009-11-11 16:03:02 +0000
+++ b/strings/ctype-bin.c	2010-03-22 09:13:41 +0000
@@ -396,28 +396,17 @@ int my_wildcmp_bin(CHARSET_INFO *cs,
 }
 
 
-static size_t my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)),
-                              uchar *dest, size_t dstlen,
-                              const uchar *src, size_t srclen)
-{
-  if (dest != src)
-    memcpy(dest, src, min(dstlen,srclen));
-  if (dstlen > srclen)
-    bfill(dest + srclen, dstlen - srclen, 0);
-  return dstlen;
-}
-
-
-static
-size_t my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)),
-                            uchar *dest, size_t dstlen,
-                            const uchar *src, size_t srclen)
-{
-  if (dest != src)
-    memcpy(dest, src, min(dstlen,srclen));
-  if (dstlen > srclen)
-    bfill(dest + srclen, dstlen - srclen, ' ');
-  return dstlen;
+static size_t
+my_strnxfrm_8bit_bin(CHARSET_INFO *cs,
+                     uchar * dst, size_t dstlen, uint nweights,
+                     const uchar *src, size_t srclen, uint flags)
+{
+  set_if_smaller(srclen, dstlen);
+  set_if_smaller(srclen, nweights);
+  if (dst != src)
+    memcpy(dst, src, srclen);
+  return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen,
+                                         nweights - srclen, flags, 0);
 }
 
 
@@ -503,7 +492,7 @@ static MY_COLLATION_HANDLER my_collation
   NULL,			/* init */
   my_strnncoll_binary,
   my_strnncollsp_binary,
-  my_strnxfrm_bin,
+  my_strnxfrm_8bit_bin,
   my_strnxfrmlen_simple,
   my_like_range_simple,
   my_wildcmp_bin,
@@ -574,6 +563,8 @@ CHARSET_INFO my_charset_bin =
     255,			/* max_sort_char */
     0,                          /* pad char      */
     0,                          /* escape_with_backslash_is_dangerous */
+    1,                          /* levels_for_compare */
+    1,                          /* levels_for_order   */
     &my_charset_handler,
     &my_collation_binary_handler
 };

=== modified file 'strings/ctype-cp932.c'
--- a/strings/ctype-cp932.c	2010-02-15 05:57:24 +0000
+++ b/strings/ctype-cp932.c	2010-03-22 09:13:41 +0000
@@ -1788,30 +1788,6 @@ static int my_strnncollsp_cp932(CHARSET_
 }
 
 
-
-static size_t my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)),
-                                uchar *dest, size_t len,
-                                const uchar *src, size_t srclen)
-{
-  uchar *d_end = dest + len;
-  uchar *s_end = (uchar*) src + srclen;
-  while (dest < d_end && src < s_end)
-  {
-    if (ismbchar_cp932(cs,(char*) src, (char*) s_end))
-    {
-      *dest++ = *src++;
-      if (dest < d_end && src < s_end)
-	*dest++ = *src++;
-    }
-    else
-      *dest++ = sort_order_cp932[(uchar)*src++];
-  }
-  if (len > srclen)
-    bfill(dest, len - srclen, ' ');
-  return len;
-}
-
-
 /*
 ** Calculate min_str and max_str that ranges a LIKE string.
 ** Arguments:
@@ -34850,7 +34826,7 @@ static MY_COLLATION_HANDLER my_collation
   NULL,			/* init */
   my_strnncoll_cp932,
   my_strnncollsp_cp932,
-  my_strnxfrm_cp932,
+  my_strnxfrm_mb,
   my_strnxfrmlen_simple,
   my_like_range_cp932,
   my_wildcmp_mb,	/* wildcmp  */
@@ -34921,6 +34897,8 @@ CHARSET_INFO my_charset_cp932_japanese_c
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -34953,6 +34931,8 @@ CHARSET_INFO my_charset_cp932_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-czech.c'
--- a/strings/ctype-czech.c	2007-05-10 09:59:39 +0000
+++ b/strings/ctype-czech.c	2010-06-07 10:27:50 +0000
@@ -61,21 +61,10 @@
 
 #define SKIP_TRAILING_SPACES 1
 
-#define REAL_MYSQL
-
-#ifdef REAL_MYSQL
-
 #include <my_global.h>
 #include "m_string.h"
 #include "m_ctype.h"
 
-#else
-
-#include <stdio.h>
-#define uchar unsigned char
-
-#endif
-
 #ifdef HAVE_CHARSET_latin2
 
 /*
@@ -165,7 +154,7 @@ static struct wordvalue doubles[] = {
  */
 
 #define ADD_TO_RESULT(dest, len, totlen, value)			\
-if ((totlen) < (len)) { dest[totlen] = value; } (totlen++);
+{ if ((totlen) < (len)) { dest[totlen++]= value; } }
 #define IS_END(p, src, len)	(((char *)p - (char *)src) >= (len))
 
 #define NEXT_CMP_VALUE(src, p, store, pass, value, len)		\
@@ -286,13 +275,24 @@ int my_strnncollsp_czech(CHARSET_INFO * 
 
 
 /*
+  Returns the number of bytes required for strnxfrm().
+*/
+static size_t
+my_strnxfrmlen_czech(CHARSET_INFO *cs __attribute__((unused)), size_t len)
+{
+  return len * 4 + 4;
+}
+    
+
+/*
   Function strnxfrm, actually strxfrm, with Czech sorting, which expect
   the length of the strings being specified
 */
 
-static size_t my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), 
-                                uchar *dest, size_t len,
-                                const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), 
+                  uchar *dest, size_t len, uint nweights_arg,
+                  const uchar *src, size_t srclen, uint flags)
 {
   int value;
   const uchar *p, * store;
@@ -300,15 +300,23 @@ static size_t my_strnxfrm_czech(CHARSET_
   size_t totlen = 0;
   p = src;	store = src;
 
+  if (!(flags & 0x0F)) /* All levels by default */                              
+    flags|= 0x0F;
+
   do
   {
+    int add= (1 << pass) & flags; /* If this level is needed */
     NEXT_CMP_VALUE(src, p, store, pass, value, (int)srclen);
-    ADD_TO_RESULT(dest, len, totlen, value);
+    if (add)
+      ADD_TO_RESULT(dest, len, totlen, value);
   }
   while (value);
-  if (len > totlen)
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len > totlen)
+  {
     bfill(dest + totlen, len - totlen, ' ');
-  return len;
+    totlen= len;
+  }
+  return totlen;
 }
 
 #undef IS_END
@@ -353,12 +361,10 @@ static size_t my_strnxfrm_czech(CHARSET_
 ** optimized !
 */
 
-#ifdef REAL_MYSQL
 
 #define min_sort_char ' '
 #define max_sort_char '9'
 
-#define EXAMPLE
 
 static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
 				   const char *ptr,size_t ptr_length,
@@ -367,7 +373,6 @@ static my_bool my_like_range_czech(CHARS
 				   char *max_str,
 				   size_t *min_length,size_t *max_length)
 {
-#ifdef EXAMPLE
   uchar value;
   const char *end=ptr+ptr_length;
   char *min_org=min_str;
@@ -411,15 +416,8 @@ static my_bool my_like_range_czech(CHARS
     *max_str++ = max_sort_char;
   }
   return 0;
-#else
-  return 1;
-#endif
 }
 
-#endif
-
-#ifdef REAL_MYSQL
-/* This is a latin2 file */
 
 /*
  * File generated by cset
@@ -427,8 +425,6 @@ static my_bool my_like_range_czech(CHARS
  *
  * definition table reworked by Jaromir Dolecek <dolecek@stripped>
  */
-#include <my_global.h>
-#include "m_string.h"
 
 static uchar NEAR ctype_czech[257] = {
 0,
@@ -592,7 +588,7 @@ static MY_COLLATION_HANDLER my_collation
   my_strnncoll_czech,
   my_strnncollsp_czech,
   my_strnxfrm_czech,
-  my_strnxfrmlen_simple,
+  my_strnxfrmlen_czech,
   my_like_range_czech,
   my_wildcmp_bin,
   my_strcasecmp_8bit,
@@ -629,11 +625,11 @@ CHARSET_INFO my_charset_latin2_czech_ci 
     0,			/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    4,                  /* levels_for_compare */
+    4,                  /* levels_for_order   */
     &my_charset_8bit_handler,
     &my_collation_latin2_czech_ci_handler
 };
 
 
 #endif
-
-#endif

=== modified file 'strings/ctype-euc_kr.c'
--- a/strings/ctype-euc_kr.c	2010-01-14 11:17:57 +0000
+++ b/strings/ctype-euc_kr.c	2010-03-22 09:13:41 +0000
@@ -9962,7 +9962,7 @@ static MY_COLLATION_HANDLER my_collation
   NULL,			/* init */
   my_strnncoll_simple,  /* strnncoll  */
   my_strnncollsp_simple,
-  my_strnxfrm_simple,	/* strnxfrm   */
+  my_strnxfrm_mb,	/* strnxfrm   */
   my_strnxfrmlen_simple,
   my_like_range_mb,     /* like_range */
   my_wildcmp_mb,	/* wildcmp    */
@@ -10032,6 +10032,8 @@ CHARSET_INFO my_charset_euckr_korean_ci=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -10065,6 +10067,8 @@ CHARSET_INFO my_charset_euckr_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-eucjpms.c'
--- a/strings/ctype-eucjpms.c	2010-02-15 05:57:24 +0000
+++ b/strings/ctype-eucjpms.c	2010-03-22 09:13:41 +0000
@@ -67505,7 +67505,7 @@ static MY_COLLATION_HANDLER my_collation
     NULL,		/* init */
     my_strnncoll_simple,/* strnncoll    */
     my_strnncollsp_simple,
-    my_strnxfrm_simple,	/* strnxfrm     */
+    my_strnxfrm_mb,	/* strnxfrm     */
     my_strnxfrmlen_simple,
     my_like_range_mb,   /* like_range   */
     my_wildcmp_mb,	/* wildcmp      */
@@ -67576,6 +67576,8 @@ CHARSET_INFO my_charset_eucjpms_japanese
     255,		/* max_sort_char */
     ' ',		/* pad_char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -67609,6 +67611,8 @@ CHARSET_INFO my_charset_eucjpms_bin=
     255,		/* max_sort_char */
     ' ',		/* pad_char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-extra.c'
--- a/strings/ctype-extra.c	2009-09-30 05:09:28 +0000
+++ b/strings/ctype-extra.c	2010-03-22 09:13:41 +0000
@@ -6631,6 +6631,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6664,6 +6666,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6697,6 +6701,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6730,6 +6736,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6763,6 +6771,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6796,6 +6806,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6829,6 +6841,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6862,6 +6876,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6895,6 +6911,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6928,6 +6946,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6961,6 +6981,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -6994,6 +7016,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7027,6 +7051,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7060,6 +7086,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7093,6 +7121,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7126,6 +7156,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7159,6 +7191,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7192,6 +7226,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7225,6 +7261,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7258,6 +7296,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7291,6 +7331,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7324,6 +7366,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7357,6 +7401,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7390,6 +7436,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7423,6 +7471,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7456,6 +7506,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7489,6 +7541,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7522,6 +7576,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7555,6 +7611,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7588,6 +7646,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7621,6 +7681,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7654,6 +7716,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7687,6 +7751,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7720,6 +7786,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7753,6 +7821,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7786,6 +7856,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7819,6 +7891,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7852,6 +7926,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7885,6 +7961,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -7918,6 +7996,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7951,6 +8031,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -7984,6 +8066,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8017,6 +8101,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8050,6 +8136,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8083,6 +8171,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8116,6 +8206,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8149,6 +8241,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8182,6 +8276,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8215,6 +8311,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8248,6 +8346,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8281,6 +8381,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8314,6 +8416,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8347,6 +8451,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8380,6 +8486,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8413,6 +8521,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8446,6 +8556,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8479,6 +8591,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8512,6 +8626,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -8545,6 +8661,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_bin_handler,
 }
@@ -8578,6 +8696,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -8611,6 +8731,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }
@@ -8643,6 +8765,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
+  1,                          /* levels_for_compare */
+  1,                          /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_8bit_simple_ci_handler,
 }

=== modified file 'strings/ctype-gb2312.c'
--- a/strings/ctype-gb2312.c	2010-01-14 11:17:57 +0000
+++ b/strings/ctype-gb2312.c	2010-03-22 09:13:41 +0000
@@ -6365,7 +6365,7 @@ static MY_COLLATION_HANDLER my_collation
   NULL,			/* init */
   my_strnncoll_simple,  /* strnncoll  */
   my_strnncollsp_simple,
-  my_strnxfrm_simple,	/* strnxfrm   */
+  my_strnxfrm_mb,	/* strnxfrm   */
   my_strnxfrmlen_simple,
   my_like_range_mb,     /* like_range */
   my_wildcmp_mb,	/* wildcmp    */
@@ -6435,6 +6435,8 @@ CHARSET_INFO my_charset_gb2312_chinese_c
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -6467,6 +6469,8 @@ CHARSET_INFO my_charset_gb2312_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-gbk.c'
--- a/strings/ctype-gbk.c	2010-01-14 11:17:57 +0000
+++ b/strings/ctype-gbk.c	2010-03-22 09:13:41 +0000
@@ -3520,31 +3520,35 @@ static int my_strnncollsp_gbk(CHARSET_IN
 }
 
 
-static size_t my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
-                              uchar *dest, size_t len,
-                              const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_gbk(CHARSET_INFO *cs,
+                uchar *dst, size_t dstlen, uint nweights,
+                const uchar *src, size_t srclen, uint flags)
 {
-  uint16 e;
-  size_t dstlen= len;
-  uchar *dest_end= dest + dstlen;
+  uchar *d0= dst;
+  uchar *de= dst + dstlen;
+  const uchar *se= src + srclen;
+  const uchar *sort_order= cs->sort_order;
 
-  len = srclen;
-  while (len-- && dest < dest_end)
+  for (; dst < de && src < se && nweights; nweights--)
   {
-    if ((len > 0) && isgbkcode(*src, *(src+1)))
+    if (cs->cset->ismbchar(cs, (const char*) src, (const char*) se))
     {
-      e = gbksortorder((uint16) gbkcode(*src, *(src+1)));
-      *dest++ = gbkhead(e);
-      if (dest < dest_end)
-        *dest++ = gbktail(e);
-      src+=2;
-      len--;
-    } else 
-      *dest++ = sort_order_gbk[(uchar) *src++];
+      /*
+        Note, it is safe not to check (src < se)
+        in the code below, because ismbchar() would
+        not return TRUE if src was too short
+      */
+      uint16 e= gbksortorder((uint16) gbkcode(*src, *(src + 1)));
+      *dst++= gbkhead(e);
+      if (dst < de)
+        *dst++= gbktail(e);
+      src+= 2;
+    }
+    else
+      *dst++= sort_order ? sort_order[*src++] : *src++;
   }
-  if (dstlen > srclen)
-    bfill(dest, dstlen - srclen, ' ');
-  return dstlen;
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
 
 
@@ -10909,6 +10913,8 @@ CHARSET_INFO my_charset_gbk_chinese_ci=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -10941,6 +10947,8 @@ CHARSET_INFO my_charset_gbk_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-latin1.c'
--- a/strings/ctype-latin1.c	2009-11-11 16:03:02 +0000
+++ b/strings/ctype-latin1.c	2010-03-22 09:13:41 +0000
@@ -444,6 +444,8 @@ CHARSET_INFO my_charset_latin1=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_8bit_simple_ci_handler
 };
@@ -655,22 +657,25 @@ static int my_strnncollsp_latin1_de(CHAR
 }
 
 
-static size_t my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
-                                    uchar *dest, size_t len,
-                                    const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_latin1_de(CHARSET_INFO *cs,
+                      uchar *dst, size_t dstlen, uint nweights,
+                      const uchar* src, size_t srclen, uint flags)
 {
-  const uchar *de = dest + len;
-  const uchar *se = src + srclen;
-  for ( ; src < se && dest < de ; src++)
+  uchar *de= dst + dstlen;
+  const uchar *se= src + srclen;
+  uchar *d0= dst;
+  for ( ; src < se && dst < de && nweights; src++, nweights--)
   {
-    uchar chr=combo1map[*src];
-    *dest++=chr;
-    if ((chr=combo2map[*src]) && dest < de)
-      *dest++=chr;
+    uchar chr= combo1map[*src];
+    *dst++= chr;
+    if ((chr= combo2map[*src]) && dst < de && nweights > 1)
+    {
+      *dst++= chr;
+      nweights--;
+    }
   }
-  if (dest < de)
-    bfill(dest, de - dest, ' ');
-  return (int) len;
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
 
 
@@ -743,6 +748,8 @@ CHARSET_INFO my_charset_latin1_german2_c
   247,					/* max_sort_char */
   ' ',                                  /* pad char      */
   0,                                    /* escape_with_backslash_is_dangerous */
+  1,                                    /* levels_for_compare */
+  1,                                    /* levels_for_order   */
   &my_charset_handler,
   &my_collation_german2_ci_handler
 };
@@ -776,6 +783,8 @@ CHARSET_INFO my_charset_latin1_bin=
   255,					/* max_sort_char */
   ' ',                                  /* pad char      */
   0,                                    /* escape_with_backslash_is_dangerous */
+  1,                                    /* levels_for_compare */
+  1,                                    /* levels_for_order   */
   &my_charset_handler,
   &my_collation_8bit_bin_handler
 };

=== modified file 'strings/ctype-mb.c'
--- a/strings/ctype-mb.c	2010-03-11 10:34:11 +0000
+++ b/strings/ctype-mb.c	2010-03-24 10:21:36 +0000
@@ -552,15 +552,106 @@ my_strnncollsp_mb_bin(CHARSET_INFO * cs 
 }
 
 
-static size_t my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
-                                 uchar *dest, size_t dstlen,
-                                 const uchar *src, size_t srclen)
-{
-  if (dest != src)
-    memcpy(dest, src, min(dstlen, srclen));
-  if (dstlen > srclen)
-    bfill(dest + srclen, dstlen - srclen, ' ');
-  return dstlen;
+/*
+  Copy one non-ascii character.
+  "dst" must have enough room for the character.
+  Note, we don't use sort_order[] in this macros.
+  This is correct even for case insensitive collations:
+  - basic Latin letters are processed outside this macros;
+  - for other characters sort_order[x] is equal to x.
+*/
+#define my_strnxfrm_mb_non_ascii_char(cs, dst, src, se)                  \
+{                                                                        \
+  switch (cs->cset->ismbchar(cs, (const char*) src, (const char*) se)) { \
+  case 4:                                                                \
+    *dst++= *src++;                                                      \
+    /* fall through */                                                   \
+  case 3:                                                                \
+    *dst++= *src++;                                                      \
+    /* fall through */                                                   \
+  case 2:                                                                \
+    *dst++= *src++;                                                      \
+    /* fall through */                                                   \
+  case 0:                                                                \
+    *dst++= *src++; /* byte in range 0x80..0xFF which is not MB head */  \
+  }                                                                      \
+}
+
+
+/*
+  For character sets with two or three byte multi-byte
+  characters having multibyte weights *equal* to their codes:
+  cp932, euckr, gb2312, sjis, eucjpms, ujis.
+*/
+size_t
+my_strnxfrm_mb(CHARSET_INFO *cs,
+               uchar *dst, size_t dstlen, uint nweights,
+               const uchar *src, size_t srclen, uint flags)
+{
+  uchar *d0= dst;
+  uchar *de= dst + dstlen;
+  const uchar *se= src + srclen;
+  const uchar *sort_order= cs->sort_order;
+
+  DBUG_ASSERT(cs->mbmaxlen <= 4);
+
+  /*
+    If "srclen" is smaller than both "dstlen" and "nweights"
+    then we can run a simplified loop -
+    without checking "nweights" and "de".
+  */
+  if (dstlen >= srclen && nweights >= srclen)
+  {
+    if (sort_order)
+    {
+      /* Optimized version for a case insensitive collation */
+      for (; src < se; nweights--)
+      {
+        if (*src < 128) /* quickly catch ASCII characters */
+          *dst++= sort_order[*src++];
+        else
+          my_strnxfrm_mb_non_ascii_char(cs, dst, src, se);
+      }
+    }
+    else
+    {
+      /* Optimized version for a case sensitive collation (no sort_order) */
+      for (; src < se; nweights--)
+      {
+        if (*src < 128) /* quickly catch ASCII characters */
+          *dst++= *src++;
+        else
+          my_strnxfrm_mb_non_ascii_char(cs, dst, src, se);
+      }
+    }
+    goto pad;
+  }
+
+  /*
+    A thourough loop, checking all possible limits:
+    "se", "nweights" and "de".
+  */
+  for (; src < se && nweights && dst < de; nweights--)
+  {
+    int chlen;
+    if (*src < 128 ||
+        !(chlen= cs->cset->ismbchar(cs, (const char*) src, (const char*) se)))
+    {
+      /* Single byte character */
+      *dst++= sort_order ? sort_order[*src++] : *src++;
+    }
+    else
+    {
+      /* Multi-byte character */
+      int len= (dst + chlen <= de) ? chlen : de - dst;
+      memcpy(dst, src, len);
+      dst+= len;
+      src+= len;
+    }
+  }
+
+pad:
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
 
 
@@ -1116,9 +1207,14 @@ size_t my_numcells_mb(CHARSET_INFO *cs, 
   {
     int mb_len;
     uint pg;
-    if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0)
+    if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0 ||
+        wc > 0xFFFF)
     {
-      mb_len= 1; /* Let's think a wrong sequence takes 1 dysplay cell */
+      /*
+        Let's think a wrong sequence takes 1 dysplay cell.
+        Also, consider supplementary characters as taking one cell.
+      */
+      mb_len= 1;
       b++;
       continue;
     }
@@ -1159,7 +1255,7 @@ MY_COLLATION_HANDLER my_collation_mb_bin
     NULL,		/* init */
     my_strnncoll_mb_bin,
     my_strnncollsp_mb_bin,
-    my_strnxfrm_mb_bin,
+    my_strnxfrm_mb,
     my_strnxfrmlen_simple,
     my_like_range_mb,
     my_wildcmp_mb_bin,

=== modified file 'strings/ctype-simple.c'
--- a/strings/ctype-simple.c	2009-11-11 16:03:02 +0000
+++ b/strings/ctype-simple.c	2010-03-22 09:13:41 +0000
@@ -71,28 +71,30 @@ size_t my_strnxfrmlen_simple(CHARSET_INF
 */
 
 
-size_t my_strnxfrm_simple(CHARSET_INFO * cs, 
-                          uchar *dest, size_t len,
-                          const uchar *src, size_t srclen)
+size_t
+my_strnxfrm_simple(CHARSET_INFO * cs,
+                   uchar *dst, size_t dstlen, uint nweights,
+                   const uchar *src, size_t srclen, uint flags)
 {
   uchar *map= cs->sort_order;
-  size_t dstlen= len;
-  set_if_smaller(len, srclen);
-  if (dest != src)
+  uchar *d0= dst;
+  uint frmlen;
+  if ((frmlen= min(dstlen, nweights)) > srclen)
+    frmlen= srclen;
+  if (dst != src)
   {
     const uchar *end;
-    for ( end=src+len; src < end ;  )
-      *dest++= map[*src++];
+    for (end= src + frmlen; src < end;)
+      *dst++= map[*src++];
   }
   else
   {
     const uchar *end;
-    for ( end=dest+len; dest < end ; dest++)
-      *dest= (char) map[(uchar) *dest];
+    for (end= dst + frmlen; dst < end; dst++)
+      *dst= map[(uchar) *dst];
   }
-  if (dstlen > len)
-    bfill(dest, dstlen - len, ' ');
-  return dstlen;
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, d0 + dstlen,
+                                         nweights - frmlen, flags, 0);
 }
 
 
@@ -1778,6 +1780,150 @@ my_bool my_propagate_complex(CHARSET_INF
 }
 
 
+/*
+  Normalize strxfrm flags
+
+  SYNOPSIS:
+    my_strxfrm_flag_normalize()
+    flags    - non-normalized flags
+    nlevels  - number of levels
+    
+  NOTES:
+    If levels are omitted, then 1-maximum is assumed.
+    If any level number is greater than the maximum,
+    it is treated as the maximum.
+
+  RETURN
+    normalized flags
+*/
+
+uint my_strxfrm_flag_normalize(uint flags, uint maximum)
+{
+  DBUG_ASSERT(maximum >= 1 && maximum <= MY_STRXFRM_NLEVELS);
+  
+  /* If levels are omitted, then 1-maximum is assumed*/
+  if (!(flags & MY_STRXFRM_LEVEL_ALL))
+  {
+    static uint def_level_flags[]= {0, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F };
+    uint flag_pad= flags &
+                   (MY_STRXFRM_PAD_WITH_SPACE | MY_STRXFRM_PAD_TO_MAXLEN);
+    flags= def_level_flags[maximum] | flag_pad;
+  }
+  else
+  {
+    uint i;
+    uint flag_lev= flags & MY_STRXFRM_LEVEL_ALL;
+    uint flag_dsc= (flags >> MY_STRXFRM_DESC_SHIFT) & MY_STRXFRM_LEVEL_ALL;
+    uint flag_rev= (flags >> MY_STRXFRM_REVERSE_SHIFT) & MY_STRXFRM_LEVEL_ALL;
+    uint flag_pad= flags &
+                   (MY_STRXFRM_PAD_WITH_SPACE | MY_STRXFRM_PAD_TO_MAXLEN);
+
+    /*
+      If any level number is greater than the maximum,
+      it is treated as the maximum.
+    */
+    for (maximum--, flags= 0, i= 0; i < MY_STRXFRM_NLEVELS; i++)
+    {
+      uint src_bit= 1 << i;
+      if (flag_lev & src_bit)
+      {
+        uint dst_bit= 1 << min(i, maximum);
+        flags|= dst_bit;
+        flags|= (flag_dsc & dst_bit) << MY_STRXFRM_DESC_SHIFT;
+        flags|= (flag_rev & dst_bit) << MY_STRXFRM_REVERSE_SHIFT;
+      }
+      else
+      {
+        /* Check that there are no DESC or REVERSE flag for skipped level */
+        DBUG_ASSERT(!(flag_dsc & src_bit) && !(flag_rev & src_bit));
+      }
+    }
+    flags|= flag_pad;
+  }
+  
+  return flags;
+}
+
+
+/*
+  Apply DESC and REVERSE collation rules.
+
+  SYNOPSIS:
+    my_strxfrm_desc_and_reverse()
+    str      - pointer to string
+    strend   - end of string
+    flags    - flags
+    level    - which level, starting from 0.
+    
+  NOTES:
+    Apply DESC or REVERSE or both flags.
+    
+    If DESC flag is given, then the weights
+    come out NOTed or negated for that level.
+    
+    If REVERSE flags is given, then the weights come out in
+    reverse order for that level, that is, starting with
+    the last character and ending with the first character.
+    
+    If nether DESC nor REVERSE flags are give,
+    the string is not changed.
+    
+*/
+void
+my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
+                            uint flags, uint level)
+{
+  if (flags & (MY_STRXFRM_DESC_LEVEL1 << level))
+  {
+    if (flags & (MY_STRXFRM_REVERSE_LEVEL1 << level))
+    {
+      for (strend--; str <= strend;)
+      {
+        uchar tmp= *str;
+        *str++= ~*strend;
+        *strend--= ~tmp;
+      }
+    }
+    else
+    {
+      for (; str < strend; str++)
+        *str= ~*str;
+    }
+  }
+  else if (flags & (MY_STRXFRM_REVERSE_LEVEL1 << level))
+  {
+    for (strend--; str < strend;)
+    {
+      uchar tmp= *str;
+      *str++= *strend;
+      *strend--= tmp;
+    }
+  }
+}
+
+
+size_t
+my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
+                                uchar *str, uchar *frmend, uchar *strend,
+                                uint nweights, uint flags, uint level)
+{
+  if (nweights && frmend < strend && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+  {
+    uint fill_length= min((uint) (strend - frmend), nweights * cs->mbminlen);
+    cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char);
+    frmend+= fill_length;
+  }
+  my_strxfrm_desc_and_reverse(str, frmend, flags, level);
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && frmend < strend)
+  {
+    uint fill_length= strend - frmend;
+    cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char);
+    frmend= strend;
+  }
+  return frmend - str;
+}
+
+
 MY_CHARSET_HANDLER my_charset_8bit_handler=
 {
     my_cset_init_8bit,

=== modified file 'strings/ctype-sjis.c'
--- a/strings/ctype-sjis.c	2010-02-15 05:57:24 +0000
+++ b/strings/ctype-sjis.c	2010-03-22 09:13:41 +0000
@@ -1155,30 +1155,6 @@ static int my_strnncollsp_sjis(CHARSET_I
 }
 
 
-
-static size_t my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
-                               uchar *dest, size_t len,
-                               const uchar *src, size_t srclen)
-{
-  uchar *d_end = dest + len;
-  uchar *s_end = (uchar*) src + srclen;
-  while (dest < d_end && src < s_end)
-  {
-    if (ismbchar_sjis(cs,(char*) src, (char*) s_end))
-    {
-      *dest++ = *src++;
-      if (dest < d_end && src < s_end)
-	*dest++ = *src++;
-    }
-    else
-      *dest++ = sort_order_sjis[(uchar)*src++];
-  }
-  if (len > srclen)
-    bfill(dest, len - srclen, ' ');
-  return len;
-}
-
-
 /*
 ** Calculate min_str and max_str that ranges a LIKE string.
 ** Arguments:
@@ -34229,7 +34205,7 @@ static MY_COLLATION_HANDLER my_collation
   NULL,			/* init */
   my_strnncoll_sjis,
   my_strnncollsp_sjis,
-  my_strnxfrm_sjis,
+  my_strnxfrm_mb,
   my_strnxfrmlen_simple,
   my_like_range_sjis,
   my_wildcmp_mb,	/* wildcmp  */
@@ -34300,6 +34276,8 @@ CHARSET_INFO my_charset_sjis_japanese_ci
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -34332,6 +34310,8 @@ CHARSET_INFO my_charset_sjis_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     1,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-tis620.c'
--- a/strings/ctype-tis620.c	2007-05-10 09:59:39 +0000
+++ b/strings/ctype-tis620.c	2010-03-22 09:13:41 +0000
@@ -632,18 +632,26 @@ ret:
   Ret: Conveted string size
 */
 
-static
-size_t my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
-                          uchar *dest, size_t len,
-                          const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_tis620(CHARSET_INFO *cs,
+                   uchar *dst, size_t dstlen, uint nweights,
+                   const uchar *src, size_t srclen, uint flags)
 {
-  size_t dstlen= len;
-  len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-                 (char*) dest);
-  len= thai2sortable(dest, len);
-  if (dstlen > len)
-    bfill(dest + len, dstlen - len, ' ');
-  return dstlen;
+  size_t len, dstlen0= dstlen;
+  len= (uint) (strmake((char*) dst, (char*) src, min(dstlen, srclen)) -
+	               (char*) dst);
+  len= thai2sortable(dst, len);
+  set_if_smaller(dstlen, nweights);
+  set_if_smaller(len, dstlen); 
+  len= my_strxfrm_pad_desc_and_reverse(cs, dst, dst + len, dst + dstlen,
+                                       dstlen - len, flags, 0);
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len < dstlen0)
+  {
+    uint fill_length= dstlen0 - len;
+    cs->cset->fill(cs, (char*) dst + len, fill_length, cs->pad_char);
+    len= dstlen0;
+  }
+  return len;
 }
 
 
@@ -925,6 +933,8 @@ CHARSET_INFO my_charset_tis620_thai_ci=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -957,6 +967,8 @@ CHARSET_INFO my_charset_tis620_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_8bit_bin_handler
 };

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	2010-03-04 12:02:30 +0000
+++ b/strings/ctype-uca.c	2010-05-28 08:13:40 +0000
@@ -6521,6 +6521,17 @@ NULL       ,page0F9data,page0FAdata,page
 page0FCdata,page0FDdata,page0FEdata,page0FFdata
 };
 
+
+
+/*
+  German Phonebook
+*/
+static const char german2[]=
+    "&AE << \\u00E6 <<< \\u00C6 << \\u00E4 <<< \\u00C4 "
+    "&OE << \\u0153 <<< \\u0152 << \\u00F6 <<< \\u00D6 "
+    "&UE << \\u00FC <<< \\u00DC ";
+
+
 /*
   Some sources treat LETTER A WITH DIARESIS (00E4,00C4)
   secondary greater than LETTER AE (00E6,00C6).
@@ -7291,37 +7302,52 @@ static void my_hash_sort_uca(CHARSET_INF
     Number of bytes that have been written into the binary image.
 */
 
-static size_t my_strnxfrm_uca(CHARSET_INFO *cs, 
-                              my_uca_scanner_handler *scanner_handler,
-                              uchar *dst, size_t dstlen,
-                              const uchar *src, size_t srclen)
+
+static size_t
+my_strnxfrm_uca(CHARSET_INFO *cs, 
+                my_uca_scanner_handler *scanner_handler,
+                uchar *dst, size_t dstlen, uint nweights,
+                const uchar *src, size_t srclen, uint flags)
 {
-  uchar *de= dst + (dstlen & (size_t) ~1); /* add even length for easier code */
+  uchar *d0= dst;
+  uchar *de= dst + dstlen;
   int   s_res;
   my_uca_scanner scanner;
   scanner_handler->init(&scanner, cs, src, srclen);
   
-  while (dst < de && (s_res= scanner_handler->next(&scanner)) >0)
+  for (; dst < de && nweights &&
+         (s_res= scanner_handler->next(&scanner)) > 0 ; nweights--)
   {
-    dst[0]= s_res >> 8;
-    dst[1]= s_res & 0xFF;
-    dst+= 2;
+    *dst++= s_res >> 8;
+    if (dst < de)
+      *dst++= s_res & 0xFF;
   }
-  s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
-  while (dst < de)
+  
+  if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
   {
-    dst[0]= s_res >> 8;
-    dst[1]= s_res & 0xFF;
-    dst+= 2;
+    uint space_count= min((uint) (de - dst) / 2, nweights);
+    s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
+    for (; space_count ; space_count--)
+    {
+      *dst++= s_res >> 8;
+      *dst++= s_res & 0xFF;
+    }
   }
-  if (dstlen & 1) /* if odd number then fill the last char */
-    *dst= '\0';
-  
-  return dstlen;
+  my_strxfrm_desc_and_reverse(d0, dst, flags, 0);
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && dst < de)
+  {
+    s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
+    for ( ; dst < de; )
+    {
+      *dst++= s_res >> 8;
+      if (dst < de)
+        *dst++= s_res & 0xFF;
+    }
+  }
+  return dst - d0;
 }
 
 
-
 /*
   This function compares if two characters are the same.
   The sign +1 or -1 does not matter. The only
@@ -7498,7 +7524,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs,
 /*
   Collation language is implemented according to
   subset of ICU Collation Customization (tailorings):
-  http://oss.software.ibm.com/icu/userguide/Collate_Customization.html
+  http://icu.sourceforge.net/userguide/Collate_Customization.html
   
   Collation language elements:
   Delimiters:
@@ -7727,7 +7753,7 @@ ex:
 
 typedef struct my_coll_rule_item_st
 {
-  uint base;     /* Base character                             */
+  uint base[2];  /* Base character                             */
   uint curr[2];  /* Current character                          */
   int diff[3];   /* Primary, Secondary and Tertiary difference */
 } MY_COLL_RULE;
@@ -7749,9 +7775,11 @@ typedef struct my_coll_rule_item_st
    -1 means ERROR, e.g. too many items, syntax error, etc.
 */
 
-static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems,
-                              const char *str, const char *str_end,
-                              char *errstr, size_t errsize)
+
+static int
+my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems,
+                   const char *str, const char *str_end,
+                   char *errstr, size_t errsize)
 {
   MY_COLL_LEXEM lexem;
   my_coll_lexem_num lexnum;
@@ -7803,16 +7831,30 @@ static int my_coll_rule_parse(MY_COLL_RU
       
       if (prevlexnum == MY_COLL_LEXEM_SHIFT)
       {
-        item.base= lexem.code;
+        MY_COLL_LEXEM savlex= lexem;
+        item.base[0]= lexem.code;
         item.diff[0]= 0;
         item.diff[1]= 0;
         item.diff[2]= 0;
+        
+        /* Check if shift to a double character (expansion) */
+        if ((lexnum= my_coll_lexem_next(&lexem)) == MY_COLL_LEXEM_CHAR)
+        {
+          item.base[1]= lexem.code;
+        }
+        else
+        {
+          item.base[1]= 0;
+          lexem= savlex;   /* Restore previous parser state */
+        }
       }
       else if (prevlexnum == MY_COLL_LEXEM_DIFF)
       {
         MY_COLL_LEXEM savlex;
         savlex= lexem;
         item.curr[0]= lexem.code;
+        
+        /* Check if diff for a double character (contraction) */
         if ((lexnum= my_coll_lexem_next(&lexem)) == MY_COLL_LEXEM_CHAR)
         {
           item.curr[1]= lexem.code;
@@ -7860,8 +7902,70 @@ static int my_coll_rule_parse(MY_COLL_RU
   return (int) nitems;
 }
 
+
 #define MY_MAX_COLL_RULE 128
 
+/**
+  Helper function:
+  Find address of weights of the given character.
+  
+  @weights  UCA weight array
+  @lengths  UCA length array
+  @ch       character Unicode code point
+  
+  @return Weight array
+    @retval  pointer to weight array for the given character,
+             or NULL if this page does not have implicit weights.
+*/
+
+static inline uint16 *
+my_char_weight_addr(uint16 **weights, const uchar *lengths, uint ch)
+{
+  uint page= (ch >> 8) & 0xFF;
+  uint ofst= ch & 0xFF;
+  return weights[page] ? weights[page] + ofst * lengths[page] : NULL;
+}
+
+
+
+/**
+  Helper function:
+  Copies UCA weights for a given "uint" string
+  to the given location.
+  
+  @weights    source UCA weight array
+  @lengths    source UCA length array
+  @to         destination
+  @to_length  size of destination
+  @str        string
+  @len        string length
+  
+  @return    number of weights put
+*/
+
+static size_t
+my_char_weight_put(uint16 **weights, const uchar *lengths,
+                   uint16 *to, size_t to_length,
+                   uint *str, size_t len)
+{
+  size_t i, count;
+  if (!to_length)
+    return 0;
+  to_length--; /* Without trailing zero */
+  for (count=0, i= 0; (i < len) && (count < to_length); i++, str++)
+  {
+    uint16 *from= my_char_weight_addr(weights, lengths, *str);
+    for ( ; from && from[0]; from++)
+    {
+      *to++= *from;
+      count++;
+    }
+  }
+  *to= 0;
+  return count;
+}
+
+
 /*
   This function copies an UCS2 collation from
   the default Unicode Collation Algorithm (UCA)
@@ -7879,16 +7983,16 @@ static int my_coll_rule_parse(MY_COLL_RU
   default weights.
 */
 
-static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(size_t))
+static my_bool
+create_tailoring(CHARSET_INFO *cs, void *(*alloc)(size_t))
 {
-  MY_COLL_RULE rule[MY_MAX_COLL_RULE];
+  MY_COLL_RULE rule[MY_MAX_COLL_RULE], *r, *rlast;
   char errstr[128];
   uchar   *newlengths;
   uint16 **newweights;
   const uchar *deflengths= uca_length;
   uint16     **defweights= uca_weight;
-  int rc, i;
-  int ncontractions= 0;
+  int rc, ncontractions= 0;
   
   if (!cs->tailoring)
     return 1;
@@ -7905,9 +8009,7 @@ static my_bool create_tailoring(CHARSET_
     */
     return 1;
   }
-  
-  if (!cs->caseinfo)
-    cs->caseinfo= my_unicase_default;
+  rlast= rule + rc;
   
   if (!(newweights= (uint16**) (*alloc)(256*sizeof(uint16*))))
     return 1;
@@ -7922,12 +8024,12 @@ static my_bool create_tailoring(CHARSET_
     Calculate maximum lenghts for the pages
     which will be overwritten.
   */
-  for (i=0; i < rc; i++)
+  for (r= rule; r < rlast; r++)
   {
-    if (!rule[i].curr[1]) /* If not a contraction */
+    if (!r->curr[1]) /* If not a contraction */
     {
-      uint pageb= (rule[i].base >> 8) & 0xFF;
-      uint pagec= (rule[i].curr[0] >> 8) & 0xFF;
+      uint pageb= (r->base[0] >> 8) & 0xFF;
+      uint pagec= (r->curr[0] >> 8) & 0xFF;
     
       if (newlengths[pagec] < deflengths[pageb])
         newlengths[pagec]= deflengths[pageb];
@@ -7936,57 +8038,7 @@ static my_bool create_tailoring(CHARSET_
       ncontractions++;
   }
   
-  for (i=0; i < rc;  i++)
-  {
-    uint pageb= (rule[i].base >> 8) & 0xFF;
-    uint pagec= (rule[i].curr[0] >> 8) & 0xFF;
-    uint chb, chc;
-    
-    if (rule[i].curr[1]) /* Skip contraction */
-      continue;
-    
-    if (!newweights[pagec])
-    {
-      /* Alloc new page and copy the default UCA weights */
-      uint size= 256*newlengths[pagec]*sizeof(uint16);
-      
-      if (!(newweights[pagec]= (uint16*) (*alloc)(size)))
-        return 1;
-      bzero((void*) newweights[pagec], size);
-      
-      for (chc=0 ; chc < 256; chc++)
-      {
-        memcpy(newweights[pagec] + chc*newlengths[pagec],
-               defweights[pagec] + chc*deflengths[pagec],
-               deflengths[pagec]*sizeof(uint16));
-      }
-    }
-    
-    /* 
-      Aply the alternative rule:
-      shift to the base character and primary difference.
-    */
-    chc= rule[i].curr[0] & 0xFF;
-    chb= rule[i].base & 0xFF;
-    memcpy(newweights[pagec] + chc*newlengths[pagec],
-           defweights[pageb] + chb*deflengths[pageb],
-           deflengths[pageb]*sizeof(uint16));
-    /* Apply primary difference */
-    newweights[pagec][chc*newlengths[pagec]]+= rule[i].diff[0];
-  }
-  
-  /* Copy non-overwritten pages from the default UCA weights */
-  for (i= 0; i < 256 ; i++)
-  {
-    if (!newweights[i])
-      newweights[i]= defweights[i];
-  }
-  
-  cs->sort_order= newlengths;
-  cs->sort_order_big= newweights;
-  cs->contractions= NULL;
   
-  /* Now process contractions */
   if (ncontractions)
   {
     /*
@@ -7994,42 +8046,100 @@ static my_bool create_tailoring(CHARSET_
       plus 256 bytes for "is contraction part" flags.
     */
     uint size= 0x40*0x40*sizeof(uint16) + 256;
-    char *contraction_flags;
     if (!(cs->contractions= (uint16*) (*alloc)(size)))
         return 1;
     bzero((void*)cs->contractions, size);
-    contraction_flags= ((char*) cs->contractions) + 0x40*0x40;
-    for (i=0; i < rc; i++)
+  }
+  else
+    cs->contractions= NULL;
+  
+  
+  for (r= rule; r < rlast;  r++)
+  {
+    size_t nweights, baselen= r->base[1] ? 2 : 1;
+    uint16 *to;
+    
+    if (r->curr[1]) /* Contraction */
+    {
+      char *contraction_flags= ((char*) cs->contractions) + 0x40*0x40;
+      uint pageb= (r->base[0] >> 8) & 0xFF;
+      uint chb= r->base[0] & 0xFF;
+      uint16 *offsb= defweights[pageb] + chb*deflengths[pageb];
+      
+      if (offsb[1] || 
+          r->curr[0] < 0x40 || r->curr[0] > 0x7f ||
+          r->curr[1] < 0x40 || r->curr[1] > 0x7f)
+      {
+        /* 
+         TODO: add error reporting;
+         We support only basic latin letters contractions at this point.
+         Also, We don't support contractions with weight longer than one.
+         Otherwise, we'd need much more memory.
+        */
+        return 1;
+      }
+      /* Mark both letters as "is contraction part */
+      contraction_flags[r->curr[0]]= 1;
+      contraction_flags[r->curr[1]]= 1;
+
+      to= &cs->contractions[(r->curr[0] - 0x40) * 0x40 + (r->curr[1] - 0x40)];
+      nweights= 2; /* +1 for trailing zero */
+    }
+    else
     {
-      if (rule[i].curr[1])
+      uint16 pagec;
+      if (!newweights[pagec= ((r->curr[0] >> 8) & 0xFF)])
       {
-        uint pageb= (rule[i].base >> 8) & 0xFF;
-        uint chb= rule[i].base & 0xFF;
-        uint16 *offsb= defweights[pageb] + chb*deflengths[pageb];
-        uint offsc;
+        /* Alloc new page and copy the default UCA weights */
+        uint chc, size= 256 * newlengths[pagec] * sizeof(uint16);
         
-        if (offsb[1] || 
-            rule[i].curr[0] < 0x40 || rule[i].curr[0] > 0x7f ||
-            rule[i].curr[1] < 0x40 || rule[i].curr[1] > 0x7f)
-        {
-          /* 
-           TODO: add error reporting;
-           We support only basic latin letters contractions at this point.
-           Also, We don't support contractions with weight longer than one.
-           Otherwise, we'd need much more memory.
-          */
+        if (!(newweights[pagec]= (uint16*) (*alloc)(size)))
           return 1;
-        }
-        offsc= (rule[i].curr[0]-0x40)*0x40+(rule[i].curr[1]-0x40);
+        bzero((void*) newweights[pagec], size);
         
-        /* Copy base weight applying primary difference */
-        cs->contractions[offsc]= offsb[0] + rule[i].diff[0];
-        /* Mark both letters as "is contraction part */
-        contraction_flags[rule[i].curr[0]]= 1;
-        contraction_flags[rule[i].curr[1]]= 1;
+        for (chc=0 ; chc < 256; chc++)
+        {
+          memcpy(newweights[pagec] + chc*newlengths[pagec],
+                 defweights[pagec] + chc*deflengths[pagec],
+                 deflengths[pagec]*sizeof(uint16));
+        }
       }
+      to= my_char_weight_addr(newweights, newlengths, r->curr[0]);
+      nweights= newlengths[pagec];
+    }
+
+    /* Copy weights of the "shift to" character */
+    nweights= my_char_weight_put(defweights, deflengths,
+                                 to, nweights,
+                                 r->base, baselen);
+
+    /* Apply primary difference */
+    if (nweights)
+    {
+      to[nweights - 1]+= r->diff[0];
+    }
+    else
+    {
+      /* Shift to a primary ignorable character, e.g.: & \u0000 < \u0001 */
+      DBUG_ASSERT(to[0] == 0);
+      to[0]= r->diff[0];
+    }
+  }
+  
+  
+  /* Copy non-overwritten pages from the default UCA weights */
+  {
+    size_t i;
+    for (i= 0; i < 256 ; i++)
+    {
+      if (!newweights[i])
+        newweights[i]= defweights[i];
     }
   }
+  
+  cs->sort_order= newlengths;
+  cs->sort_order_big= newweights;
+  
   return 0;
 }
 
@@ -8044,6 +8154,8 @@ static my_bool my_coll_init_uca(CHARSET_
 {
   cs->pad_char= ' ';
   cs->ctype= my_charset_utf8_unicode_ci.ctype;
+  if (!cs->caseinfo)
+    cs->caseinfo= my_unicase_default;
   return create_tailoring(cs, alloc);
 }
 
@@ -8074,11 +8186,11 @@ static void my_hash_sort_any_uca(CHARSET
 }
 
 static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs, 
-                                  uchar *dst, size_t dstlen,
-                                  const uchar *src, size_t srclen)
+                                  uchar *dst, size_t dstlen, uint nweights,
+                                  const uchar *src, size_t srclen, uint flags)
 {
   return my_strnxfrm_uca(cs, &my_any_uca_scanner_handler,
-                         dst, dstlen, src, srclen);
+                         dst, dstlen, nweights, src, srclen, flags);
 }
 
 
@@ -8113,11 +8225,11 @@ static void my_hash_sort_ucs2_uca(CHARSE
 }
 
 static size_t my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, 
-                                   uchar *dst, size_t dstlen,
-                                   const uchar *src, size_t srclen)
+                                   uchar *dst, size_t dstlen, uint nweights,
+                                   const uchar *src, size_t srclen, uint flags)
 {
   return my_strnxfrm_uca(cs, &my_ucs2_uca_scanner_handler,
-                         dst, dstlen, src, srclen);
+                         dst, dstlen, nweights, src, srclen, flags);
 }
 
 MY_COLLATION_HANDLER my_collation_ucs2_uca_handler =
@@ -8163,6 +8275,8 @@ CHARSET_INFO my_charset_ucs2_unicode_ci=
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8195,6 +8309,8 @@ CHARSET_INFO my_charset_ucs2_icelandic_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8227,6 +8343,8 @@ CHARSET_INFO my_charset_ucs2_latvian_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8259,6 +8377,8 @@ CHARSET_INFO my_charset_ucs2_romanian_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8291,6 +8411,8 @@ CHARSET_INFO my_charset_ucs2_slovenian_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8323,6 +8445,8 @@ CHARSET_INFO my_charset_ucs2_polish_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8355,6 +8479,8 @@ CHARSET_INFO my_charset_ucs2_estonian_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8387,6 +8513,8 @@ CHARSET_INFO my_charset_ucs2_spanish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8419,6 +8547,8 @@ CHARSET_INFO my_charset_ucs2_swedish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8451,6 +8581,8 @@ CHARSET_INFO my_charset_ucs2_turkish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8483,6 +8615,8 @@ CHARSET_INFO my_charset_ucs2_czech_uca_c
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8516,6 +8650,8 @@ CHARSET_INFO my_charset_ucs2_danish_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8548,6 +8684,8 @@ CHARSET_INFO my_charset_ucs2_lithuanian_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8580,6 +8718,8 @@ CHARSET_INFO my_charset_ucs2_slovak_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8612,6 +8752,8 @@ CHARSET_INFO my_charset_ucs2_spanish2_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8645,6 +8787,8 @@ CHARSET_INFO my_charset_ucs2_roman_uca_c
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8678,6 +8822,8 @@ CHARSET_INFO my_charset_ucs2_persian_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8711,6 +8857,8 @@ CHARSET_INFO my_charset_ucs2_esperanto_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8744,6 +8892,8 @@ CHARSET_INFO my_charset_ucs2_hungarian_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8752,7 +8902,7 @@ CHARSET_INFO my_charset_ucs2_hungarian_u
 CHARSET_INFO my_charset_ucs2_sinhala_uca_ci=
 {
     147,0,0,             /* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE,
+    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
     "ucs2",              /* csname    */
     "ucs2_sinhala_ci",   /* name         */
     "",                  /* comment      */
@@ -8777,6 +8927,43 @@ CHARSET_INFO my_charset_ucs2_sinhala_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
+    &my_charset_ucs2_handler,
+    &my_collation_ucs2_uca_handler
+};
+
+
+CHARSET_INFO my_charset_ucs2_german2_uca_ci=
+{
+    148,0,0,             /* number       */
+    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    "ucs2",              /* csname    */
+    "ucs2_german2_ci",   /* name         */
+    "",                  /* comment      */
+    german2,             /* 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    */
+    8,                   /* strxfrm_multiply */
+    1,                   /* caseup_multiply  */
+    1,                   /* casedn_multiply  */
+    2,                   /* mbminlen     */
+    2,                   /* mbmaxlen     */
+    9,                   /* min_sort_char */
+    0xFFFF,              /* max_sort_char */
+    ' ',                 /* pad char      */
+    0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_uca_handler
 };
@@ -8829,10 +9016,12 @@ static uchar ctype_utf8[] = {
 
 extern MY_CHARSET_HANDLER my_charset_utf8_handler;
 
+#define MY_CS_UTF8MB3_UCA_FLAGS  (MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE)
+
 CHARSET_INFO my_charset_utf8_unicode_ci=
 {
     192,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_unicode_ci",	/* name         */
     "",			/* comment      */
@@ -8857,6 +9046,8 @@ CHARSET_INFO my_charset_utf8_unicode_ci=
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -8865,7 +9056,7 @@ CHARSET_INFO my_charset_utf8_unicode_ci=
 CHARSET_INFO my_charset_utf8_icelandic_uca_ci=
 {
     193,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_icelandic_ci",/* name         */
     "",			/* comment      */
@@ -8890,6 +9081,8 @@ CHARSET_INFO my_charset_utf8_icelandic_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -8897,7 +9090,7 @@ CHARSET_INFO my_charset_utf8_icelandic_u
 CHARSET_INFO my_charset_utf8_latvian_uca_ci=
 {
     194,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_latvian_ci",	/* name         */
     "",			/* comment      */
@@ -8922,6 +9115,8 @@ CHARSET_INFO my_charset_utf8_latvian_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -8929,7 +9124,7 @@ CHARSET_INFO my_charset_utf8_latvian_uca
 CHARSET_INFO my_charset_utf8_romanian_uca_ci=
 {
     195,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_romanian_ci",	/* name         */
     "",			/* comment      */
@@ -8954,6 +9149,8 @@ CHARSET_INFO my_charset_utf8_romanian_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -8961,7 +9158,7 @@ CHARSET_INFO my_charset_utf8_romanian_uc
 CHARSET_INFO my_charset_utf8_slovenian_uca_ci=
 {
     196,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_slovenian_ci",/* name         */
     "",			/* comment      */
@@ -8986,6 +9183,8 @@ CHARSET_INFO my_charset_utf8_slovenian_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -8993,7 +9192,7 @@ CHARSET_INFO my_charset_utf8_slovenian_u
 CHARSET_INFO my_charset_utf8_polish_uca_ci=
 {
     197,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_polish_ci",	/* name         */
     "",			/* comment      */
@@ -9018,6 +9217,8 @@ CHARSET_INFO my_charset_utf8_polish_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9025,7 +9226,7 @@ CHARSET_INFO my_charset_utf8_polish_uca_
 CHARSET_INFO my_charset_utf8_estonian_uca_ci=
 {
     198,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_estonian_ci",	/* name         */
     "",			/* comment      */
@@ -9050,6 +9251,8 @@ CHARSET_INFO my_charset_utf8_estonian_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9057,7 +9260,7 @@ CHARSET_INFO my_charset_utf8_estonian_uc
 CHARSET_INFO my_charset_utf8_spanish_uca_ci=
 {
     199,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_spanish_ci",	/* name         */
     "",			/* comment      */
@@ -9082,6 +9285,8 @@ CHARSET_INFO my_charset_utf8_spanish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9089,7 +9294,7 @@ CHARSET_INFO my_charset_utf8_spanish_uca
 CHARSET_INFO my_charset_utf8_swedish_uca_ci=
 {
     200,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_swedish_ci",	/* name         */
     "",			/* comment      */
@@ -9114,6 +9319,8 @@ CHARSET_INFO my_charset_utf8_swedish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9121,7 +9328,7 @@ CHARSET_INFO my_charset_utf8_swedish_uca
 CHARSET_INFO my_charset_utf8_turkish_uca_ci=
 {
     201,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_turkish_ci",	/* name         */
     "",			/* comment      */
@@ -9146,6 +9353,8 @@ CHARSET_INFO my_charset_utf8_turkish_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9153,7 +9362,7 @@ CHARSET_INFO my_charset_utf8_turkish_uca
 CHARSET_INFO my_charset_utf8_czech_uca_ci=
 {
     202,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_czech_ci",	/* name         */
     "",			/* comment      */
@@ -9178,6 +9387,8 @@ CHARSET_INFO my_charset_utf8_czech_uca_c
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9186,7 +9397,7 @@ CHARSET_INFO my_charset_utf8_czech_uca_c
 CHARSET_INFO my_charset_utf8_danish_uca_ci=
 {
     203,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_danish_ci",	/* name         */
     "",			/* comment      */
@@ -9211,6 +9422,8 @@ CHARSET_INFO my_charset_utf8_danish_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9218,7 +9431,7 @@ CHARSET_INFO my_charset_utf8_danish_uca_
 CHARSET_INFO my_charset_utf8_lithuanian_uca_ci=
 {
     204,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_lithuanian_ci",/* name         */
     "",			/* comment      */
@@ -9243,6 +9456,8 @@ CHARSET_INFO my_charset_utf8_lithuanian_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9250,7 +9465,7 @@ CHARSET_INFO my_charset_utf8_lithuanian_
 CHARSET_INFO my_charset_utf8_slovak_uca_ci=
 {
     205,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_slovak_ci",	/* name         */
     "",			/* comment      */
@@ -9275,6 +9490,8 @@ CHARSET_INFO my_charset_utf8_slovak_uca_
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9282,7 +9499,7 @@ CHARSET_INFO my_charset_utf8_slovak_uca_
 CHARSET_INFO my_charset_utf8_spanish2_uca_ci=
 {
     206,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_spanish2_ci",	/* name         */
     "",			/* comment      */
@@ -9307,6 +9524,8 @@ CHARSET_INFO my_charset_utf8_spanish2_uc
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9314,7 +9533,7 @@ CHARSET_INFO my_charset_utf8_spanish2_uc
 CHARSET_INFO my_charset_utf8_roman_uca_ci=
 {
     207,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_roman_ci",	/* name         */
     "",			/* comment      */
@@ -9339,6 +9558,8 @@ CHARSET_INFO my_charset_utf8_roman_uca_c
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9346,7 +9567,7 @@ CHARSET_INFO my_charset_utf8_roman_uca_c
 CHARSET_INFO my_charset_utf8_persian_uca_ci=
 {
     208,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_persian_ci",	/* name         */
     "",			/* comment      */
@@ -9371,6 +9592,8 @@ CHARSET_INFO my_charset_utf8_persian_uca
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9378,7 +9601,7 @@ CHARSET_INFO my_charset_utf8_persian_uca
 CHARSET_INFO my_charset_utf8_esperanto_uca_ci=
 {
     209,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_esperanto_ci",/* name         */
     "",			/* comment      */
@@ -9403,6 +9626,8 @@ CHARSET_INFO my_charset_utf8_esperanto_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9410,7 +9635,7 @@ CHARSET_INFO my_charset_utf8_esperanto_u
 CHARSET_INFO my_charset_utf8_hungarian_uca_ci=
 {
     210,0,0,		/* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",		/* cs name    */
     "utf8_hungarian_ci",/* name         */
     "",			/* comment      */
@@ -9435,6 +9660,8 @@ CHARSET_INFO my_charset_utf8_hungarian_u
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
@@ -9442,7 +9669,7 @@ CHARSET_INFO my_charset_utf8_hungarian_u
 CHARSET_INFO my_charset_utf8_sinhala_uca_ci=
 {
     211,0,0,             /* number       */
-    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE,
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
     "utf8",              /* cs name      */
     "utf8_sinhala_ci",   /* name         */
     "",                  /* comment      */
@@ -9467,10 +9694,48 @@ CHARSET_INFO my_charset_utf8_sinhala_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
+    &my_charset_utf8_handler,
+    &my_collation_any_uca_handler
+};
+
+
+CHARSET_INFO my_charset_utf8_german2_uca_ci=
+{
+    212,0,0,             /* number       */
+    MY_CS_UTF8MB3_UCA_FLAGS,/* flags    */
+    MY_UTF8MB3,          /* cs name      */
+    MY_UTF8MB3 "_german2_ci",/* name    */
+    "",                  /* comment      */
+    german2,             /* tailoring    */
+    ctype_utf8,          /* 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    */
+    8,                   /* strxfrm_multiply */
+    1,                   /* caseup_multiply  */
+    1,                   /* casedn_multiply  */
+    1,                   /* mbminlen     */
+    3,                   /* mbmaxlen     */
+    9,                   /* min_sort_char */
+    0xFFFF,              /* max_sort_char */
+    ' ',                 /* pad char      */
+    0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_any_uca_handler
 };
 
+
 #endif /* HAVE_CHARSET_utf8 */
 
 
@@ -9508,6 +9773,8 @@ CHARSET_INFO my_charset_utf8mb4_unicode_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9541,6 +9808,8 @@ CHARSET_INFO my_charset_utf8mb4_icelandi
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9573,6 +9842,8 @@ CHARSET_INFO my_charset_utf8mb4_latvian_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9605,6 +9876,8 @@ CHARSET_INFO my_charset_utf8mb4_romanian
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9637,6 +9910,8 @@ CHARSET_INFO my_charset_utf8mb4_slovenia
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9669,6 +9944,8 @@ CHARSET_INFO my_charset_utf8mb4_polish_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9701,6 +9978,8 @@ CHARSET_INFO my_charset_utf8mb4_estonian
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9733,6 +10012,8 @@ CHARSET_INFO my_charset_utf8mb4_spanish_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9765,6 +10046,8 @@ CHARSET_INFO my_charset_utf8mb4_swedish_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9797,6 +10080,8 @@ CHARSET_INFO my_charset_utf8mb4_turkish_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9829,6 +10114,8 @@ CHARSET_INFO my_charset_utf8mb4_czech_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9862,6 +10149,8 @@ CHARSET_INFO my_charset_utf8mb4_danish_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9894,6 +10183,8 @@ CHARSET_INFO my_charset_utf8mb4_lithuani
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9926,6 +10217,8 @@ CHARSET_INFO my_charset_utf8mb4_slovak_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9958,6 +10251,8 @@ CHARSET_INFO my_charset_utf8mb4_spanish2
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -9990,6 +10285,8 @@ CHARSET_INFO my_charset_utf8mb4_roman_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -10022,6 +10319,8 @@ CHARSET_INFO my_charset_utf8mb4_persian_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -10054,6 +10353,8 @@ CHARSET_INFO my_charset_utf8mb4_esperant
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -10086,6 +10387,8 @@ CHARSET_INFO my_charset_utf8mb4_hungaria
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -10118,6 +10421,42 @@ CHARSET_INFO my_charset_utf8mb4_sinhala_
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
+    &my_charset_utf8mb4_handler,
+    &my_collation_any_uca_handler
+};
+
+CHARSET_INFO my_charset_utf8mb4_german2_uca_ci=
+{
+    244,0,0,            /* number       */
+    MY_CS_UTF8MB4_UCA_FLAGS,/* state    */
+    MY_UTF8MB4,         /* csname      */
+    MY_UTF8MB4 "_german2_ci",/* name  */
+    "",                 /* comment      */
+    german2,            /* tailoring    */
+    ctype_utf8,         /* 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    */
+    8,                  /* strxfrm_multiply */
+    1,                  /* caseup_multiply  */
+    1,                  /* casedn_multiply  */
+    1,                  /* mbminlen      */
+    4,                  /* mbmaxlen      */
+    9,                  /* min_sort_char */
+    0xFFFF,             /* max_sort_char */
+    ' ',                /* pad char      */
+    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8mb4_handler,
     &my_collation_any_uca_handler
 };
@@ -10174,6 +10513,8 @@ CHARSET_INFO my_charset_utf32_unicode_ci
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10207,6 +10548,8 @@ CHARSET_INFO my_charset_utf32_icelandic_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10239,6 +10582,8 @@ CHARSET_INFO my_charset_utf32_latvian_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10271,6 +10616,8 @@ CHARSET_INFO my_charset_utf32_romanian_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10303,6 +10650,8 @@ CHARSET_INFO my_charset_utf32_slovenian_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10335,6 +10684,8 @@ CHARSET_INFO my_charset_utf32_polish_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10367,6 +10718,8 @@ CHARSET_INFO my_charset_utf32_estonian_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10399,6 +10752,8 @@ CHARSET_INFO my_charset_utf32_spanish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10431,6 +10786,8 @@ CHARSET_INFO my_charset_utf32_swedish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10463,6 +10820,8 @@ CHARSET_INFO my_charset_utf32_turkish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10495,6 +10854,8 @@ CHARSET_INFO my_charset_utf32_czech_uca_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10528,6 +10889,8 @@ CHARSET_INFO my_charset_utf32_danish_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10560,6 +10923,8 @@ CHARSET_INFO my_charset_utf32_lithuanian
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10592,6 +10957,8 @@ CHARSET_INFO my_charset_utf32_slovak_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10624,6 +10991,8 @@ CHARSET_INFO my_charset_utf32_spanish2_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10656,6 +11025,8 @@ CHARSET_INFO my_charset_utf32_roman_uca_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10688,6 +11059,8 @@ CHARSET_INFO my_charset_utf32_persian_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10720,6 +11093,8 @@ CHARSET_INFO my_charset_utf32_esperanto_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10752,6 +11127,8 @@ CHARSET_INFO my_charset_utf32_hungarian_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
@@ -10784,10 +11161,47 @@ CHARSET_INFO my_charset_utf32_sinhala_uc
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
+    &my_charset_utf32_handler,
+    &my_collation_utf32_uca_handler
+};
+
+CHARSET_INFO my_charset_utf32_german2_uca_ci=
+{
+    180,0,0,            /* number       */
+    MY_CS_UTF32_UCA_FLAGS,/* state      */
+    "utf32",            /* csname      */
+    "utf32_german2_ci", /* name         */
+    "",                 /* comment      */
+    german2,            /* 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    */
+    8,                  /* strxfrm_multiply */
+    1,                  /* caseup_multiply  */
+    1,                  /* casedn_multiply  */
+    4,                  /* mbminlen     */
+    4,                  /* mbmaxlen     */
+    9,                  /* min_sort_char */
+    0xFFFF,             /* max_sort_char */
+    ' ',                /* pad char      */
+    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf32_handler,
     &my_collation_utf32_uca_handler
 };
 
+
 #endif /* HAVE_CHARSET_utf32 */
 
 
@@ -10841,6 +11255,8 @@ CHARSET_INFO my_charset_utf16_unicode_ci
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -10874,6 +11290,8 @@ CHARSET_INFO my_charset_utf16_icelandic_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -10906,6 +11324,8 @@ CHARSET_INFO my_charset_utf16_latvian_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -10938,6 +11358,8 @@ CHARSET_INFO my_charset_utf16_romanian_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -10970,6 +11392,8 @@ CHARSET_INFO my_charset_utf16_slovenian_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11002,6 +11426,8 @@ CHARSET_INFO my_charset_utf16_polish_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11034,6 +11460,8 @@ CHARSET_INFO my_charset_utf16_estonian_u
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11066,6 +11494,8 @@ CHARSET_INFO my_charset_utf16_spanish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11098,6 +11528,8 @@ CHARSET_INFO my_charset_utf16_swedish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11130,6 +11562,8 @@ CHARSET_INFO my_charset_utf16_turkish_uc
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11162,6 +11596,8 @@ CHARSET_INFO my_charset_utf16_czech_uca_
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11195,6 +11631,8 @@ CHARSET_INFO my_charset_utf16_danish_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11227,6 +11665,8 @@ CHARSET_INFO my_charset_utf16_lithuanian
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11259,6 +11699,8 @@ CHARSET_INFO my_charset_utf16_slovak_uca
     0xFFFF,              /* max_sort_char */
     ' ',                 /* pad char      */
     0,                   /* escape_with_backslash_is_dangerous */
+    1,                   /* levels_for_compare */
+    1,                   /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11291,6 +11733,8 @@ CHARSET_INFO my_charset_utf16_spanish2_u
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11323,6 +11767,8 @@ CHARSET_INFO my_charset_utf16_roman_uca_
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11355,6 +11801,8 @@ CHARSET_INFO my_charset_utf16_persian_uc
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11387,6 +11835,8 @@ CHARSET_INFO my_charset_utf16_esperanto_
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11419,6 +11869,8 @@ CHARSET_INFO my_charset_utf16_hungarian_
     0xFFFF,            /* max_sort_char */
     ' ',               /* pad char      */
     0,                 /* escape_with_backslash_is_dangerous */
+    1,                 /* levels_for_compare */
+    1,                 /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };
@@ -11451,6 +11903,42 @@ CHARSET_INFO my_charset_utf16_sinhala_uc
     0xFFFF,            /* max_sort_char */
     ' ',               /* pad char      */
     0,                 /* escape_with_backslash_is_dangerous */
+    1,                 /* levels_for_compare */
+    1,                 /* levels_for_order   */
+    &my_charset_utf16_handler,
+    &my_collation_utf16_uca_handler
+};
+
+CHARSET_INFO my_charset_utf16_german2_uca_ci=
+{
+    121,0,0,           /* number       */
+    MY_CS_UTF16_UCA_FLAGS,/* state     */
+    "utf16",           /* cs name    */
+    "utf16_german2_ci",/* name         */
+    "",                /* comment      */
+    german2,           /* 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    */
+    8,                 /* strxfrm_multiply */
+    1,                 /* caseup_multiply  */
+    1,                 /* casedn_multiply  */
+    2,                 /* mbminlen     */
+    4,                 /* mbmaxlen     */
+    9,                 /* min_sort_char */
+    0xFFFF,            /* max_sort_char */
+    ' ',               /* pad char      */
+    0,                 /* escape_with_backslash_is_dangerous */
+    1,                 /* levels_for_compare */
+    1,                 /* levels_for_order   */
     &my_charset_utf16_handler,
     &my_collation_utf16_uca_handler
 };

=== modified file 'strings/ctype-ucs2.c'
--- a/strings/ctype-ucs2.c	2010-05-26 14:12:23 +0000
+++ b/strings/ctype-ucs2.c	2010-06-17 07:22:36 +0000
@@ -1775,6 +1775,8 @@ CHARSET_INFO my_charset_utf16_general_ci
   0xFFFF,              /* max_sort_char */
   ' ',                 /* pad char      */
   0,                   /* escape_with_backslash_is_dangerous */
+  1,                   /* levels_for_compare */
+  1,                   /* levels_for_order   */
   &my_charset_utf16_handler,
   &my_collation_utf16_general_ci_handler
 };
@@ -1808,6 +1810,8 @@ CHARSET_INFO my_charset_utf16_bin=
   0xFFFF,              /* max_sort_char */
   ' ',                 /* pad char      */
   0,                   /* escape_with_backslash_is_dangerous */
+  1,                   /* levels_for_compare */
+  1,                   /* levels_for_order   */
   &my_charset_utf16_handler,
   &my_collation_utf16_bin_handler
 };
@@ -2802,6 +2806,8 @@ CHARSET_INFO my_charset_utf32_general_ci
   0xFFFF,              /* max_sort_char */
   ' ',                 /* pad char      */
   0,                   /* escape_with_backslash_is_dangerous */
+  1,                   /* levels_for_compare */
+  1,                   /* levels_for_order   */
   &my_charset_utf32_handler,
   &my_collation_utf32_general_ci_handler
 };
@@ -2835,6 +2841,8 @@ CHARSET_INFO my_charset_utf32_bin=
   0xFFFF,              /* max_sort_char */
   ' ',                 /* pad char      */
   0,                   /* escape_with_backslash_is_dangerous */
+  1,                   /* levels_for_compare */
+  1,                   /* levels_for_order   */
   &my_charset_utf32_handler,
   &my_collation_utf32_bin_handler
 };
@@ -3487,6 +3495,8 @@ CHARSET_INFO my_charset_ucs2_general_ci=
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_general_ci_handler
 };
@@ -3519,6 +3529,8 @@ CHARSET_INFO my_charset_ucs2_bin=
     0xFFFF,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_ucs2_handler,
     &my_collation_ucs2_bin_handler
 };

=== modified file 'strings/ctype-ujis.c'
--- a/strings/ctype-ujis.c	2010-02-15 05:57:24 +0000
+++ b/strings/ctype-ujis.c	2010-03-22 09:13:41 +0000
@@ -67248,7 +67248,7 @@ static MY_COLLATION_HANDLER my_collation
     NULL,		/* init */
     my_strnncoll_simple,/* strnncoll    */
     my_strnncollsp_simple,
-    my_strnxfrm_simple,	/* strnxfrm     */
+    my_strnxfrm_mb,	/* strnxfrm     */
     my_strnxfrmlen_simple,
     my_like_range_mb,   /* like_range   */
     my_wildcmp_mb,	/* wildcmp      */
@@ -67319,6 +67319,8 @@ CHARSET_INFO my_charset_ujis_japanese_ci
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -67352,6 +67354,8 @@ CHARSET_INFO my_charset_ujis_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

=== modified file 'strings/ctype-utf8.c'
--- a/strings/ctype-utf8.c	2010-03-04 11:00:32 +0000
+++ b/strings/ctype-utf8.c	2010-03-22 09:13:41 +0000
@@ -1892,48 +1892,109 @@ my_wildcmp_unicode(CHARSET_INFO *cs,
 }
 
 
+/**
+  Pad buffer with weights for space characters.
+  
+  @details
+  This functions fills the buffer pointed by "str"
+  with weights of space character. Not more than
+  "nweights" weights are put. If at some iteration
+  step only a half of weight can fit
+  (which is possible if buffer length is an odd number)
+  then a half of this weight is put - this gives
+  a little bit better ORDER BY result for long strings.
+  
+  @str      Buffer
+  @strend   End of buffer
+  @nweights Number of weights
+  
+  @return Result length
+*/
+
+static size_t
+my_strxfrm_pad_nweights_unicode(uchar *str, uchar *strend, size_t nweights)
+{
+  uchar *str0;
+  DBUG_ASSERT(str && str <= strend); 
+  for (str0= str; str < strend && nweights; nweights--)
+  {
+    *str++= 0x00;
+    if (str < strend)
+      *str++= 0x20;
+  }
+  return str - str0;
+}
+
+
+/**
+  Pad buffer with weights for space characters.
+  
+  @details
+  This functions fills the buffer pointed by "str"
+  with weights of space character. Putting half of weight
+  (when buffer length is an odd number) is OK.
+  
+  @str      Buffer
+  @strend   End of buffer
+  
+  @return Result length
+*/
+
+static size_t
+my_strxfrm_pad_unicode(uchar *str, uchar *strend)
+{
+  uchar *str0= str;
+  DBUG_ASSERT(str && str <= strend); 
+  for ( ; str < strend ; )
+  {
+    *str++= 0x00;
+    if (str < strend)
+      *str++= 0x20;
+  }
+  return str - str0;
+}
+
+
 /*
   This function is shared between utf8mb3/utf8mb4/ucs2/utf16/utf32
 */
 size_t
 my_strnxfrm_unicode(CHARSET_INFO *cs,
-                    uchar *dst, size_t dstlen,
-                    const uchar *src, size_t srclen)
+                    uchar *dst, size_t dstlen, uint nweights,
+                    const uchar *src, size_t srclen, uint flags)
 {
   my_wc_t wc;
   int res;
+  uchar *dst0= dst;
   uchar *de= dst + dstlen;
-  uchar *de_beg= de - 1;
-  const uchar *se = src + srclen;
+  const uchar *se= src + srclen;
   MY_UNICASE_INFO **uni_plane= (cs->state & MY_CS_BINSORT) ?
                                 NULL : cs->caseinfo;
   LINT_INIT(wc);
   DBUG_ASSERT(src);
   
-  while (dst < de_beg)
+  for (; dst < de && nweights; nweights--)
   {
-    if ((res= cs->cset->mb_wc(cs,&wc, src, se)) <= 0)
+    if ((res= cs->cset->mb_wc(cs, &wc, src, se)) <= 0)
       break;
-    src+=res;
+    src+= res;
 
     if (uni_plane)
       my_tosort_unicode(uni_plane, &wc);
-
+    
     *dst++= (uchar) (wc >> 8);
     if (dst < de)
       *dst++= (uchar) (wc & 0xFF);
   }
-  
-  while (dst < de_beg) /* Fill the tail with keys for space character */
-  {
-    *dst++= 0x00;
-    *dst++= 0x20;
-  }
-  
-  if (dst < de)  /* Clear the last byte, if "dstlen" was an odd number */
-    *dst= 0x00;
-  
-  return dstlen;
+
+  if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+    dst+= my_strxfrm_pad_nweights_unicode(dst, de, nweights);
+
+  my_strxfrm_desc_and_reverse(dst0, dst, flags, 0);
+
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && dst < de)
+    dst+= my_strxfrm_pad_unicode(dst, de);
+  return dst - dst0;
 }
 
 
@@ -2674,7 +2735,7 @@ static uint my_mbcharlen_utf8(CHARSET_IN
 }
 
 
-static MY_COLLATION_HANDLER my_collation_ci_handler =
+static MY_COLLATION_HANDLER my_collation_utf8_general_ci_handler =
 {
     NULL,               /* init */
     my_strnncoll_utf8,
@@ -2689,6 +2750,22 @@ static MY_COLLATION_HANDLER my_collation
     my_propagate_complex
 };
 
+
+static MY_COLLATION_HANDLER my_collation_utf8_bin_handler =
+{
+    NULL,		/* init */
+    my_strnncoll_mb_bin,
+    my_strnncollsp_mb_bin,
+    my_strnxfrm_unicode,
+    my_strnxfrmlen_utf8,
+    my_like_range_mb,
+    my_wildcmp_mb_bin,
+    my_strcasecmp_mb_bin,
+    my_instr_mb,
+    my_hash_sort_mb_bin,
+    my_propagate_simple
+};
+
 MY_CHARSET_HANDLER my_charset_utf8_handler=
 {
     NULL,               /* init */
@@ -2750,8 +2827,10 @@ CHARSET_INFO my_charset_utf8_general_ci=
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
-    &my_collation_ci_handler
+    &my_collation_utf8_general_ci_handler
 };
 
 
@@ -2783,8 +2862,10 @@ CHARSET_INFO my_charset_utf8_bin=
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
-    &my_collation_mb_bin_handler
+    &my_collation_utf8_bin_handler
 };
 
 #ifdef HAVE_UTF8_GENERAL_CS
@@ -2966,6 +3047,8 @@ CHARSET_INFO my_charset_utf8_general_cs=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_utf8_handler,
     &my_collation_cs_handler
 };
@@ -4262,6 +4345,8 @@ CHARSET_INFO my_charset_filename=
     0xFFFF,             /* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_filename_handler,
     &my_collation_filename_handler
 };
@@ -5139,6 +5224,8 @@ CHARSET_INFO my_charset_utf8mb4_general_
   0xFFFF,             /* max_sort_char */
   ' ',                /* pad char      */
   0,                  /* escape_with_backslash_is_dangerous */
+  1,                  /* levels_for_compare */
+  1,                  /* levels_for_order   */
   &my_charset_utf8mb4_handler,
   &my_collation_utf8mb4_general_ci_handler
 };
@@ -5172,6 +5259,8 @@ CHARSET_INFO my_charset_utf8mb4_bin=
   0xFFFF,             /* max_sort_char */
   ' ',                /* pad char      */
   0,                  /* escape_with_backslash_is_dangerous */
+  1,                  /* levels_for_compare */
+  1,                  /* levels_for_order   */
   &my_charset_utf8mb4_handler,
   &my_collation_utf8mb4_bin_handler
 };

=== modified file 'strings/ctype-win1250ch.c'
--- a/strings/ctype-win1250ch.c	2007-05-10 09:59:39 +0000
+++ b/strings/ctype-win1250ch.c	2010-06-07 10:27:50 +0000
@@ -36,20 +36,10 @@
  * .configure. strxfrm_multiply_win1250ch=2
  */
 
-#define REAL_MYSQL
-#ifdef REAL_MYSQL
-
 #include "my_global.h"
 #include "m_string.h"
 #include "m_ctype.h"
 
-#else
-
-#include <stdio.h>
-#define uchar unsigned char
-
-#endif
-
 #ifdef HAVE_CHARSET_cp1250
 
 
@@ -488,9 +478,11 @@ int my_strnncollsp_win1250ch(CHARSET_INF
 }
 
 
-static size_t my_strnxfrm_win1250ch(CHARSET_INFO * cs  __attribute__((unused)),
-                                    uchar *dest, size_t len, 
-                                    const uchar *src, size_t srclen)
+static size_t
+my_strnxfrm_win1250ch(CHARSET_INFO * cs  __attribute__((unused)),
+                      uchar *dest, size_t len,
+                      uint nweights_arg __attribute__((unused)),
+                      const uchar *src, size_t srclen, uint flags)
 {
   int value;
   const uchar *p;
@@ -498,20 +490,27 @@ static size_t my_strnxfrm_win1250ch(CHAR
   size_t totlen = 0;
   p = src;
 
-  do {
+  if (!(flags & 0x0F)) /* All levels by default */                              
+    flags|= 0x0F;
+
+  for (;;)
+  {
     NEXT_CMP_VALUE(src, p, pass, value, (int)srclen);
-    if (totlen <= len)
-      dest[totlen] = value;
-    totlen++;
-  } while (value) ;
-  if (len > totlen)
-    bfill(dest + totlen, len - totlen, ' ');
-  return len;
+    if (!value)
+      break;
+    if (totlen <= len && ((1 << pass) & flags))
+      dest[totlen++] = value;
+  }
+  if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len > totlen)
+  {
+    bfill(dest + totlen, len - totlen, 0x00);
+    totlen= len;
+  }
+  return totlen;
 }
 
 #undef IS_END
 
-#ifdef REAL_MYSQL
 
 static uchar NEAR like_range_prefix_min_win1250ch[]=
 {
@@ -705,11 +704,11 @@ CHARSET_INFO my_charset_cp1250_czech_ci 
   0,				/* max_sort_char */
   ' ',                          /* pad char      */
   0,                            /* escape_with_backslash_is_dangerous */
+  2,                            /* levels_for_compare */
+  2,                            /* levels_for_order   */
   &my_charset_8bit_handler,
   &my_collation_czech_ci_handler
 };
 
 
-#endif /* REAL_MYSQL */
-
 #endif /* HAVE_CHARSET_cp1250 */

Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100621183800-l673fpx3v2vo5tru.bundle
Thread
bzr commit into mysql-next-mr branch (marc.alff:3155) Marc Alff21 Jun