List:Commits« Previous MessageNext Message »
From:bar Date:April 3 2007 11:16am
Subject:bk commit into 5.1 tree (bar:1.2474)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2474 07/04/03 16:16:17 bar@stripped +80 -0
  WL #3664 - strnxfrm() changes for prefix keys and NOPAD
  with partial implementation of
  WL #3716 - WEIGHT_STRING function
  The latter is an excellent tool to cover #3664 with tests,
  so it is implemented in the same patch.

  mysql-test/t/func_weight_string.test
    1.1 07/04/03 16:16:12 bar@stripped +97 -0
    New BitKeeper file ``mysql-test/t/func_weight_string.test''

  mysql-test/r/func_weight_string.result
    1.1 07/04/03 16:16:12 bar@stripped +71 -0
    New BitKeeper file ``mysql-test/r/func_weight_string.result''

  mysql-test/include/weight_string_l4.inc
    1.1 07/04/03 16:16:12 bar@stripped +10 -0
    New BitKeeper file ``mysql-test/include/weight_string_l4.inc''

  mysql-test/include/weight_string_l3.inc
    1.1 07/04/03 16:16:12 bar@stripped +10 -0
    New BitKeeper file ``mysql-test/include/weight_string_l3.inc''

  mysql-test/include/weight_string_l2.inc
    1.1 07/04/03 16:16:12 bar@stripped +7 -0
    New BitKeeper file ``mysql-test/include/weight_string_l2.inc''

  mysql-test/t/func_weight_string.test
    1.0 07/04/03 16:16:12 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/t/func_weight_string.test

  mysql-test/r/func_weight_string.result
    1.0 07/04/03 16:16:12 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/r/func_weight_string.result

  mysql-test/include/weight_string_l4.inc
    1.0 07/04/03 16:16:12 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l4.inc

  mysql-test/include/weight_string_l3.inc
    1.0 07/04/03 16:16:12 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l3.inc

  mysql-test/include/weight_string_l2.inc
    1.0 07/04/03 16:16:12 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l2.inc

  mysql-test/include/weight_string_l14.inc
    1.1 07/04/03 16:16:11 bar@stripped +37 -0
    New BitKeeper file ``mysql-test/include/weight_string_l14.inc''

  mysql-test/include/weight_string_l12.inc
    1.1 07/04/03 16:16:11 bar@stripped +5 -0
    New BitKeeper file ``mysql-test/include/weight_string_l12.inc''

  mysql-test/include/weight_string_l1.inc
    1.1 07/04/03 16:16:11 bar@stripped +10 -0
    New BitKeeper file ``mysql-test/include/weight_string_l1.inc''

  mysql-test/include/weight_string_chde.inc
    1.1 07/04/03 16:16:11 bar@stripped +21 -0
    New BitKeeper file ``mysql-test/include/weight_string_chde.inc''

  mysql-test/include/weight_string_l14.inc
    1.0 07/04/03 16:16:11 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l14.inc

  mysql-test/include/weight_string_l12.inc
    1.0 07/04/03 16:16:11 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l12.inc

  mysql-test/include/weight_string_l1.inc
    1.0 07/04/03 16:16:11 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_l1.inc

  mysql-test/include/weight_string_chde.inc
    1.0 07/04/03 16:16:11 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_chde.inc

  mysql-test/include/weight_string_A1A1.inc
    1.1 07/04/03 16:16:10 bar@stripped +11 -0
    New BitKeeper file ``mysql-test/include/weight_string_A1A1.inc''

  mysql-test/include/weight_string_8FA2C3.inc
    1.1 07/04/03 16:16:10 bar@stripped +11 -0
    New BitKeeper file ``mysql-test/include/weight_string_8FA2C3.inc''

  mysql-test/include/weight_string_8EA1.inc
    1.1 07/04/03 16:16:10 bar@stripped +11 -0
    New BitKeeper file ``mysql-test/include/weight_string_8EA1.inc''

  mysql-test/include/weight_string_8140.inc
    1.1 07/04/03 16:16:10 bar@stripped +11 -0
    New BitKeeper file ``mysql-test/include/weight_string_8140.inc''

  mysql-test/include/weight_string.inc
    1.1 07/04/03 16:16:10 bar@stripped +7 -0
    New BitKeeper file ``mysql-test/include/weight_string.inc''

  mysql-test/include/weight_string_A1A1.inc
    1.0 07/04/03 16:16:10 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_A1A1.inc

  mysql-test/include/weight_string_8FA2C3.inc
    1.0 07/04/03 16:16:10 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_8FA2C3.inc

  mysql-test/include/weight_string_8EA1.inc
    1.0 07/04/03 16:16:10 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_8EA1.inc

  mysql-test/include/weight_string_8140.inc
    1.0 07/04/03 16:16:10 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string_8140.inc

  mysql-test/include/weight_string.inc
    1.0 07/04/03 16:16:10 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/weight_string.inc

  mysql-test/include/ctype_pad_space.inc
    1.1 07/04/03 16:16:09 bar@stripped +5 -0
    New BitKeeper file ``mysql-test/include/ctype_pad_space.inc''

  strings/ctype-win1250ch.c
    1.59 07/04/03 16:16:09 bar@stripped +113 -56
    - Adding new parameters
    - Adding new CHARSET_INFO members.
    - Removing unesed ifdef/define (leftovers from the original contributed patch)
    - Making cp1250_czech_cs "PAD SPACE", like all other MySQL collations.

  strings/ctype-utf8.c
    1.113 07/04/03 16:16:09 bar@stripped +81 -12
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-ujis.c
    1.75 07/04/03 16:16:09 bar@stripped +6 -1
    Using multibyte-aware function, instead of 8bit counterpart.
    Adding new CHARSET_INFO members.

  strings/ctype-ucs2.c
    1.69 07/04/03 16:16:09 bar@stripped +23 -16
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-uca.c
    1.44 07/04/03 16:16:09 bar@stripped +101 -22
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-tis620.c
    1.96 07/04/03 16:16:09 bar@stripped +15 -10
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-sjis.c
    1.94 07/04/03 16:16:09 bar@stripped +5 -25
    Removing a separate function, using my_strnxfrm_mb instead.
    Adding new CHARSET_INFO members.

  strings/ctype-simple.c
    1.86 07/04/03 16:16:09 bar@stripped +148 -12
    Adding new parameters.
    Adding new function for strnxfrm flag normalization.
    Adding new function to apply REVERSE and DESC strnxfrm flags.

  strings/ctype-mb.c
    1.57 07/04/03 16:16:09 bar@stripped +120 -28
    Adding new function my_strnxfrm_mb - it is shared between many mb charsets.

  strings/ctype-latin1.c
    1.53 07/04/03 16:16:09 bar@stripped +22 -13
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-gbk.c
    1.83 07/04/03 16:16:09 bar@stripped +30 -19
    Adding new parameters.
    Adding new CHARSET_INFO members.

  strings/ctype-gb2312.c
    1.69 07/04/03 16:16:09 bar@stripped +6 -1
    Using multi-byte aware function instead if 8bit counterpart.
    Adding new CHARSET_INFO members.

  mysql-test/include/ctype_pad_space.inc
    1.0 07/04/03 16:16:09 bar@stripped +0 -0
    BitKeeper file /home/bar/mysql-5.1-wl3664/mysql-test/include/ctype_pad_space.inc

  strings/ctype-extra.c
    1.29 07/04/03 16:16:08 bar@stripped +124 -66
    The file was recreated using conf_to_src:
    - new CHARSET_INFO members were added
    - double definition of "geostd8" was removed

  strings/ctype-eucjpms.c
    1.18 07/04/03 16:16:08 bar@stripped +6 -1
    Using multi-byte aware function instead if 8bit counterpart.
    Adding new CHARSET_INFO members.

  strings/ctype-euc_kr.c
    1.72 07/04/03 16:16:08 bar@stripped +6 -1
    Using multi-byte aware function instead if 8bit counterpart.
    Adding new CHARSET_INFO members.

  strings/ctype-czech.c
    1.65 07/04/03 16:16:08 bar@stripped +296 -151
    Adding new parameters
    - Making latin_czech_cs "PAD SPACE", like all other MySQL collations
    - Removing various unesed ifdef/define (leftovers from contributed patch)
    - Some other changes, see "In Matrch 2007..." comment for details.

  strings/ctype-cp932.c
    1.17 07/04/03 16:16:08 bar@stripped +5 -25
    Removing a separate function, reuse my_strnxfrm_mb().
    Adding new CHARSET_INFO members.

  strings/ctype-bin.c
    1.76 07/04/03 16:16:08 bar@stripped +14 -23
    Adding new parameters

  strings/ctype-big5.c
    1.92 07/04/03 16:16:08 bar@stripped +30 -67
    Adding new parameters.

  strings/conf_to_src.c
    1.22 07/04/03 16:16:08 bar@stripped +2 -0
    Dumping new CHARSET_INFO members.

  storage/ndb/src/common/util/NdbSqlUtil.cpp
    1.38 07/04/03 16:16:08 bar@stripped +4 -2
    Pass new parameters.

  sql/sql_yacc.yy
    1.550 07/04/03 16:16:08 bar@stripped +93 -1
    Adding WEIGHT_STRING() syntax.
    Adding creation of REVERSE() function.

  sql/lex.h
    1.171 07/04/03 16:16:08 bar@stripped +2 -0
    Adding new parser symbols

  sql/item_strfunc.h
    1.126 07/04/03 16:16:08 bar@stripped +15 -0
    Class prototype for the WEIGHT_STRING function

  sql/item_strfunc.cc
    1.314 07/04/03 16:16:08 bar@stripped +44 -0
    Implementation of the WEIGHT_STRING() function - returns
    results of strnxfrm() with various flags.

  sql/item_create.cc
    1.74 07/04/03 16:16:08 bar@stripped +0 -23
    Removing Create_func_revers, as function REVERSE()
    is now created directly in sql_yacc.yy because
    REVERSE now is a new non-reserved keyword.

  mysys/charset.c
    1.150 07/04/03 16:16:08 bar@stripped +3 -0
    Initializing new members.

  mysql-test/t/ctype_utf8.test
    1.104 07/04/03 16:16:08 bar@stripped +23 -0
    Adding tests

  mysql-test/t/ctype_ujis.test
    1.20 07/04/03 16:16:08 bar@stripped +16 -0
    Adding tests

  mysql-test/t/ctype_ucs.test
    1.51 07/04/03 16:16:08 bar@stripped +9 -0
    Adding tests

  mysql-test/t/ctype_uca.test
    1.16 07/04/03 16:16:08 bar@stripped +16 -0
    Adding tests

  mysql-test/t/ctype_tis620.test
    1.14 07/04/03 16:16:08 bar@stripped +14 -0
    Adding tests

  mysql-test/t/ctype_sjis.test
    1.13 07/04/03 16:16:08 bar@stripped +12 -0
    Adding tests

  mysql-test/t/ctype_latin2_ch.test
    1.3 07/04/03 16:16:08 bar@stripped +14 -1
    Adding tests

  mysql-test/t/ctype_latin2.test
    1.4 07/04/03 16:16:08 bar@stripped +10 -0
    Adding tests

  mysql-test/t/ctype_latin1_de.test
    1.27 07/04/03 16:16:07 bar@stripped +23 -0
    Adding tests

  mysql-test/t/ctype_latin1.test
    1.11 07/04/03 16:16:07 bar@stripped +20 -0
    Adding tests

  mysql-test/t/ctype_gbk.test
    1.6 07/04/03 16:16:07 bar@stripped +15 -0
    Adding tests

  mysql-test/t/ctype_gb2312.test
    1.2 07/04/03 16:16:07 bar@stripped +11 -0
    Adding tests

  mysql-test/t/ctype_euckr.test
    1.2 07/04/03 16:16:07 bar@stripped +11 -0
    Adding tests

  mysql-test/t/ctype_eucjpms.test
    1.10 07/04/03 16:16:07 bar@stripped +15 -0
    Adding tests

  mysql-test/t/ctype_cp932_binlog_stm.test
    1.5 07/04/03 16:16:07 bar@stripped +9 -0
    Adding tests.

  mysql-test/t/ctype_cp1250_ch.test
    1.9 07/04/03 16:16:07 bar@stripped +10 -0
    Adding tests

  mysql-test/t/ctype_big5.test
    1.12 07/04/03 16:16:07 bar@stripped +11 -0
    Adding tests

  mysql-test/r/ctype_utf8.result
    1.114 07/04/03 16:16:07 bar@stripped +124 -0
    Adding tests

  mysql-test/r/ctype_ujis.result
    1.20 07/04/03 16:16:07 bar@stripped +303 -0
    Adding tests

  mysql-test/r/ctype_ucs.result
    1.55 07/04/03 16:16:07 bar@stripped +104 -0
    Adding tests

  mysql-test/r/ctype_uca.result
    1.18 07/04/03 16:16:07 bar@stripped +221 -0
    Adding tests

  mysql-test/r/ctype_tis620.result
    1.14 07/04/03 16:16:07 bar@stripped +117 -0
    Adding tests

  mysql-test/r/ctype_sjis.result
    1.13 07/04/03 16:16:07 bar@stripped +170 -0
    Adding tests

  mysql-test/r/ctype_latin2_ch.result
    1.3 07/04/03 16:16:07 bar@stripped +313 -0
    Adding tests

  mysql-test/r/ctype_latin2.result
    1.3 07/04/03 16:16:07 bar@stripped +70 -1
    Adding tests

  mysql-test/r/ctype_latin1_de.result
    1.26 07/04/03 16:16:07 bar@stripped +104 -0
    Adding tests

  mysql-test/r/ctype_latin1.result
    1.10 07/04/03 16:16:07 bar@stripped +210 -0
    Adding tests

  mysql-test/r/ctype_gbk.result
    1.5 07/04/03 16:16:07 bar@stripped +302 -0
    Adding tests

  mysql-test/r/ctype_gb2312.result
    1.3 07/04/03 16:16:07 bar@stripped +170 -0
    Adding tests

  mysql-test/r/ctype_euckr.result
    1.3 07/04/03 16:16:07 bar@stripped +170 -0
    Adding tests

  mysql-test/r/ctype_eucjpms.result
    1.7 07/04/03 16:16:07 bar@stripped +303 -0
    Adding tests

  mysql-test/r/ctype_cp932_binlog_stm.result
    1.5 07/04/03 16:16:07 bar@stripped +170 -0
    Adding tests

  mysql-test/r/ctype_cp1250_ch.result
    1.10 07/04/03 16:16:07 bar@stripped +169 -0
    Adding tests

  mysql-test/r/ctype_big5.result
    1.12 07/04/03 16:16:07 bar@stripped +170 -0
    Adding tests

  mysql-test/r/binlog_stm_ctype_cp932.result
    1.16 07/04/03 16:16:07 bar@stripped +111 -0
    Adding tests

  mysql-test/r/binlog_row_ctype_cp932.result
    1.8 07/04/03 16:16:07 bar@stripped +111 -0
    Adding tests

  mysql-test/extra/binlog_tests/ctype_cp932.test
    1.18 07/04/03 16:16:07 bar@stripped +10 -0
    Adding tests

  include/m_ctype.h
    1.135 07/04/03 16:16:07 bar@stripped +75 -4
    Adding strnxfrm flags for levels, PAD, REVERSE and DESC.
    Adding "flags" and "nweights" parameters.
    Adding "levels_for_compare" and "levels_for_sort" members into CHARSET_INFO.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.myoffice.izhnet.ru
# Root:	/home/bar/mysql-5.1-wl3664

--- 1.134/include/m_ctype.h	2007-01-29 03:51:37 +04:00
+++ 1.135/include/m_ctype.h	2007-04-03 16:16:07 +05:00
@@ -86,6 +86,39 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
 #define MY_CS_HIDDEN	2048   /* don't display in SHOW          */	
 #define MY_CHARSET_UNDEFINED 0
 
+/* 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_UNUSED_00000080 0x00000080 /* for future extensions     */
+
+#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
 {
@@ -131,7 +164,8 @@ typedef struct my_collation_handler_st
                          const uchar *, uint, const uchar *, uint,
                          my_bool diff_if_only_endspace_difference);
   int     (*strnxfrm)(struct charset_info_st *,
-		      uchar *, uint, const uchar *, uint);
+		      uchar *dst, uint dstlen, uint nweights,
+		      const uchar *src, uint srclen, uint flags);
   uint    (*strnxfrmlen)(struct charset_info_st *, uint); 
   my_bool (*like_range)(struct charset_info_st *,
 			const char *s, uint s_length,
@@ -261,6 +295,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;
@@ -300,8 +336,9 @@ extern CHARSET_INFO my_charset_cp1250_cz
 extern CHARSET_INFO my_charset_filename;
 
 /* declarations for simple charsets */
-extern int  my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *,
-                               uint); 
+extern int  my_strnxfrm_simple(CHARSET_INFO *,
+                               uchar *dst, uint dstlen, uint nweights,
+                               const uchar *src, uint srclen, uint flags); 
 uint  my_strnxfrmlen_simple(CHARSET_INFO *, uint); 
 extern int  my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint,
 				const uchar *, uint, my_bool);
@@ -436,6 +473,31 @@ uint my_instr_mb(struct charset_info_st 
                  const char *s, uint s_length,
                  my_match_t *match, uint nmatch);
 
+int my_strnncoll_mb_bin(CHARSET_INFO * cs,
+                        const uchar *s, uint slen,
+                        const uchar *t, uint tlen,
+                        my_bool t_is_prefix);
+
+int my_strnncollsp_mb_bin(CHARSET_INFO *cs,
+                          const uchar *a, uint a_length, 
+                          const uchar *b, uint b_length,
+                          my_bool diff_if_only_endspace_difference);
+
+int my_wildcmp_mb_bin(CHARSET_INFO *cs,
+                      const char *str,const char *str_end,
+                      const char *wildstr,const char *wildend,
+                      int escape, int w_one, int w_many);
+
+int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
+                         const char *s, const char *t);
+
+void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
+                         const uchar *key, uint len,ulong *nr1, ulong *nr2);
+
+int  my_strnxfrm_mb(CHARSET_INFO *,
+                    uchar *dst, uint dstlen, uint nweights,
+                    const uchar *src, uint srclen, uint flags); 
+
 int my_wildcmp_unicode(CHARSET_INFO *cs,
                        const char *str, const char *str_end,
                        const char *wildstr, const char *wildend,
@@ -451,6 +513,14 @@ my_bool my_propagate_simple(CHARSET_INFO
 my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len);
 
 
+uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
+void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
+                                 uint flags, uint level);
+uint my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
+                                     uchar *str, uchar *frmend, uchar *strend,
+                                     uint nweights, uint flags, uint level);
+
+
 #define	_MY_U	01	/* Upper case */
 #define	_MY_L	02	/* Lower case */
 #define	_MY_NMR	04	/* Numeral (digit) */
@@ -485,7 +555,8 @@ my_bool my_propagate_complex(CHARSET_INF
 
 #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)))

--- 1.149/mysys/charset.c	2006-12-23 23:04:07 +04:00
+++ 1.150/mysys/charset.c	2007-04-03 16:16:08 +05:00
@@ -229,6 +229,9 @@ static int add_collation(CHARSET_INFO *c
       if (cs_copy_data(all_charsets[cs->number],cs))
         return MY_XML_ERROR;
 
+      new->levels_for_compare= 1;
+      new->levels_for_order= 1;
+      
       if (!strcmp(cs->csname,"ucs2") )
       {
 #if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS)

--- 1.73/sql/item_create.cc	2007-01-12 15:24:32 +04:00
+++ 1.74/sql/item_create.cc	2007-04-03 16:16:08 +05:00
@@ -1732,19 +1732,6 @@ protected:
 };
 
 
-class Create_func_reverse : public Create_func_arg1
-{
-public:
-  virtual Item* create(THD *thd, Item *arg1);
-
-  static Create_func_reverse s_singleton;
-
-protected:
-  Create_func_reverse() {}
-  virtual ~Create_func_reverse() {}
-};
-
-
 class Create_func_round : public Create_native_func
 {
 public:
@@ -4170,15 +4157,6 @@ Create_func_release_lock::create(THD *th
 }
 
 
-Create_func_reverse Create_func_reverse::s_singleton;
-
-Item*
-Create_func_reverse::create(THD *thd, Item *arg1)
-{
-  return new (thd->mem_root) Item_func_reverse(arg1);
-}
-
-
 Create_func_round Create_func_round::s_singleton;
 
 Item*
@@ -4834,7 +4812,6 @@ static Native_func_registry func_array[]
   { C_STRING_WITH_LEN("RADIANS"), BUILDER(Create_func_radians)},
   { C_STRING_WITH_LEN("RAND"), BUILDER(Create_func_rand)},
   { C_STRING_WITH_LEN("RELEASE_LOCK"), BUILDER(Create_func_release_lock)},
-  { C_STRING_WITH_LEN("REVERSE"), BUILDER(Create_func_reverse)},
   { C_STRING_WITH_LEN("ROUND"), BUILDER(Create_func_round)},
   { C_STRING_WITH_LEN("ROW_COUNT"), BUILDER(Create_func_row_count)},
   { C_STRING_WITH_LEN("RPAD"), BUILDER(Create_func_rpad)},

--- 1.313/sql/item_strfunc.cc	2007-03-07 13:24:11 +04:00
+++ 1.314/sql/item_strfunc.cc	2007-04-03 16:16:08 +05:00
@@ -2687,6 +2687,50 @@ 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);
+  max_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]->null_value ||
+      args[0]->result_type() != STRING_RESULT ||
+      !(res= args[0]->val_str(str)))
+    goto nl;
+  
+  tmp_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;

--- 1.125/sql/item_strfunc.h	2007-01-24 17:55:03 +04:00
+++ 1.126/sql/item_strfunc.h	2007-04-03 16:16:08 +05:00
@@ -782,6 +782,21 @@ 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;
+public:
+  Item_func_weight_string(Item *a, uint nweights_arg, uint flags_arg)
+  :Item_str_func(a) { nweights= nweights_arg; flags= flags_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;

--- 1.170/sql/lex.h	2007-02-24 00:48:12 +04:00
+++ 1.171/sql/lex.h	2007-04-03 16:16:08 +05:00
@@ -436,6 +436,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 */
@@ -568,6 +569,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)},

--- 1.549/sql/sql_yacc.yy	2007-03-07 17:08:31 +04:00
+++ 1.550/sql/sql_yacc.yy	2007-04-03 16:16:08 +05:00
@@ -915,6 +915,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 */
@@ -1051,6 +1052,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
@@ -1116,7 +1118,11 @@ bool my_yyoverflow(short **a, YYSTYPE **
         ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt
 
 %type <ulong_num>
-	ulong_num real_ulong_num merge_insert_types
+        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
@@ -4888,6 +4894,74 @@ opt_bin_charset:
 	}
 	| charset charset_name	{ Lex->charset=$2; } ;
 
+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 */
 	| PRIMARY_SYM
@@ -6751,6 +6825,8 @@ function_call_conflict:
 	  { $$= new (YYTHD->mem_root) Item_func_repeat($3,$5); }
 	| REPLACE '(' expr ',' expr ',' expr ')'
 	  { $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7); }
+	| REVERSE_SYM '(' expr ')'
+	  { $$= new (YYTHD->mem_root) Item_func_reverse($3); }
 	| TRUNCATE_SYM '(' expr ',' expr ')'
 	  { $$= new (YYTHD->mem_root) Item_func_round($3,$5,1); }
 	| WEEK_SYM '(' expr ')'
@@ -6764,6 +6840,20 @@ function_call_conflict:
           }
 	| WEEK_SYM '(' expr ',' expr ')'
 	  { $$= new (YYTHD->mem_root) Item_func_week($3,$5); }
+	| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
+	  { $$= new (YYTHD->mem_root) Item_func_weight_string($3, 0, $4); }
+	| WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
+	  {
+            $$= new (YYTHD->mem_root)
+                Item_func_weight_string($3, $6, $7|MY_STRXFRM_PAD_WITH_SPACE);
+          }
+	| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
+	  {
+            $3= create_func_cast(YYTHD, $3, ITEM_CAST_CHAR, $6, 0,
+                                 &my_charset_bin);
+            $$= new (YYTHD->mem_root)
+                Item_func_weight_string($3, $6, MY_STRXFRM_PAD_WITH_SPACE);
+          }
         | geometry_function
           {
 #ifdef HAVE_SPATIAL
@@ -9986,6 +10076,7 @@ keyword_sp:
 	| RESOURCES		{}
         | RESUME_SYM            {}
 	| RETURNS_SYM           {}
+        | REVERSE_SYM           {}
 	| ROLLUP_SYM		{}
 	| ROUTINE_SYM		{}
 	| ROWS_SYM		{}
@@ -10046,6 +10137,7 @@ keyword_sp:
 	| WARNINGS		{}
 	| WAIT_SYM              {}
 	| WEEK_SYM		{}
+	| WEIGHT_STRING_SYM	{}
 	| WORK_SYM		{}
 	| X509_SYM		{}
 	| YEAR_SYM		{}

--- 1.21/strings/conf_to_src.c	2007-01-11 17:09:59 +04:00
+++ 1.22/strings/conf_to_src.c	2007-04-03 16:16:08 +05:00
@@ -233,6 +233,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)

--- 1.91/strings/ctype-big5.c	2006-12-23 23:20:32 +04:00
+++ 1.92/strings/ctype-big5.c	2007-04-03 16:16:08 +05:00
@@ -301,78 +301,36 @@ static int my_strnncollsp_big5(CHARSET_I
 }
 
 
-static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)),
-                     uchar * dest, uint len, 
-                     const uchar * src, uint srclen)
-{
-  uint16 e;
-  uint dstlen= len;
-
-  len = srclen;
-  while (len--)
-  {
-    if ((len > 0) && isbig5code(*src, *(src+1)))
-    {
-      e = big5strokexfrm((uint16) big5code(*src, *(src+1)));
-      *dest++ = big5head(e);
-      *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)
+static int
+my_strnxfrm_big5(CHARSET_INFO *cs,
+                 uchar *dst, uint dstlen, uint nweights,
+                 const uchar *src, uint srclen, uint flags)
 {
-  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
 
 
 /*
@@ -6343,6 +6301,7 @@ static MY_COLLATION_HANDLER my_collation
   my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_big5_handler=
 {
   NULL,			/* init */
@@ -6402,6 +6361,8 @@ CHARSET_INFO my_charset_big5_chinese_ci=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_big5_handler,
     &my_collation_big5_chinese_ci_handler
 };
@@ -6435,6 +6396,8 @@ CHARSET_INFO my_charset_big5_bin=
     255,		/* max_sort_char */
     ' ',                /* pad char      */
     0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* levels_for_compare */
+    1,                  /* levels_for_order   */
     &my_charset_big5_handler,
     &my_collation_mb_bin_handler
 };

--- 1.64/strings/ctype-czech.c	2006-12-23 23:04:29 +04:00
+++ 1.65/strings/ctype-czech.c	2007-04-03 16:16:08 +05:00
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-/* File strings/ctype-czech.c for MySQL.
+/*
+        File strings/ctype-czech.c for MySQL.
 
 	This file implements the Czech sorting for the MySQL database
 	server (www.mysql.com). Due to some complicated rules the
@@ -59,23 +60,10 @@
  * .configure. strxfrm_multiply_czech=4
  */
 
-#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
 
 /*
@@ -83,34 +71,117 @@
 	below for what are the "special values"
 */
 
-static uchar * CZ_SORT_TABLE[] = {
-  (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\043\044\045\046\047\050\051\052\053\054\000\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024\024\024\024\000\030\034\034\034\034\040\033\000\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024!
 \024\024\024\000\030\034\034\034\034\040\033\000",
-  (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\106\107\110\111\112\113\114\115\116\117\000\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050\051\053\052\000\060\072\071\074\073\101\067\000\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050!
 \051\053\052\000\060\072\071\074\073\101\067\000",
-(uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\212\213\214\215\216\217\220\221\222\223\000\000\000\000\000\000\000\004\020\377\032\040\052\054\056\063\071\073\075\105\107\115\127\131\133\141\151\157\171\173\175\177\203\000\000\000\000\000\000\003\017\377\031\037\051\053\055\062\070\072\074\104\106\114\126\130\132\140\150\156\170\172\174\176\202\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\103\000\101\145\000\000\143\147\153\207\000\205\211\000\015\000\102\000\100\144\000\000\142\146\152\206\000\204\210\135\006\010\014\012\077\026\030\024\042\050\046\044\065\067\034\036\113\111\117\121\125\123\000\137\163\161\167\165\201\155\000\134\005\007\013\011\076\025\027\023\041\047\045\043\064\066\033\035\112\110\116\1!
 20\124\122\000\136\162\160\166\164\200\154\000",
-(uchar*) "\264\265\266\267\270\271\272\273\274\002\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\002\230\232\253\324\252\251\234\240\241\261\260\225\262\224\235\212\213\214\215\216\217\220\221\222\223\231\226\244\257\245\227\250\004\020\377\032\040\052\054\056\063\071\073\075\105\107\115\127\131\133\141\151\157\171\173\175\177\203\242\237\243\254\255\233\003\017\377\031\037\051\053\055\062\070\072\074\104\106\114\126\130\132\140\150\156\170\172\174\176\202\246\236\247\256\325\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\326\016\327\103\330\101\145\331\332\143\147\153\207\333\205\211\334\015\335\102\336\100\144\337\340\142\146\152\206\341\204\210\135\006\010\014\012\077\026\030\024\042\050\046\044\065\067\034\036\113\111\117\121\125\123\263\137\163\161\167\165\201\155\342\134\005\007\013\011\076\025\027\023\041\047\045\043\064\066\033\035\112\110\116\1!
 20\124\122\343\136\162\160\166\164\200\154\344",
+static const uchar *CZ_SORT_TABLE[]=
+{
+  (const uchar*)
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x41\x42\x43\x44\x45\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x47\x58\x5C\x6A\x77\x6B\x69\x5B\x5E\x5F\x66\x6E\x55\x54\x5A\x67"
+  "\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x57\x56\x71\x72\x73\x59"
+  "\x65\x82\x83\xFF\x86\x87\x88\x89\x8A\x8C\x8D\x8E\x8F\x90\x91\x93"
+  "\x94\x95\x96\x98\x9A\x9C\x9D\x9E\x9F\xA0\xA1\x60\x68\x61\x4B\x52"
+  "\x49\x82\x83\xFF\x86\x87\x88\x89\x8A\x8C\x8D\x8E\x8F\x90\x91\x92"
+  "\x94\x95\x96\x98\x9A\x9B\x9D\x9E\x9F\xA0\xA1\x62\x74\x63\x75\x00"
+  "\x00\x00\x00\x00\x00\x46\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x48\x82\x4C\x8F\x76\x8F\x98\x64\x4E\x99\x98\x9A\xA1\x53\xA2\xA1"
+  "\x6D\x82\x51\x8F\x4A\x8F\x98\x6C\x50\x99\x98\x9A\xA1\x4F\xA2\xA1"
+  "\x96\x82\x82\x82\x82\x8F\x84\x84\x85\x87\x87\x87\x87\x8C\x8C\x86"
+  "\x86\x91\x91\x93\x93\x93\x93\x70\x97\x9C\x9C\x9C\x9C\xA0\x9A\x98"
+  "\x96\x82\x82\x82\x82\x8F\x84\x84\x85\x87\x87\x87\x87\x8C\x8C\x86"
+  "\x86\x91\x91\x92\x92\x92\x92\x6F\x97\x9B\x9B\x9B\x9B\xA0\x9A\x4D",
+
+  (const uchar*)
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x20\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
+  "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
+  "\x20\x20\x20\xFF\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
+  "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
+  "\x20\x20\x20\xFF\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
+  "\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x00"
+  "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x20\x2B\x20\x2C\x20\x25\x22\x20\x20\x25\x2A\x25\x22\x20\x25\x29"
+  "\x20\x2B\x20\x2C\x20\x25\x22\x20\x20\x25\x2A\x25\x22\x20\x25\x29"
+  "\x22\x22\x24\x23\x27\x22\x22\x2A\x25\x22\x2B\x47\x25\x22\x24\x25"
+  "\x2C\x22\x25\x22\x24\x28\x27\x20\x25\x26\x22\x28\x27\x22\x2A\x21"
+  "\x22\x22\x24\x23\x27\x22\x22\x2A\x25\x22\x2B\x47\x25\x22\x24\x25"
+  "\x2C\x22\x25\x22\x24\x28\x27\x20\x25\x26\x22\x28\x27\x22\x2A\x20",
+
+
+  (const uchar*)
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x03\x03\x03\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+  "\x03\x05\x05\xFF\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05"
+  "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x03\x03\x03\x03\x03"
+  "\x03\x03\x03\xFF\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x00"
+  "\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+  "\x1B\x05\x03\x05\x03\x05\x05\x03\x03\x05\x05\x05\x05\x03\x05\x05"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+  "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05"
+  "\x05\x05\x05\x05\x05\x05\x05\x03\x05\x05\x05\x05\x05\x05\x05\x03"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03"
+  "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03",
+
+  (const uchar*)
+  "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
+  "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
+  "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"
+  "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
+  "\x40\x41\x42\xFF\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F"
+  "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F"
+  "\x60\x61\x62\xFF\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F"
+  "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F"
+  "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F"
+  "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F"
+  "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF"
+  "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF"
+  "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF"
+  "\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"
+  "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF"
+  "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"
 };
 
 /*
-	These define the valuse for the double chars that need to be
-	sorted as they were single characters -- in Czech these are
-	'ch', 'Ch' and 'CH'.
+  These define the values for the double chars that need to be
+  sorted as they were single characters -- in Czech these are
+  'ch', 'Ch' and 'CH'.
 */
 
 struct wordvalue
-	{
-	  const char * word;
-	  uchar * outvalue;
-	};
-static struct wordvalue doubles[] = {
-	{ "ch", (uchar*) "\014\031\057\057" },
-	{ "Ch", (uchar*) "\014\031\060\060" },
-	{ "CH", (uchar*) "\014\031\061\061" },
-	{ "c",  (uchar*) "\005\012\021\021" },
-	{ "C",  (uchar*) "\005\012\022\022" },
-	};
+{
+  const uchar *word;
+  const uchar *outvalue;
+};
+
+static struct wordvalue doubles[]=
+{
+  { "ch", (const uchar*) "\x8B\x20\x03\x63" },
+  { "Ch", (const uchar*) "\x8B\x20\x04\x43" },
+  { "CH", (const uchar*) "\x8B\x20\x05\x43" },
+  { "c",  (const uchar*) "\x84\x20\x03\x63" },
+  { "C",  (const uchar*) "\x84\x20\x05\x43" },
+};
+
+
+/*
+  Define "auto" space character,
+  which is used while processing "PAD SPACE" rule,
+  when one string is shorter than another string.
+  "Auto" space character is lower than a real space
+  character on the third level.
+*/
+static const uchar *virtual_space= "\x47\x20\x02\x20";
 
 /*
-	Unformal description of the algorithm:
+        Original comments from the contributor:
+        
+	Informal description of the algorithm:
 
 	We walk the string left to right.
 
@@ -131,44 +202,95 @@ static struct wordvalue doubles[] = {
 
 	If the value is space/end of word (2) and we are in the first
 	or second pass, we skip all characters having value 0 -- 2 and
-	switch the passwd.
+	switch the pass.
 
 	If it's the compose character (255), we check if the double
 	exists behind it, find its value.
 
 	We append 0 to the end.
----
-
 
-
 
 
 
+*/
 
+/*
+  In March 2007 latin2_czech_cs was reworked by Alexander Barkov,
+  to suite other MySQL collations better, and to be Falcon compatible.
+  
+  Changes:
+  - Discarded word-by-word comparison on the primary and the secondary level.
+    Comparison is now strictly done level-by-level
+    (like the Unicode Collation Algorithm (UCA) does).
+    
+  - Character weights were derived from Unicode 5.0.0 standard.
+    This is to make order of punctuation characters and digits
+    more consistent with all other MySQL collations and UCA.
+    
+    The order is now:
+    
+      Controls, spaces, punctuations, digits, letters.
+    
+    It previously used to be:
+    
+      Punctuations, controls, some more punctuations, letters, digits.
+    
+    NOTE:
+    
+    A minor difference between this implementations and the UCA:
+    
+    German "LATIN SMALL LETTER SHARP S" does not expand to "ss".
+    It is instead considered as secondary greater than "LATIN LETTER S",
+    and thus sorted between "LATIN LETTER S" and "LATIN LETTER S WITH ACUTE".
+    This allows to reduce *twice* disk space required for un-indexed
+    ORDER BY (using the filesort method).
+    
+    As neither the original version of latin2_czech_cs 
+    expanded "SHARP S" to "ss", nor "SHARP S" is a part of Czech alphabet,
+    this behavior should be ok.
+    
+  - Collation is now "PAD SPACE" like all other MySQL collations.
+    It ignores trailing spaces on primary and secondary level.
+    
+  - SPACE and TAB characters are not ignorable anymore.
+    Also, they have different weights on primary level,
+    like in all other MySQL collations:
+    
+    SELECT 'a\t' < 'a ' -- returns true
+    SELECT 'a\t' < 'a'  -- returns true
+    
+  - Some other punctuation characters are not ignorable anymore,
+    for better compatibility with UCA and other MySQL collations.
 
+*/
 
- */
 
 #define ADD_TO_RESULT(dest, len, totlen, value)			\
 if ((totlen) < (len)) { dest[totlen] = value; } (totlen++);
 #define IS_END(p, src, len)	(((char *)p - (char *)src) >= (len))
 
-#define NEXT_CMP_VALUE(src, p, store, pass, value, len)		\
+/*
+  ml - a flag indicating whether automatically
+       switch to the secondary level,
+       or stop on the primary level
+*/
+                
+#define NEXT_CMP_VALUE(src, p, pass, value, len, ml)	\
 while (1)						\
 {							\
   if (IS_END(p, src, len))				\
@@ -176,38 +298,18 @@ while (1)						\
     /* when we are at the end of string */		\
     /* return either 0 for end of string */		\
    /* or 1 for end of pass */				\
-   value= 0;						\
-   if (pass != 3)					\
+   value= pass < 3 && ml ? 1 : -1;			\
+   if (pass != 3 && ml && len > 0)			\
    {							\
-     p= (pass++ == 0) ? store : src;			\
-     value = 1;						\
+     p= src;						\
+     pass++;						\
    }							\
    break;						\
   }							\
   /* not at end of string */				\
   value = CZ_SORT_TABLE[pass][*p];			\
-  if (value == 0)					\
-  { p++; continue; } /* ignore value */			\
-  if (value == 2) /* space */				\
-  {							\
-    const uchar * tmp;					\
-    const uchar * runner = ++p;				\
-    while (!(IS_END(runner, src, len)) && (CZ_SORT_TABLE[pass][*runner] == 2)) \
-     runner++;	/* skip all spaces */			\
-    if (IS_END(runner, src, len) && SKIP_TRAILING_SPACES) \
-      p = runner;					\
-    if ((pass <= 2) && !(IS_END(runner, src, len)))	\
-      p = runner;					\
-    if (IS_END(p, src, len))				\
-      continue;						\
-    /* we switch passes */				\
-    if (pass > 1)					\
-      break;						\
-    tmp = p;						\
-    pass= 1-pass;					\
-    p = store; store = tmp;				\
-    break;						\
-  }							\
+  if (value == 0 && pass < 3)				\
+  { p++; continue; } /* ignore value on levels 0,1,2 */	\
   if (value == 255)					\
   {							\
     int i;						\
@@ -245,20 +347,20 @@ static int my_strnncoll_czech(CHARSET_IN
                               my_bool s2_is_prefix)
 {
   int v1, v2;
-  const uchar * p1, * p2, * store1, * store2;
-  int pass1 = 0, pass2 = 0;
+  const uchar * p1, * p2;
+  int pass1= 0, pass2= 0;
 
   if (s2_is_prefix && len1 > len2)
     len1=len2;
 
-  p1 = s1;	p2 = s2;
-  store1 = s1;	store2 = s2;
+  p1= s1;
+  p2= s2;
 
   do
   {
     int diff;
-    NEXT_CMP_VALUE(s1, p1, store1, pass1, v1, (int)len1);
-    NEXT_CMP_VALUE(s2, p2, store2, pass2, v2, (int)len2);
+    NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1, 1);
+    NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2, 1);
     if ((diff = v1 - v2))
       return diff;
   }
@@ -269,19 +371,66 @@ static int my_strnncoll_czech(CHARSET_IN
 
 
 /*
-  TODO: Fix this one to compare strings as they are done in ctype-simple1
+  Compare strings, ignore trailing spaces
 */
 
-static
-int my_strnncollsp_czech(CHARSET_INFO * cs, 
-                         const uchar *s, uint slen, 
-                         const uchar *t, uint tlen,
-                         my_bool diff_if_only_endspace_difference
-                         __attribute__((unused)))
+static int
+my_strnncollsp_czech(CHARSET_INFO * cs __attribute__((unused)),
+                     const uchar *s, uint slen, 
+                     const uchar *t, uint tlen,
+                     my_bool diff_if_only_endspace_difference
+                     __attribute__((unused)))
 {
-  for ( ; slen && s[slen-1] == ' ' ; slen--);
-  for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
-  return my_strnncoll_czech(cs,s,slen,t,tlen,0);
+  int level;
+
+  for (level= 0; level <= 3; level++)
+  {
+    const uchar *s1= s;
+    const uchar *t1= t;
+    
+    for (;;)
+    {
+      int sval, tval, diff;
+      NEXT_CMP_VALUE(s, s1, level, sval, (int) slen, 0);
+      NEXT_CMP_VALUE(t, t1, level, tval, (int) tlen, 0);
+      if (sval < 0)
+      {
+        sval= virtual_space[level];
+        for (; tval >= 0 ;)
+        {
+          if ((diff= sval - tval))
+            return diff;
+          NEXT_CMP_VALUE(t, t1, level, tval, (int) tlen, 0);
+        }
+        break;
+      }
+      else if (tval < 0)
+      {
+        tval= virtual_space[level];
+        for (; sval >= 0 ;)
+        {
+          if ((diff= sval - tval))
+            return diff;
+          NEXT_CMP_VALUE(s, s1, level, sval, (int) slen, 0);
+        }
+        break;
+      }
+
+      if ((diff= sval - tval))
+        return diff;
+    }
+  }
+  return 0;
+}
+
+
+/*
+  Returns the number of bytes required for strnxfrm().
+*/
+static uint
+my_strnxfrmlen_czech(CHARSET_INFO *cs __attribute__((unused)), uint len)
+{
+  return len * 4 + 4;
 }
 
 
@@ -289,50 +438,60 @@ int my_strnncollsp_czech(CHARSET_INFO * 
   Function strnxfrm, actually strxfrm, with Czech sorting, which expect
   the length of the strings being specified
 */
-
-static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), 
-			     uchar * dest, uint len,
-			     const uchar * src, uint srclen)
+static int
+my_strnxfrm_czech(CHARSET_INFO * cs  __attribute__((unused)),
+                  uchar *dst, uint dstlen, uint nweights_arg,
+                  const uchar *src, uint srclen, uint flags)
 {
-  int value;
-  const uchar * p, * store;
-  int pass = 0;
-  uint totlen = 0;
-  p = src;	store = src;
-
-  do
+  uint level;
+  uchar *dst0= dst;
+  uchar *de= dst + dstlen;
+  
+  if (!(flags & 0x0F)) /* All levels by default */
+    flags|= 0x0F;
+    
+  for (level= 0; level <= 3; level++)
   {
-    NEXT_CMP_VALUE(src, p, store, pass, value, (int)srclen);
-    ADD_TO_RESULT(dest, len, totlen, value);
+    if (flags & (1 << level))
+    {
+      uint nweights= nweights_arg;
+      const uchar *p= src;
+      int value;
+      uchar *dstl= dst;
+      
+      for (; dst < de && nweights; nweights--)
+      {
+        NEXT_CMP_VALUE(src, p, level, value, (int) srclen, 0);
+        if (value < 0)
+          break;
+        *dst++= value;
+      }
+      
+      if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+      {
+        uint pad_length= de - dst;
+        set_if_smaller(pad_length, nweights);
+        /* fill with weight for space character */
+        bfill(dst, pad_length, virtual_space[level]);
+        dst+= pad_length;
+      }
+      
+      my_strxfrm_desc_and_reverse(dstl, dst, flags, level);
+      
+      /* Add level delimiter */
+      if (dst < de)
+        *dst++= level < 3 ? 1 : 0;
+    }
   }
-  while (value);
-  if (len > totlen)
-    bfill(dest + totlen, len - totlen, ' ');
-  return len;
+
+  return dst - dst0;
 }
 
+
 #undef IS_END
 
 
 /*
-
-
-
  */
 
 
@@ -353,12 +512,9 @@ static int my_strnxfrm_czech(CHARSET_INF
 ** optimized !
 */
 
-#ifdef REAL_MYSQL
-
-#define min_sort_char ' '
-#define max_sort_char '9'
+#define min_sort_char 0x00
+#define max_sort_char 0xAE
 
-#define EXAMPLE
 
 static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
 				   const char *ptr,uint ptr_length,
@@ -367,7 +523,6 @@ static my_bool my_like_range_czech(CHARS
 				   char *max_str,
 				   uint *min_length,uint *max_length)
 {
-#ifdef EXAMPLE
   uchar value;
   const char *end=ptr+ptr_length;
   char *min_org=min_str;
@@ -411,15 +566,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 +575,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 +738,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 +775,10 @@ 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

--- 1.71/strings/ctype-euc_kr.c	2006-12-23 23:20:32 +04:00
+++ 1.72/strings/ctype-euc_kr.c	2007-04-03 16:16:08 +05:00
@@ -8674,7 +8674,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_simple, /* like_range */
   my_wildcmp_mb,	/* wildcmp    */
@@ -8684,6 +8684,7 @@ static MY_COLLATION_HANDLER my_collation
   my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_handler=
 {
   NULL,			/* init */
@@ -8744,6 +8745,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
 };
@@ -8777,6 +8780,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
 };

--- 1.68/strings/ctype-gb2312.c	2006-12-23 23:20:33 +04:00
+++ 1.69/strings/ctype-gb2312.c	2007-04-03 16:16:09 +05:00
@@ -5725,7 +5725,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_simple, /* like_range */
   my_wildcmp_mb,	/* wildcmp    */
@@ -5735,6 +5735,7 @@ static MY_COLLATION_HANDLER my_collation
   my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_handler=
 {
   NULL,			/* init */
@@ -5795,6 +5796,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
 };
@@ -5827,6 +5830,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
 };

--- 1.82/strings/ctype-gbk.c	2006-12-23 23:20:33 +04:00
+++ 1.83/strings/ctype-gbk.c	2007-04-03 16:16:09 +05:00
@@ -2662,29 +2662,35 @@ static int my_strnncollsp_gbk(CHARSET_IN
 }
 
 
-static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
-                    uchar * dest, uint len,
-                    const uchar * src, uint srclen)
+static int
+my_strnxfrm_gbk(CHARSET_INFO *cs,
+                uchar *dst, uint dstlen, uint nweights,
+                const uchar *src, uint srclen, uint flags)
 {
-  uint16 e;
-  uint dstlen= len;
-
-  len = srclen;
-  while (len--)
+  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 ((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);
-      *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);
 }
 
 
@@ -9988,6 +9994,7 @@ static MY_COLLATION_HANDLER my_collation
   my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_handler=
 {
   NULL,			/* init */
@@ -10048,6 +10055,8 @@ CHARSET_INFO my_charset_gbk_chinese_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
 };
@@ -10080,6 +10089,8 @@ CHARSET_INFO my_charset_gbk_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
 };

--- 1.93/strings/ctype-sjis.c	2007-01-24 21:57:04 +04:00
+++ 1.94/strings/ctype-sjis.c	2007-04-03 16:16:09 +05:00
@@ -280,30 +280,6 @@ static int my_strnncollsp_sjis(CHARSET_I
 }
 
 
-
-static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
-                     uchar *dest, uint len,
-                     const uchar *src, uint 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:
@@ -4625,7 +4601,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  */
@@ -4696,6 +4672,8 @@ CHARSET_INFO my_charset_sjis_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
 };
@@ -4728,6 +4706,8 @@ CHARSET_INFO my_charset_sjis_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
 };

--- 1.95/strings/ctype-tis620.c	2006-12-23 23:20:33 +04:00
+++ 1.96/strings/ctype-tis620.c	2007-04-03 16:16:09 +05:00
@@ -633,17 +633,18 @@ ret:
 */
 
 static
-int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
-                       uchar * dest, uint len,
-                       const uchar * src, uint srclen)
+int my_strnxfrm_tis620(CHARSET_INFO *cs,
+                       uchar *dst, uint dstlen, uint nweights,
+                       const uchar *src, uint srclen, uint flags)
 {
-  uint dstlen= len;
-  len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) -
-	       (char*) dest);
-  len= thai2sortable(dest, len);
-  if (dstlen > len)
-    bfill(dest + len, dstlen - len, ' ');
-  return dstlen;
+  uint len;
+  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); 
+  return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + len, dst + dstlen,
+                                         dstlen - len, flags, 0);
 }
 
 
@@ -925,6 +926,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 +960,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
 };

--- 1.74/strings/ctype-ujis.c	2007-01-24 21:57:04 +04:00
+++ 1.75/strings/ctype-ujis.c	2007-04-03 16:16:09 +05:00
@@ -8509,7 +8509,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_simple,/* like_range   */
     my_wildcmp_mb,	/* wildcmp      */
@@ -8519,6 +8519,7 @@ static MY_COLLATION_HANDLER my_collation
     my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_handler=
 {
     NULL,		/* init */
@@ -8580,6 +8581,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
 };
@@ -8613,6 +8616,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
 };

--- 1.11/mysql-test/r/ctype_big5.result	2005-12-12 21:36:21 +04:00
+++ 1.12/mysql-test/r/ctype_big5.result	2007-04-03 16:16:07 +05:00
@@ -192,3 +192,173 @@ drop table t1;
 select hex(convert(_big5 0xC84041 using ucs2));
 hex(convert(_big5 0xC84041 using ucs2))
 003F0041
+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 @@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
+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 @@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

--- 1.9/mysql-test/r/ctype_latin1.result	2006-06-06 22:13:21 +05:00
+++ 1.10/mysql-test/r/ctype_latin1.result	2007-04-03 16:16:07 +05:00
@@ -405,3 +405,213 @@ i
 1
 2
+End of 5.1 tests
+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 @@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 @@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 @@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 @@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;

--- 1.12/mysql-test/r/ctype_sjis.result	2006-06-19 16:48:38 +05:00
+++ 1.13/mysql-test/r/ctype_sjis.result	2007-04-03 16:16:07 +05:00
@@ -175,3 +175,173 @@ SET NAMES sjis;
 8DB2939181408C5C
+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 @@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
+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 @@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

--- 1.13/mysql-test/r/ctype_tis620.result	2006-02-22 13:09:48 +04:00
+++ 1.14/mysql-test/r/ctype_tis620.result	2007-04-03 16:16:07 +05:00
@@ -2993,3 +2993,120 @@ select c1 as c2h from t1 where c1 like '
 c2h
 ab_def
 drop table t1;
+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 @@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 @@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

--- 1.11/mysql-test/t/ctype_big5.test	2005-12-12 21:36:47 +04:00
+++ 1.12/mysql-test/t/ctype_big5.test	2007-04-03 16:16:07 +05:00
@@ -64,3 +64,14 @@ drop table t1;
 select hex(convert(_big5 0xC84041 using ucs2));
 
 # End of 4.1 tests
+
+
+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

--- 1.10/mysql-test/t/ctype_latin1.test	2006-06-06 22:13:21 +05:00
+++ 1.11/mysql-test/t/ctype_latin1.test	2007-04-03 16:16:07 +05:00
+
+--echo End of 5.1 tests
+
+set @@collation_connection=latin1_swedish_ci;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=latin1_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=latin1_general_cs;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=binary;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set names latin1;

--- 1.12/mysql-test/t/ctype_sjis.test	2006-06-19 16:48:38 +05:00
+++ 1.13/mysql-test/t/ctype_sjis.test	2007-04-03 16:16:08 +05:00
@@ -81,3 +81,15 @@ SET NAMES sjis;
 
 # End of 4.1 tests
+
+
+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

--- 1.13/mysql-test/t/ctype_tis620.test	2006-05-12 21:16:41 +05:00
+++ 1.14/mysql-test/t/ctype_tis620.test	2007-04-03 16:16:08 +05:00
@@ -161,3 +161,17 @@ SET collation_connection='tis620_bin';
 -- source include/ctype_like_escape.inc
 
 # End of 4.1 tests
+
+
+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)));

--- 1.43/strings/ctype-uca.c	2007-01-22 16:10:42 +04:00
+++ 1.44/strings/ctype-uca.c	2007-04-03 16:16:09 +05:00
@@ -7237,31 +7237,34 @@ static void my_hash_sort_uca(CHARSET_INF
 
 static int my_strnxfrm_uca(CHARSET_INFO *cs, 
                            my_uca_scanner_handler *scanner_handler,
-                           uchar *dst, uint dstlen,
-                           const uchar *src, uint srclen)
+                           uchar *dst, uint dstlen, uint nweights,
+                           const uchar *src, uint srclen, uint flags)
 {
-  uchar *de = dst + (dstlen & (uint) ~1); /* add even length for easier code */
+  uchar *d0= dst;
+  uchar *de= dst + (dstlen & (uint) ~1); /* add even length for easier code */
   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;
+    *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);
+  return dst - d0;
 }
 
 
@@ -7993,11 +7996,11 @@ static void my_hash_sort_any_uca(CHARSET
 }
 
 static int my_strnxfrm_any_uca(CHARSET_INFO *cs, 
-                               uchar *dst, uint dstlen,
-                               const uchar *src, uint srclen)
+                               uchar *dst, uint dstlen, uint nweights,
+                               const uchar *src, uint srclen, uint flags)
 {
   return my_strnxfrm_uca(cs, &my_any_uca_scanner_handler,
-                         dst, dstlen, src, srclen);
+                         dst, dstlen, nweights, src, srclen, flags);
 }
 
 
@@ -8032,11 +8035,11 @@ static void my_hash_sort_ucs2_uca(CHARSE
 }
 
 static int my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, 
-                                uchar *dst, uint dstlen,
-                                const uchar *src, uint srclen)
+                                uchar *dst, uint dstlen, uint nweights,
+                                const uchar *src, uint 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 =
@@ -8082,6 +8085,8 @@ CHARSET_INFO my_charset_ucs2_general_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
 };
@@ -8114,6 +8119,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
 };
@@ -8146,6 +8153,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
 };
@@ -8178,6 +8187,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
 };
@@ -8210,6 +8221,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
 };
@@ -8242,6 +8255,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
 };
@@ -8274,6 +8289,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
 };
@@ -8306,6 +8323,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
 };
@@ -8338,6 +8357,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
 };
@@ -8370,6 +8391,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
 };
@@ -8402,6 +8425,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
 };
@@ -8435,6 +8460,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
 };
@@ -8467,6 +8494,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
 };
@@ -8499,6 +8528,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
 };
@@ -8531,6 +8562,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
 };
@@ -8564,6 +8597,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
 };
@@ -8597,6 +8632,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
 };
@@ -8630,6 +8667,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
 };
@@ -8663,6 +8702,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
 };
@@ -8743,6 +8784,8 @@ CHARSET_INFO my_charset_utf8_general_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
 };
@@ -8776,6 +8819,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
 };
@@ -8808,6 +8853,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
 };
@@ -8840,6 +8887,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
 };
@@ -8872,6 +8921,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
 };
@@ -8904,6 +8955,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
 };
@@ -8936,6 +8989,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
 };
@@ -8968,6 +9023,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
 };
@@ -9000,6 +9057,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
 };
@@ -9032,6 +9091,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
 };
@@ -9064,6 +9125,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
 };
@@ -9097,6 +9160,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
 };
@@ -9129,6 +9194,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
 };
@@ -9161,6 +9228,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
 };
@@ -9193,6 +9262,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
 };
@@ -9225,6 +9296,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
 };
@@ -9257,6 +9330,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
 };
@@ -9289,6 +9364,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
 };
@@ -9321,6 +9398,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
 };

--- 1.54/mysql-test/r/ctype_ucs.result	2006-10-12 09:39:54 +05:00
+++ 1.55/mysql-test/r/ctype_ucs.result	2007-04-03 16:16:07 +05:00
@@ -848,3 +848,107 @@ text	65535	65535
 text	65535	32767
 drop table t1;
 End of 5.0 tests
+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 @@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 @@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

--- 1.113/mysql-test/r/ctype_utf8.result	2006-11-20 18:04:57 +04:00
+++ 1.114/mysql-test/r/ctype_utf8.result	2007-04-03 16:16:07 +05:00
@@ -1602,3 +1602,127 @@ colA	colB	colA	colB
 1	foo	1	foo
 2	foo bar	2	foo bar
 DROP TABLE t1, t2;
+End of 5.1 tests
+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 @@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 @@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
+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;

--- 1.50/mysql-test/t/ctype_ucs.test	2006-11-22 01:15:29 +04:00
+++ 1.51/mysql-test/t/ctype_ucs.test	2007-04-03 16:16:08 +05:00
@@ -581,3 +581,12 @@ select data_type, character_octet_length
 drop table t1;
 
 --echo End of 5.0 tests
+
+
+set collation_connection=ucs2_general_ci;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set collation_connection=ucs2_bin;
+-- source include/weight_string.inc
+--source include/weight_string_l1.inc

--- 1.103/mysql-test/t/ctype_utf8.test	2007-01-22 21:08:44 +04:00
+++ 1.104/mysql-test/t/ctype_utf8.test	2007-04-03 16:16:08 +05:00
@@ -1296,3 +1296,26 @@ INSERT INTO t2 (colA, colB) VALUES (1, '
 SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
 WHERE t1.colA < 3;
 DROP TABLE t1, t2;
+
+--echo End of 5.1 tests
+
+set names utf8;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf8_bin;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+#
+# Check strnxfrm() with odd length
+#
+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;

--- 1.75/strings/ctype-bin.c	2007-01-24 21:57:04 +04:00
+++ 1.76/strings/ctype-bin.c	2007-04-03 16:16:08 +05:00
@@ -374,28 +374,17 @@ int my_wildcmp_bin(CHARSET_INFO *cs,
 }
 
 
-static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)),
-                           uchar * dest, uint dstlen,
-                           const uchar *src, uint srclen)
-{
-  if (dest != src)
-    memcpy(dest, src, min(dstlen,srclen));
-  if (dstlen > srclen)
-    bfill(dest + srclen, dstlen - srclen, 0);
-  return dstlen;
-}
-
-
-static
-int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)),
-                         uchar * dest, uint dstlen,
-                         const uchar *src, uint srclen)
-{
-  if (dest != src)
-    memcpy(dest, src, min(dstlen,srclen));
-  if (dstlen > srclen)
-    bfill(dest + srclen, dstlen - srclen, ' ');
-  return dstlen;
+static int
+my_strnxfrm_8bit_bin(CHARSET_INFO *cs,
+                     uchar * dst, uint dstlen, uint nweights,
+                     const uchar *src, uint 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);
 }
 
 
@@ -481,7 +470,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,
@@ -552,6 +541,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
 };

--- 1.28/strings/ctype-extra.c	2007-01-18 19:41:46 +04:00
+++ 1.29/strings/ctype-extra.c	2007-04-03 16:16:08 +05:00
@@ -6616,6 +6616,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,
 }
@@ -6649,6 +6651,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,
 }
@@ -6682,6 +6686,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,
 }
@@ -6715,6 +6721,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,
 }
@@ -6748,6 +6756,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,
 }
@@ -6781,6 +6791,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,
 }
@@ -6814,6 +6826,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,
 }
@@ -6847,6 +6861,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,
 }
@@ -6880,6 +6896,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,
 }
@@ -6913,6 +6931,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,
 }
@@ -6946,6 +6966,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,
 }
@@ -6979,6 +7001,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,
 }
@@ -7012,6 +7036,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,
 }
@@ -7045,6 +7071,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,
 }
@@ -7078,6 +7106,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,
 }
@@ -7111,6 +7141,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,
 }
@@ -7144,6 +7176,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,
 }
@@ -7177,6 +7211,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,
 }
@@ -7210,6 +7246,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,
 }
@@ -7243,6 +7281,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,
 }
@@ -7276,6 +7316,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,
 }
@@ -7309,6 +7351,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,
 }
@@ -7342,6 +7386,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,
 }
@@ -7375,6 +7421,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,
 }
@@ -7408,6 +7456,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,
 }
@@ -7441,6 +7491,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,
 }
@@ -7474,6 +7526,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,
 }
@@ -7507,6 +7561,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,
 }
@@ -7540,6 +7596,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,
 }
@@ -7573,6 +7631,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,
 }
@@ -7606,6 +7666,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,
 }
@@ -7639,6 +7701,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,
 }
@@ -7672,6 +7736,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,
 }
@@ -7705,6 +7771,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,
 }
@@ -7738,6 +7806,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,
 }
@@ -7771,6 +7841,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,
 }
@@ -7804,6 +7876,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,
 }
@@ -7837,6 +7911,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,
 }
@@ -7870,6 +7946,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,
 }
@@ -7903,6 +7981,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,
 }
@@ -7936,6 +8016,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,
 }
@@ -7969,6 +8051,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,
 }
@@ -8002,6 +8086,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,
 }
@@ -8035,6 +8121,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,
 }
@@ -8068,6 +8156,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,
 }
@@ -8101,6 +8191,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,
 }
@@ -8134,6 +8226,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,
 }
@@ -8167,6 +8261,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,
 }
@@ -8200,6 +8296,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,
 }
@@ -8233,6 +8331,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,
 }
@@ -8266,6 +8366,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,
 }
@@ -8299,6 +8401,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,
 }
@@ -8332,6 +8436,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,
 }
@@ -8365,6 +8471,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,
 }
@@ -8398,6 +8506,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,
 }
@@ -8431,6 +8541,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,
 }
@@ -8464,6 +8576,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,
 }
@@ -8497,6 +8611,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,
 }
@@ -8530,72 +8646,8 @@ CHARSET_INFO compiled_charsets[] = {
   255,                        /* max_sort_char */
   ' ',                        /* pad_char      */
   0,                          /* escape_with_backslash_is_dangerous */
-  &my_charset_8bit_handler,
-  &my_collation_8bit_bin_handler,
-}
-,
-#endif
-#ifdef HAVE_CHARSET_geostd8
-{
-  92,0,0,
-  MY_CS_COMPILED|MY_CS_PRIMARY,
-  "geostd8",                     /* cset name     */
-  "geostd8_general_ci",                     /* coll name     */
-  "",                       /* comment       */
-  NULL,                       /* tailoring     */
-  ctype_geostd8_general_ci,                   /* ctype         */
-  to_lower_geostd8_general_ci,                /* lower         */
-  to_upper_geostd8_general_ci,                /* upper         */
-  sort_order_geostd8_general_ci,            /* sort_order    */
-  NULL,                       /* contractions  */
-  NULL,                       /* sort_order_big*/
-  to_uni_geostd8_general_ci,                  /* to_uni        */
-  NULL,                       /* from_uni      */
-  my_unicase_default,         /* caseinfo      */
-  NULL,                       /* state map     */
-  NULL,                       /* ident map     */
-  1,                          /* strxfrm_multiply*/
-  1,                          /* caseup_multiply*/
-  1,                          /* casedn_multiply*/
-  1,                          /* mbminlen      */
-  1,                          /* mbmaxlen      */
-  0,                          /* min_sort_char */
-  255,                        /* max_sort_char */
-  ' ',                        /* pad_char      */
-  0,                          /* escape_with_backslash_is_dangerous */
-  &my_charset_8bit_handler,
-  &my_collation_8bit_simple_ci_handler,
-}
-,
-#endif
-#ifdef HAVE_CHARSET_geostd8
-{
-  93,0,0,
-  MY_CS_COMPILED|MY_CS_BINSORT,
-  "geostd8",                     /* cset name     */
-  "geostd8_bin",                     /* coll name     */
-  "",                       /* comment       */
-  NULL,                       /* tailoring     */
-  ctype_geostd8_bin,                   /* ctype         */
-  to_lower_geostd8_bin,                /* lower         */
-  to_upper_geostd8_bin,                /* upper         */
-  NULL,                     /* sort_order    */
-  NULL,                       /* contractions  */
-  NULL,                       /* sort_order_big*/
-  to_uni_geostd8_bin,                  /* to_uni        */
-  NULL,                       /* from_uni      */
-  my_unicase_default,         /* caseinfo      */
-  NULL,                       /* state map     */
-  NULL,                       /* ident map     */
-  1,                          /* strxfrm_multiply*/
-  1,                          /* caseup_multiply*/
-  1,                          /* casedn_multiply*/
-  1,                          /* mbminlen      */
-  1,                          /* mbmaxlen      */
-  0,                          /* min_sort_char */
-  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,
 }
@@ -8629,6 +8681,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,
 }
@@ -8662,6 +8716,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,
 }
@@ -8694,6 +8750,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,
 }

--- 1.52/strings/ctype-latin1.c	2006-12-23 23:20:33 +04:00
+++ 1.53/strings/ctype-latin1.c	2007-04-03 16:16:09 +05:00
@@ -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 int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
-				 uchar * dest, uint len,
-				 const uchar * src, uint srclen)
+static int
+my_strnxfrm_latin1_de(CHARSET_INFO *cs,
+                      uchar *dst, uint dstlen, uint nweights,
+                      const uchar* src, uint 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);
 }
 
 
@@ -744,6 +749,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
 };
@@ -777,6 +784,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
 };

--- 1.68/strings/ctype-ucs2.c	2007-02-27 13:27:00 +04:00
+++ 1.69/strings/ctype-ucs2.c	2007-04-03 16:16:09 +05:00
@@ -362,17 +362,20 @@ static int my_strcasecmp_ucs2(CHARSET_IN
 }
 
 
-static int my_strnxfrm_ucs2(CHARSET_INFO *cs, 
-	uchar *dst, uint dstlen, const uchar *src, uint srclen)
+static int
+my_strnxfrm_ucs2(CHARSET_INFO *cs, 
+                 uchar *dst, uint dstlen, uint nweights,
+                 const uchar *src, uint srclen, uint flags)
 {
   my_wc_t wc;
   int res;
   int plane;
-  uchar *de = dst + dstlen;
-  const uchar *se = src + srclen;
+  uchar *de= dst + dstlen;
+  uchar *d0= dst;
+  const uchar *se= src + srclen;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
 
-  while( src < se && dst < de )
+  for (; src < se && dst < de && nweights; nweights--)
   {
     if ((res=my_ucs2_uni(cs,&wc, src, se))<0)
     {
@@ -390,9 +393,7 @@ static int my_strnxfrm_ucs2(CHARSET_INFO
     }
     dst+=res;
   }
-  if (dst < de)
-    cs->cset->fill(cs, (char*) dst, (uint) (de - dst), ' ');
-  return dstlen;
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
 
 
@@ -1467,15 +1468,17 @@ int my_strcasecmp_ucs2_bin(CHARSET_INFO 
 
 
 static
-int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)),
-			 uchar *dst, uint dstlen,
-			 const uchar *src, uint srclen)
-{
+int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs,
+			 uchar *dst, uint dstlen, uint nweights,
+			 const uchar *src, uint srclen, uint flags)
+{
+  uint frmlen;
+  if ((frmlen= min(dstlen, nweights * 2)) > srclen)
+    frmlen= srclen;
   if (dst != src)
-    memcpy(dst,src,srclen= min(dstlen,srclen));
-  if (dstlen > srclen)
-    cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' ');
-  return dstlen;
+    memcpy(dst, src, frmlen);
+  return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + frmlen, dst + dstlen,
+                                         nweights - frmlen / 2, flags, 0);
 }
 
 
@@ -1699,6 +1702,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
 };
@@ -1731,6 +1736,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
 };

--- 1.56/strings/ctype-mb.c	2007-01-24 21:57:04 +04:00
+++ 1.57/strings/ctype-mb.c	2007-04-03 16:16:09 +05:00
@@ -359,10 +359,10 @@ uint my_instr_mb(CHARSET_INFO *cs,
 
 /* BINARY collations handlers for MB charsets */
 
-static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
-				const uchar *s, uint slen,
-				const uchar *t, uint tlen,
-                                my_bool t_is_prefix)
+int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
+                        const uchar *s, uint slen,
+                        const uchar *t, uint tlen,
+                        my_bool t_is_prefix)
 {
   uint len=min(slen,tlen);
   int cmp= memcmp(s,t,len);
@@ -395,10 +395,10 @@ static int my_strnncoll_mb_bin(CHARSET_I
     0 if strings are equal
 */
 
-static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
-                                 const uchar *a, uint a_length, 
-                                 const uchar *b, uint b_length,
-                                 my_bool diff_if_only_endspace_difference)
+int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
+                          const uchar *a, uint a_length, 
+                          const uchar *b, uint b_length,
+                          my_bool diff_if_only_endspace_difference)
 {
   const uchar *end;
   uint length;
@@ -442,26 +442,119 @@ static int my_strnncollsp_mb_bin(CHARSET
 }
 
 
-static int my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
-                              uchar * dest, uint dstlen,
-                              const uchar *src, uint 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 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.
+*/
+int
+my_strnxfrm_mb(CHARSET_INFO *cs,
+               uchar *dst, uint dstlen, uint nweights,
+               const uchar *src, uint 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 <= 3);
+  
+  /*
+    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; nweights--)
+  {
+    int chlen;
+    if (*src < 128 ||
+        !(chlen= cs->cset->ismbchar(cs, (const char*) src, (const char*) se)))
+    {
+      /* Single byte character */
+      if (dst >= de)
+        break;
+      *dst++= sort_order ? sort_order[*src++] : *src++;
+    }
+    else
+    {
+      /* Multi-byte character */
+      if (dst + chlen > de)
+        break;
+      *dst++= *src++;
+      *dst++= *src++;
+      if (chlen == 3)
+        *dst++= *src++;
+    }
+  }
+  
+pad:  
+  return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
 }
 
 
-static int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
-		      const char *s, const char *t)
+int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
+                         const char *s, const char *t)
 {
   return strcmp(s,t);
 }
 
-static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
-		      const uchar *key, uint len,ulong *nr1, ulong *nr2)
+
+void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
+                         const uchar *key, uint len,ulong *nr1, ulong *nr2)
 {
   const uchar *pos = key;
   
@@ -606,10 +699,10 @@ my_bool my_like_range_mb(CHARSET_INFO *c
 }
 
 
-static int my_wildcmp_mb_bin(CHARSET_INFO *cs,
-		  const char *str,const char *str_end,
-		  const char *wildstr,const char *wildend,
-		  int escape, int w_one, int w_many)
+int my_wildcmp_mb_bin(CHARSET_INFO *cs,
+                      const char *str,const char *str_end,
+                      const char *wildstr,const char *wildend,
+                      int escape, int w_one, int w_many)
 {
   int result= -1;				/* Not found, using wildcards */
 
@@ -961,10 +1054,10 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int
 
 MY_COLLATION_HANDLER my_collation_mb_bin_handler =
 {
-    NULL,		/* init */
+    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,
@@ -973,6 +1066,5 @@ MY_COLLATION_HANDLER my_collation_mb_bin
     my_hash_sort_mb_bin,
     my_propagate_simple
 };
-
 
 #endif

--- 1.85/strings/ctype-simple.c	2007-01-24 21:57:04 +04:00
+++ 1.86/strings/ctype-simple.c	2007-04-03 16:16:09 +05:00
@@ -71,29 +71,31 @@ uint my_strnxfrmlen_simple(CHARSET_INFO 
 
 
 int my_strnxfrm_simple(CHARSET_INFO * cs, 
-                       uchar *dest, uint len,
-                       const uchar *src, uint srclen)
+                       uchar *dst, uint dstlen, uint nweights,
+                       const uchar *src, uint srclen, uint flags)
 {
   uchar *map= cs->sort_order;
-  uint 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);
 }
 
+
 int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, 
                         const uchar *t, uint tlen,
                         my_bool t_is_prefix)
@@ -1759,6 +1761,140 @@ my_bool my_propagate_complex(CHARSET_INF
                              uint length __attribute__((unused)))
 {
   return 0;
+}
+
+
+
+/*
+  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;
+    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;
+
+    /*
+      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;
+      uint dst_bit= 1 << min(i, maximum);
+      if (flag_lev & src_bit)
+      {
+        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;
+    }
+  }
+}
+
+
+uint 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);
+  return frmend - str;
 }
 
 

--- 1.112/strings/ctype-utf8.c	2007-02-27 13:27:00 +04:00
+++ 1.113/strings/ctype-utf8.c	2007-04-03 16:16:09 +05:00
@@ -1780,7 +1780,7 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
     {						/* Found w_many */
     
       /* Remove any '%' and '_' from the wild search string */
-      for ( ; wildstr != wildend ; )
+      for (; wildstr != wildend ;)
       {
         if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
                          (const uchar*)wildend)) <= 0)
@@ -2570,18 +2570,19 @@ uint my_strnxfrmlen_utf8(CHARSET_INFO *c
 }
 
 static int my_strnxfrm_utf8(CHARSET_INFO *cs,
-                            uchar *dst, uint dstlen,
-                            const uchar *src, uint srclen)
+                            uchar *dst, uint dstlen, uint nweights,
+                            const uchar *src, uint srclen, uint flags)
 {
   my_wc_t wc;
   int res;
   int plane;
+  uchar *dst0= dst;
   uchar *de= dst + dstlen;
   uchar *de_beg= de - 1;
   const uchar *se = src + srclen;
   MY_UNICASE_INFO **uni_plane= cs->caseinfo;
 
-  while (dst < de_beg)
+  for (; dst < de_beg && nweights; nweights--)
   {
     if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0)
       break;
@@ -2595,18 +2596,61 @@ static int my_strnxfrm_utf8(CHARSET_INFO
     
   }
   
-  while (dst < de_beg) /* Fill the tail with keys for space character */
+  if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
   {
-    *dst++= 0x00;
-    *dst++= 0x20;
+    /* Fill the tail with keys for space character */
+    for (; dst < de_beg && nweights; nweights--)
+    {
+      *dst++= 0x00;
+      *dst++= 0x20;
+    }
+    
+    if (dst < de)  /* Clear the last byte, if "dstlen" was an odd number */
+      *dst++= 0x00;
+  }
+  my_strxfrm_desc_and_reverse(dst0, dst, flags, 0);
+  return dst - dst0;
+}
+
+
+static int my_strnxfrm_utf8_bin(CHARSET_INFO *cs,
+                                uchar *dst, uint dstlen, uint nweights,
+                                const uchar *src, uint 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;
+
+  for (; dst < de_beg && nweights; nweights--)
+  {
+    if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0)
+      break;
+    src+=res;
+
+    *dst++= (uchar)(wc >> 8);
+    *dst++= (uchar)(wc & 0xFF);
   }
   
-  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))
+  {
+    /* Fill the tail with keys for space character */
+    for (; dst < de_beg && nweights; nweights--)
+    {
+      *dst++= 0x00;
+      *dst++= 0x20;
+    }
+    
+    if (dst < de)  /* Clear the last byte, if "dstlen" was an odd number */
+      *dst++= 0x00;
+  }
+  my_strxfrm_desc_and_reverse(dst0, dst, flags, 0);
+  return dst - dst0;
 }
 
+
 static int my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e)
 {
   my_wc_t wc;
@@ -2651,6 +2695,23 @@ 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_utf8_bin,
+    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 */
@@ -2712,6 +2773,8 @@ 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
 };
@@ -2745,8 +2808,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
@@ -2916,6 +2981,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
 };
@@ -4212,6 +4279,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
 };

--- 1.58/strings/ctype-win1250ch.c	2006-12-23 23:20:33 +04:00
+++ 1.59/strings/ctype-win1250ch.c	2007-04-03 16:16:09 +05:00
@@ -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
 
 
@@ -399,23 +389,32 @@ static uchar NEAR _sort_order_win1250ch2
 0x02, 0x06, 0x04, 0x0a, 0x08, 0x04, 0x06, 0x01
 };
 
-struct wordvalue {
-	const uchar * word;
-	uchar pass1;
-	uchar pass2;
-};
-static struct wordvalue doubles[] = {
-	{ (uchar*) "ch", 0xad, 0x03 },
-	{ (uchar*) "c",  0xa6, 0x02 },
-	{ (uchar*) "Ch", 0xad, 0x02 },
-	{ (uchar*) "CH", 0xad, 0x01 },
-	{ (uchar*) "C",  0xa6, 0x01 },
+struct wordvalue
+{
+  const uchar * word;
+  uchar pass1;
+  uchar pass2;
 };
 
-#define NEXT_CMP_VALUE(src, p, pass, value, len)			\
+static struct wordvalue doubles[]=
+{
+  { (uchar*) "ch", 0xad, 0x03 },
+  { (uchar*) "c",  0xa6, 0x02 },
+  { (uchar*) "Ch", 0xad, 0x02 },
+  { (uchar*) "CH", 0xad, 0x01 },
+  { (uchar*) "C",  0xa6, 0x01 },
+};
+
+/*
+  ml - a flag indicating whether automatically
+       switch to the secondary level,
+       or stop on the primary level
+*/
+
+#define NEXT_CMP_VALUE(src, p, pass, value, len, ml)			\
 	while (1) {							\
 		if (IS_END(p, src, len)) {				\
-			if (pass == 0 && len > 0) { p= src; pass++; }	\
+			if (pass == 0 && ml && len > 0) { p= src; pass++; } \
 			else { value = 0; break; }			\
 		}							\
 		value = ((pass == 0) ? _sort_order_win1250ch1[*p]	\
@@ -462,8 +461,8 @@ static int my_strnncoll_win1250ch(CHARSE
 
   do
   {
-    NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1);
-    NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2);
+    NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1, 1);
+    NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2, 1);
     if ((diff = v1 - v2))
       return diff;
   } while (v1);
@@ -472,46 +471,104 @@ static int my_strnncoll_win1250ch(CHARSE
 
 
 /*
-  TODO: Has to be fixed as strnncollsp in ctype-simple
+  Compare strings, ignore trailing spaces
 */
 
-static
-int my_strnncollsp_win1250ch(CHARSET_INFO * cs, 
-			     const uchar *s, uint slen, 
-			     const uchar *t, uint tlen,
-                             my_bool diff_if_only_endspace_difference
-                             __attribute__((unused)))
+static int
+my_strnncollsp_win1250ch(CHARSET_INFO * cs __attribute__((unused)),
+                         const uchar *s, uint slen, 
+                         const uchar *t, uint tlen,
+                         my_bool diff_if_only_endspace_difference
+                         __attribute__((unused)))
 {
-  for ( ; slen && s[slen-1] == ' ' ; slen--);
-  for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
-  return my_strnncoll_win1250ch(cs,s,slen,t,tlen,0);
+  int level;
+
+  for (level= 0; level <= 3; level++)
+  {
+    const uchar *s1= s;
+    const uchar *t1= t;
+    
+    for (;;)
+    {
+      int sval, tval, diff;
+      NEXT_CMP_VALUE(s, s1, level, sval, (int) slen, 0);
+      NEXT_CMP_VALUE(t, t1, level, tval, (int) tlen, 0);
+      if (!sval)
+      {
+        sval= level ? _sort_order_win1250ch2[32] : _sort_order_win1250ch1[32];
+        for (; tval;)
+        {
+          if ((diff= sval - tval))
+            return diff;
+          NEXT_CMP_VALUE(t, t1, level, tval, (int) tlen, 0);
+        }
+        break;
+      }
+      else if (!tval)
+      {
+        tval= level ? _sort_order_win1250ch2[32] : _sort_order_win1250ch1[32];
+        for (; sval;)
+        {
+          if ((diff= sval - tval))
+            return diff;
+          NEXT_CMP_VALUE(s, s1, level, sval, (int) slen, 0);
+        }
+        break;
+      }
+
+      if ((diff= sval - tval))
+        return diff;
+    }
+  }
+  return 0;
 }
 
 
-static int my_strnxfrm_win1250ch(CHARSET_INFO * cs  __attribute__((unused)),
-				 uchar * dest, uint len, 
-				 const uchar * src, uint srclen)
+static int
+my_strnxfrm_win1250ch(CHARSET_INFO * cs  __attribute__((unused)),
+                      uchar *dst, uint dstlen, uint nweights_arg,
+                      const uchar *src, uint srclen, uint flags)
 {
-  int value;
-  const uchar * p;
-  int pass = 0;
-  uint totlen = 0;
-  p = src;
-
-  do {
-    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;
+  uint level;
+  uchar *dst0= dst;
+  uchar *de= dst + dstlen;
+
+  if (!(flags & 0x03)) /* All levels by default */
+    flags|= 0x03;
+  
+  for (level= 0; level <= 1; level++)
+  {
+    if (flags & (1 << level))
+    {
+      uint nweights= nweights_arg;
+      const uchar *p= src;
+      int value;
+      uchar *dstl= dst;
+      
+      for (; dst < de && nweights; nweights--)
+      {
+        NEXT_CMP_VALUE(src, p, level, value, (int) srclen, 0);
+        if (!value)
+          break;
+        *dst++= value;
+      }
+      
+      if (dst < de && nweights && (flags & MY_STRXFRM_PAD_WITH_SPACE))
+      {
+        uint pad_length= de - dst;
+        set_if_smaller(pad_length, nweights);
+        /* [82.01] - weights for space character */
+        bfill(dst, pad_length, (int) (level ? 0x01 : 0x82));
+        dst+= pad_length;
+      }
+      my_strxfrm_desc_and_reverse(dstl, dst, flags, level);
+    }
+  }
+  return dst - dst0;
 }
 
 #undef IS_END
 
-#ifdef REAL_MYSQL
 
 static uchar NEAR like_range_prefix_min_win1250ch[]=
 {
@@ -705,11 +762,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 */
--- New file ---
+++ mysql-test/include/ctype_pad_space.inc	07/04/03 16:16:09
SELECT strcmp('a','a ');
SELECT strcmp('a\0','a' );
SELECT strcmp('a\0','a ');
SELECT strcmp('a\t','a' );
SELECT strcmp('a\t','a ');

--- New file ---
+++ mysql-test/include/weight_string.inc	07/04/03 16:16:10
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)));

--- New file ---
+++ mysql-test/include/weight_string_8140.inc	07/04/03 16:16:10
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)));

--- New file ---
+++ mysql-test/include/weight_string_8EA1.inc	07/04/03 16:16:10
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)));

--- New file ---
+++ mysql-test/include/weight_string_8FA2C3.inc	07/04/03 16:16:10
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)));

--- New file ---
+++ mysql-test/include/weight_string_A1A1.inc	07/04/03 16:16:10
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)));

--- New file ---
+++ mysql-test/include/weight_string_chde.inc	07/04/03 16:16:11
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 'shart 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)));

--- New file ---
+++ mysql-test/include/weight_string_l1.inc	07/04/03 16:16:11
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));

--- New file ---
+++ mysql-test/include/weight_string_l12.inc	07/04/03 16:16:11
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));

--- New file ---
+++ mysql-test/include/weight_string_l14.inc	07/04/03 16:16:11
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));

--- New file ---
+++ mysql-test/include/weight_string_l2.inc	07/04/03 16:16:12
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));

--- New file ---
+++ mysql-test/include/weight_string_l3.inc	07/04/03 16:16:12
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));

--- New file ---
+++ mysql-test/include/weight_string_l4.inc	07/04/03 16:16:12
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));


--- 1.9/mysql-test/r/ctype_cp1250_ch.result	2006-11-27 03:47:21 +04:00
+++ 1.10/mysql-test/r/ctype_cp1250_ch.result	2007-04-03 16:16:07 +05:00
 a
 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	6109
+cp1250_czech_cs	61
+cp1250_czech_cs	6120
+drop table t1;
+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)))
+A4A50202
+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)))
+A4A5A682820202020101
+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)))
+AD03
+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)))
+ADBB82030101
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+ADBB828203010101
+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)))
+BB01
+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)))
+BBAD82010301
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+BBAD828201030101
+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))
+A4A5
+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))
+A4A5A68282
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+8282A6A5A4
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+5B5A597D7D
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+7D7D595A5B
+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))
+0202
+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))
+0202020101
+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

--- 1.2/mysql-test/r/ctype_euckr.result	2006-05-12 21:26:40 +05:00
+++ 1.3/mysql-test/r/ctype_euckr.result	2007-04-03 16:16:07 +05:00
@@ -165,3 +165,173 @@ hex(a)
 A2E6
 FEF7
 DROP TABLE t1;
+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 @@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
+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 @@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

--- 1.2/mysql-test/r/ctype_gb2312.result	2006-05-12 21:26:40 +05:00
+++ 1.3/mysql-test/r/ctype_gb2312.result	2007-04-03 16:16:07 +05:00
@@ -165,3 +165,173 @@ hex(a)
 A2A1
 D7FE
 DROP TABLE t1;
+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 @@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
+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 @@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

--- 1.4/mysql-test/r/ctype_gbk.result	2006-09-29 16:24:06 +05:00
+++ 1.5/mysql-test/r/ctype_gbk.result	2007-04-03 16:16:07 +05:00
@@ -178,3 +178,305 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=gbk
 drop table t1;
 End of 5.0 tests
+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 @@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 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 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
+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 @@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 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 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

--- 1.2/mysql-test/r/ctype_latin2.result	2005-05-06 18:41:38 +05:00
+++ 1.3/mysql-test/r/ctype_latin2.result	2007-04-03 16:16:07 +05:00
@@ -381,3 +381,108 @@ _
 drop table t1;
+End of 5.1 tests
+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 @@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 @@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

--- 1.2/mysql-test/r/ctype_latin2_ch.result	2006-04-18 21:10:42 +05:00
+++ 1.3/mysql-test/r/ctype_latin2_ch.result	2007-04-03 16:16:07 +05:00
@@ -29,3 +29,316 @@ 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 ')
+-1
+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)
+latin2_czech_cs	6109
+latin2_czech_cs	61
+latin2_czech_cs	6120
+drop table t1;
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a'));
+hex(weight_string('a'))
+8201200103016100
+select hex(weight_string('A'));
+hex(weight_string('A'))
+8201200105014100
+select hex(weight_string('abc'));
+hex(weight_string('abc'))
+82838401202020010303030161626300
+select hex(weight_string('abc' as char(2)));
+hex(weight_string('abc' as char(2)))
+828301202001030301616200
+select hex(weight_string('abc' as char(3)));
+hex(weight_string('abc' as char(3)))
+82838401202020010303030161626300
+select hex(weight_string('abc' as char(5)));
+hex(weight_string('abc' as char(5)))
+828384474701202020202001030303020201616263202000
+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'))
+9801200103017300
+select hex(weight_string(cast(_latin1 0xDF as char)));
+hex(weight_string(cast(_latin1 0xDF as char)))
+980121010301DF00
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF as char) as char(1)))
+980121010301DF00
+select hex(weight_string('c'));
+hex(weight_string('c'))
+8401200103016300
+select hex(weight_string('h'));
+hex(weight_string('h'))
+8A01200103016800
+select hex(weight_string('ch'));
+hex(weight_string('ch'))
+8B01200103016300
+select hex(weight_string('i'));
+hex(weight_string('i'))
+8C01200103016900
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+hex(weight_string(cast(_latin1 0x6368DF as char)))
+8B980120210103030163DF00
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)))
+8B01200103016300
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)))
+8B980120210103030163DF00
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)))
+8B984701202120010303020163DF2000
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)))
+8B984747012021202001030302020163DF202000
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+hex(weight_string(cast(_latin1 0xDF6368 as char)))
+988B01212001030301DF6300
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)))
+980121010301DF00
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)))
+988B01212001030301DF6300
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)))
+988B47012120200103030201DF632000
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)))
+988B47470121202020010303020201DF63202000
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1));
+hex(weight_string('a' LEVEL 1))
+8201
+select hex(weight_string('A' LEVEL 1));
+hex(weight_string('A' LEVEL 1))
+8201
+select hex(weight_string('abc' LEVEL 1));
+hex(weight_string('abc' LEVEL 1))
+82838401
+select hex(weight_string('abc' as char(2) LEVEL 1));
+hex(weight_string('abc' as char(2) LEVEL 1))
+828301
+select hex(weight_string('abc' as char(3) LEVEL 1));
+hex(weight_string('abc' as char(3) LEVEL 1))
+82838401
+select hex(weight_string('abc' as char(5) LEVEL 1));
+hex(weight_string('abc' as char(5) LEVEL 1))
+828384474701
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 REVERSE))
+474784838201
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC))
+7D7C7BB8B801
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE))
+B8B87B7C7D01
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 2));
+hex(weight_string('a' LEVEL 2))
+2001
+select hex(weight_string('A' LEVEL 2));
+hex(weight_string('A' LEVEL 2))
+2001
+select hex(weight_string('abc' LEVEL 2));
+hex(weight_string('abc' LEVEL 2))
+20202001
+select hex(weight_string('abc' as char(2) LEVEL 2));
+hex(weight_string('abc' as char(2) LEVEL 2))
+202001
+select hex(weight_string('abc' as char(3) LEVEL 2));
+hex(weight_string('abc' as char(3) LEVEL 2))
+20202001
+select hex(weight_string('abc' as char(5) LEVEL 2));
+hex(weight_string('abc' as char(5) LEVEL 2))
+202020202001
+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))
+0501
+select hex(weight_string('abc' LEVEL 3));
+hex(weight_string('abc' LEVEL 3))
+03030301
+select hex(weight_string('abc' as char(2) LEVEL 3));
+hex(weight_string('abc' as char(2) LEVEL 3))
+030301
+select hex(weight_string('abc' as char(3) LEVEL 3));
+hex(weight_string('abc' as char(3) LEVEL 3))
+03030301
+select hex(weight_string('Abc' as char(5) LEVEL 3));
+hex(weight_string('Abc' as char(5) LEVEL 3))
+050303020201
+select hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE));
+hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE))
+020203030501
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC));
+hex(weight_string('Abc' as char(5) LEVEL 3 DESC))
+FAFCFCFDFD01
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE));
+hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE))
+FDFDFCFCFA01
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 4));
+hex(weight_string('a' LEVEL 4))
+6100
+select hex(weight_string('A' LEVEL 4));
+hex(weight_string('A' LEVEL 4))
+4100
+select hex(weight_string('abc' LEVEL 4));
+hex(weight_string('abc' LEVEL 4))
+61626300
+select hex(weight_string('abc' as char(2) LEVEL 4));
+hex(weight_string('abc' as char(2) LEVEL 4))
+616200
+select hex(weight_string('abc' as char(3) LEVEL 4));
+hex(weight_string('abc' as char(3) LEVEL 4))
+61626300
+select hex(weight_string('abc' as char(5) LEVEL 4));
+hex(weight_string('abc' as char(5) LEVEL 4))
+616263202000
+select hex(weight_string('abc' as char(5) LEVEL 4 REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 4 REVERSE))
+202063626100
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC));
+hex(weight_string('abc' as char(5) LEVEL 4 DESC))
+9E9D9CDFDF00
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE));
+hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE))
+DFDF9C9D9E00
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1,2));
+hex(weight_string('a' LEVEL 1,2))
+82012001
+select hex(weight_string('a' LEVEL 1-2));
+hex(weight_string('a' LEVEL 1-2))
+82012001
+select hex(weight_string('A' LEVEL 1,2));
+hex(weight_string('A' LEVEL 1,2))
+82012001
+select hex(weight_string('A' LEVEL 1-2));
+hex(weight_string('A' LEVEL 1-2))
+82012001
+select @@collation_connection;
+@@collation_connection
+latin2_czech_cs
+select hex(weight_string('a' LEVEL 1,3));
+hex(weight_string('a' LEVEL 1,3))
+82010301
+select hex(weight_string('a' LEVEL 1-3));
+hex(weight_string('a' LEVEL 1-3))
+820120010301
+select hex(weight_string('A' LEVEL 1,3));
+hex(weight_string('A' LEVEL 1,3))
+82010501
+select hex(weight_string('A' LEVEL 1-3));
+hex(weight_string('A' LEVEL 1-3))
+820120010501
+select hex(weight_string('a' LEVEL 1,4));
+hex(weight_string('a' LEVEL 1,4))
+82016100
+select hex(weight_string('a' LEVEL 1-4));
+hex(weight_string('a' LEVEL 1-4))
+8201200103016100
+select hex(weight_string('A' LEVEL 1,4));
+hex(weight_string('A' LEVEL 1,4))
+82014100
+select hex(weight_string('A' LEVEL 1-4));
+hex(weight_string('A' LEVEL 1-4))
+8201200105014100
+select hex(weight_string('a' LEVEL 2,3));
+hex(weight_string('a' LEVEL 2,3))
+20010301
+select hex(weight_string('a' LEVEL 2-3));
+hex(weight_string('a' LEVEL 2-3))
+20010301
+select hex(weight_string('A' LEVEL 2,3));
+hex(weight_string('A' LEVEL 2,3))
+20010501
+select hex(weight_string('A' LEVEL 2-3));
+hex(weight_string('A' LEVEL 2-3))
+20010501
+select hex(weight_string('a' LEVEL 2,4));
+hex(weight_string('a' LEVEL 2,4))
+20016100
+select hex(weight_string('a' LEVEL 2-4));
+hex(weight_string('a' LEVEL 2-4))
+200103016100
+select hex(weight_string('A' LEVEL 2,4));
+hex(weight_string('A' LEVEL 2,4))
+20014100
+select hex(weight_string('A' LEVEL 2-4));
+hex(weight_string('A' LEVEL 2-4))
+200105014100
+select hex(weight_string('a' LEVEL 3,4));
+hex(weight_string('a' LEVEL 3,4))
+03016100
+select hex(weight_string('a' LEVEL 3-4));
+hex(weight_string('a' LEVEL 3-4))
+03016100
+select hex(weight_string('A' LEVEL 3,4));
+hex(weight_string('A' LEVEL 3,4))
+05014100
+select hex(weight_string('A' LEVEL 3-4));
+hex(weight_string('A' LEVEL 3-4))
+05014100
+select hex(weight_string('a' LEVEL 1,2,3,4));
+hex(weight_string('a' LEVEL 1,2,3,4))
+8201200103016100
+select hex(weight_string('a' LEVEL 2,3,4));
+hex(weight_string('a' LEVEL 2,3,4))
+200103016100
+select hex(weight_string('a' LEVEL 1,3,4));
+hex(weight_string('a' LEVEL 1,3,4))
+820103016100
+select hex(weight_string('a' LEVEL 1,2,3));
+hex(weight_string('a' LEVEL 1,2,3))
+820120010301
+select hex(weight_string('a' LEVEL 0));
+hex(weight_string('a' LEVEL 0))
+8201
+select hex(weight_string('a' LEVEL 8));
+hex(weight_string('a' LEVEL 8))
+6100
+select hex(weight_string('a' LEVEL 1,8));
+hex(weight_string('a' LEVEL 1,8))
+82016100

--- 1.17/mysql-test/r/ctype_uca.result	2005-12-23 14:19:31 +04:00
+++ 1.18/mysql-test/r/ctype_uca.result	2007-04-03 16:16:07 +05:00
@@ -2654,3 +2654,224 @@ ii	2	ii	2	İİ	4
 İİ	4	ii	2	İİ	4
 II	2	ıı	4	II	2
 DROP TABLE t1;
+End of 5.1 tests
+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 @@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 @@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
+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
--- New file ---
+++ mysql-test/r/func_weight_string.result	07/04/03 16:16:12
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


--- 1.8/mysql-test/t/ctype_cp1250_ch.test	2006-11-22 01:15:29 +04:00
+++ 1.9/mysql-test/t/ctype_cp1250_ch.test	2007-04-03 16:16:07 +05:00
 drop table t1;
 
 # End of 4.1 tests
+
+
+set names cp1250 collate cp1250_czech_cs;
+--source include/ctype_pad_space.inc
+--source include/ctype_filesort.inc
+--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_l12.inc

--- 1.1/mysql-test/t/ctype_euckr.test	2005-12-09 16:33:43 +04:00
+++ 1.2/mysql-test/t/ctype_euckr.test	2007-04-03 16:16:07 +05:00
@@ -31,3 +31,14 @@ SELECT hex(a) FROM t1 ORDER BY a;
 DROP TABLE t1;
 
 # End of 4.1 tests
+
+
+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

--- 1.1/mysql-test/t/ctype_gb2312.test	2005-12-09 16:33:43 +04:00
+++ 1.2/mysql-test/t/ctype_gb2312.test	2007-04-03 16:16:07 +05:00
@@ -31,3 +31,14 @@ SELECT hex(a) FROM t1 ORDER BY a;
 DROP TABLE t1;
 
 # End of 4.1 tests
+
+
+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

--- 1.5/mysql-test/t/ctype_gbk.test	2006-09-29 16:24:06 +05:00
+++ 1.6/mysql-test/t/ctype_gbk.test	2007-04-03 16:16:07 +05:00
@@ -52,3 +52,18 @@ show create table t1;
 drop table t1;
 
 --echo End of 5.0 tests
+
+
+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

--- 1.3/mysql-test/t/ctype_latin2.test	2005-07-28 05:21:40 +05:00
+++ 1.4/mysql-test/t/ctype_latin2.test	2007-04-03 16:16:08 +05:00
@@ -50,3 +50,13 @@ SELECT group_concat(a collate latin2_cro
 drop table t1;
 
 # End of 4.1 tests
+
+--echo End of 5.1 tests
+
+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

--- 1.2/mysql-test/t/ctype_latin2_ch.test	2006-04-18 21:10:42 +05:00
+++ 1.3/mysql-test/t/ctype_latin2_ch.test	2007-04-03 16:16:08 +05:00
@@ -27,6 +27,19 @@ 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
 
-drop table t1;
+
+set names latin2 collate latin2_czech_cs;
+--source include/ctype_pad_space.inc
+--source include/ctype_filesort.inc
+--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

--- 1.15/mysql-test/t/ctype_uca.test	2005-12-23 14:19:25 +04:00
+++ 1.16/mysql-test/t/ctype_uca.test	2007-04-03 16:16:08 +05:00
@@ -475,3 +475,19 @@ ALTER TABLE t1 MODIFY a VARCHAR(30) char
 SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu
 FROM t1 ORDER BY id;
 DROP TABLE t1;
+
+--echo End of 5.1 tests
+
+set collation_connection=ucs2_unicode_ci;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+
+set @@collation_connection=utf8_unicode_ci;
+--source include/weight_string.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
--- New file ---
+++ mysql-test/t/func_weight_string.test	07/04/03 16:16:12
--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));


--- 1.7/mysql-test/r/binlog_row_ctype_cp932.result	2007-03-07 10:20:56 +04:00
+++ 1.8/mysql-test/r/binlog_row_ctype_cp932.result	2007-04-03 16:16:07 +05:00
@@ -11375,3 +11375,114 @@ c_cp932
 ソ
+End of 5.1 tests
+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 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
+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 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

--- 1.4/mysql-test/r/ctype_cp932_binlog_stm.result	2007-03-01 18:16:13 +04:00
+++ 1.5/mysql-test/r/ctype_cp932_binlog_stm.result	2007-04-03 16:16:07 +05:00
@@ -44,3 +44,173 @@ END
 master-bin.000001	820	Query	1	1039	use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172),  NAME_CONST('ins2',_cp932 0xED40ED41ED42),  NAME_CONST('ind',47.93))
 master-bin.000001	1039	Query	1	1128	use `test`; DROP PROCEDURE bug18293
 master-bin.000001	1128	Query	1	1207	use `test`; DROP TABLE t4
+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 @@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
+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 @@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

--- 1.4/mysql-test/t/ctype_cp932_binlog_stm.test	2007-03-01 18:16:13 +04:00
+++ 1.5/mysql-test/t/ctype_cp932_binlog_stm.test	2007-04-03 16:16:07 +05:00
@@ -27,3 +27,12 @@ delimiter ;|
 
 # End of 5.0 tests
 
+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

--- 1.37/storage/ndb/src/common/util/NdbSqlUtil.cpp	2007-02-23 15:23:42 +04:00
+++ 1.38/storage/ndb/src/common/util/NdbSqlUtil.cpp	2007-04-03 16:16:08 +05:00
@@ -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) {

--- 1.25/mysql-test/r/ctype_latin1_de.result	2006-02-22 13:09:48 +04:00
+++ 1.26/mysql-test/r/ctype_latin1_de.result	2007-04-03 16:16:07 +05:00
@@ -344,3 +344,107 @@ select * from t1 where length(s1)=1 and 
 s1
 drop table t1;
+End of 5.1 tests
+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 @@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
+4145
+4145
+4F45
+4F45
+5545
+5545
+select hex(weight_string('S'));
+hex(weight_string('S'))
+53
+select hex(weight_string('s'));
+hex(weight_string('s'))
+53
+5353
+41
+4F
+55
+53
+5841
+584F
+5855
+5853

--- 1.26/mysql-test/t/ctype_latin1_de.test	2005-09-16 00:17:37 +05:00
+++ 1.27/mysql-test/t/ctype_latin1_de.test	2007-04-03 16:16:07 +05:00
@@ -142,3 +142,26 @@ 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
+
+set @@collation_connection=latin1_german2_ci;
+--source include/weight_string.inc
+--source include/weight_string_l1.inc
+select hex(weight_string('S'));
+select hex(weight_string('s'));

--- 1.19/mysql-test/r/ctype_ujis.result	2006-03-23 14:07:36 +04:00
+++ 1.20/mysql-test/r/ctype_ujis.result	2007-04-03 16:16:07 +05:00
@@ -2343,3 +2343,306 @@ DROP TABLE t2;
 set names default;
 set character_set_database=default;
 set character_set_server=default;
+End of 5.1 tests
+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 @@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 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 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
+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 @@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 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 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

--- 1.19/mysql-test/t/ctype_ujis.test	2006-03-23 14:07:36 +04:00
+++ 1.20/mysql-test/t/ctype_ujis.test	2007-04-03 16:16:08 +05:00
@@ -1210,3 +1210,19 @@ DROP TABLE t2;
 set names default;
 set character_set_database=default;
 set character_set_server=default;
+
+--echo End of 5.1 tests
+
+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

--- 1.15/mysql-test/r/binlog_stm_ctype_cp932.result	2007-03-07 13:24:05 +04:00
+++ 1.16/mysql-test/r/binlog_stm_ctype_cp932.result	2007-04-03 16:16:07 +05:00
@@ -11375,3 +11375,114 @@ c_cp932
 ソ
+End of 5.1 tests
+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 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
+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 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

--- 1.6/mysql-test/r/ctype_eucjpms.result	2006-03-23 14:03:31 +04:00
+++ 1.7/mysql-test/r/ctype_eucjpms.result	2007-04-03 16:16:07 +05:00
@@ -9825,3 +9825,306 @@ hex(convert(_eucjpms 0xA5FE41 using ucs2
 select hex(convert(_eucjpms 0x8FABF841 using ucs2));
 hex(convert(_eucjpms 0x8FABF841 using ucs2))
 003F0041
+End of 5.1 tests
+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 @@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 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 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
+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 @@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 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 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

--- 1.17/mysql-test/extra/binlog_tests/ctype_cp932.test	2007-03-07 13:24:04 +04:00
+++ 1.18/mysql-test/extra/binlog_tests/ctype_cp932.test	2007-04-03 16:16:07 +05:00
@@ -438,3 +438,13 @@ drop table t1;
+
+--echo End of 5.1 tests
+
+set names cp932;
+--source include/weight_string.inc
+--source include/weight_string_8140.inc
+
+set collation_connection=cp932_bin;
+--source include/weight_string.inc
+--source include/weight_string_8140.inc

--- 1.9/mysql-test/t/ctype_eucjpms.test	2006-03-23 14:03:31 +04:00
+++ 1.10/mysql-test/t/ctype_eucjpms.test	2007-04-03 16:16:07 +05:00
@@ -380,3 +380,18 @@ select hex(convert(_eucjpms 0xA5FE41 usi
 # the next character, which is a single byte character 0x41.
 select hex(convert(_eucjpms 0x8FABF841 using ucs2));
 
+--echo End of 5.1 tests
+
+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

--- 1.16/strings/ctype-cp932.c	2007-01-24 21:57:04 +04:00
+++ 1.17/strings/ctype-cp932.c	2007-04-03 16:16:08 +05:00
@@ -274,30 +274,6 @@ static int my_strnncollsp_cp932(CHARSET_
 }
 
 
-
-static int my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)),
-                     uchar *dest, uint len,
-                     const uchar *src, uint 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:
@@ -5454,7 +5430,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  */
@@ -5525,6 +5501,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
 };
@@ -5557,6 +5535,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
 };

--- 1.17/strings/ctype-eucjpms.c	2007-01-24 21:57:04 +04:00
+++ 1.18/strings/ctype-eucjpms.c	2007-04-03 16:16:08 +05:00
@@ -8641,7 +8641,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_simple,/* like_range   */
     my_wildcmp_mb,	/* wildcmp      */
@@ -8651,6 +8651,7 @@ static MY_COLLATION_HANDLER my_collation
     my_propagate_simple
 };
 
+
 static MY_CHARSET_HANDLER my_charset_handler=
 {
     NULL,		/* init */
@@ -8712,6 +8713,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
 };
@@ -8745,6 +8748,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
 };
Thread
bk commit into 5.1 tree (bar:1.2474)bar3 Apr