diff -c -r mysql-5.0.17/config/ac-macros/character_sets.m4 mysql-5.0.17.test/config/ac-macros/character_sets.m4
*** mysql-5.0.17/config/ac-macros/character_sets.m4	2005-12-15 00:33:31.000000000 +0100
--- mysql-5.0.17.test/config/ac-macros/character_sets.m4	2005-12-30 16:35:02.000000000 +0100
***************
*** 225,231 ****
        ;;
      cp1250)
        default_charset_default_collation="cp1250_general_ci"
!       default_charset_collations="cp1250_general_ci cp1250_czech_cs cp1250_bin"
        ;;
      cp1251)
        default_charset_default_collation="cp1251_general_ci"
--- 225,231 ----
        ;;
      cp1250)
        default_charset_default_collation="cp1250_general_ci"
!       default_charset_collations="cp1250_general_ci cp1250_czech_cs cp1250_czech_ci cp1250_bin"
        ;;
      cp1251)
        default_charset_default_collation="cp1251_general_ci"
***************
*** 309,315 ****
        ;;
      latin2)
        default_charset_default_collation="latin2_general_ci"
!       default_charset_collations="latin2_general_ci latin2_bin latin2_czech_cs latin2_hungarian_ci latin2_croatian_ci"
        ;;
      latin5)
        default_charset_default_collation="latin5_turkish_ci"
--- 309,315 ----
        ;;
      latin2)
        default_charset_default_collation="latin2_general_ci"
!       default_charset_collations="latin2_general_ci latin2_bin latin2_czech_cs latin2_czech_ci latin2_hungarian_ci latin2_croatian_ci"
        ;;
      latin5)
        default_charset_default_collation="latin5_turkish_ci"
diff -c -r mysql-5.0.17/configure mysql-5.0.17.test/configure
*** mysql-5.0.17/configure	2005-12-15 00:35:25.000000000 +0100
--- mysql-5.0.17.test/configure	2005-12-30 16:42:05.000000000 +0100
***************
*** 2610,2616 ****
        ;;
      cp1250)
        default_charset_default_collation="cp1250_general_ci"
!       default_charset_collations="cp1250_general_ci cp1250_czech_cs cp1250_bin"
        ;;
      cp1251)
        default_charset_default_collation="cp1251_general_ci"
--- 2610,2616 ----
        ;;
      cp1250)
        default_charset_default_collation="cp1250_general_ci"
!       default_charset_collations="cp1250_general_ci cp1250_czech_cs cp1250_czech_ci cp1250_bin"
        ;;
      cp1251)
        default_charset_default_collation="cp1251_general_ci"
***************
*** 2694,2700 ****
        ;;
      latin2)
        default_charset_default_collation="latin2_general_ci"
!       default_charset_collations="latin2_general_ci latin2_bin latin2_czech_cs latin2_hungarian_ci latin2_croatian_ci"
        ;;
      latin5)
        default_charset_default_collation="latin5_turkish_ci"
--- 2694,2700 ----
        ;;
      latin2)
        default_charset_default_collation="latin2_general_ci"
!       default_charset_collations="latin2_general_ci latin2_bin latin2_czech_cs latin2_czech_ci latin2_hungarian_ci latin2_croatian_ci"
        ;;
      latin5)
        default_charset_default_collation="latin5_turkish_ci"
diff -c -r mysql-5.0.17/include/m_ctype.h mysql-5.0.17.test/include/m_ctype.h
*** mysql-5.0.17/include/m_ctype.h	2005-12-15 00:33:16.000000000 +0100
--- mysql-5.0.17.test/include/m_ctype.h	2005-12-30 16:37:44.000000000 +0100
***************
*** 256,261 ****
--- 256,262 ----
  extern CHARSET_INFO my_charset_latin1;
  extern CHARSET_INFO my_charset_latin1_german2_ci;
  extern CHARSET_INFO my_charset_latin1_bin;
+ extern CHARSET_INFO my_charset_latin2_czech_cs;
  extern CHARSET_INFO my_charset_latin2_czech_ci;
  extern CHARSET_INFO my_charset_sjis_japanese_ci;
  extern CHARSET_INFO my_charset_sjis_bin;
***************
*** 268,273 ****
--- 269,275 ----
  extern CHARSET_INFO my_charset_ujis_bin;
  extern CHARSET_INFO my_charset_utf8_general_ci;
  extern CHARSET_INFO my_charset_utf8_bin;
+ extern CHARSET_INFO my_charset_cp1250_czech_cs;
  extern CHARSET_INFO my_charset_cp1250_czech_ci;
  
  /* declarations for simple charsets */
diff -c -r mysql-5.0.17/mysys/charset-def.c mysql-5.0.17.test/mysys/charset-def.c
*** mysql-5.0.17/mysys/charset-def.c	2005-12-15 00:33:32.000000000 +0100
--- mysql-5.0.17.test/mysys/charset-def.c	2005-12-30 17:10:39.000000000 +0100
***************
*** 88,93 ****
--- 88,94 ----
  
  #ifdef HAVE_CHARSET_cp1250
    add_compiled_collation(&my_charset_cp1250_czech_ci);
+   add_compiled_collation(&my_charset_cp1250_czech_cs);
  #endif
  
  #ifdef HAVE_CHARSET_cp932
***************
*** 97,102 ****
--- 98,104 ----
  
  #ifdef HAVE_CHARSET_latin2
    add_compiled_collation(&my_charset_latin2_czech_ci);
+   add_compiled_collation(&my_charset_latin2_czech_cs);
  #endif
  
  #ifdef HAVE_CHARSET_eucjpms
diff -c -r mysql-5.0.17/scripts/mysqlbug mysql-5.0.17.test/scripts/mysqlbug
*** mysql-5.0.17/scripts/mysqlbug	2005-12-15 00:42:59.000000000 +0100
--- mysql-5.0.17.test/scripts/mysqlbug	2005-12-30 17:35:21.000000000 +0100
***************
*** 8,15 ****
  COMPILATION_COMMENT="Source distribution"
  BUGmysql="mysql@lists.mysql.com"
  # This is set by configure
! COMP_ENV_INFO="CC='ccache gcc'  CFLAGS=''  CXX='ccache gcc'  CXXFLAGS='-felide-constructors -fno-exceptions -fno-rtti'  LDFLAGS=''  ASFLAGS=''"
! CONFIGURE_LINE="./configure '--with-embedded-server' '--with-berkeley-db' '--with-innodb' '--enable-thread-safe-client' '--with-extra-charsets=complex' '--with-ndbcluster' 'CC=ccache gcc' 'CXXFLAGS=-felide-constructors -fno-exceptions -fno-rtti' 'CXX=ccache gcc'"
  
  LIBC_INFO=""
  for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
--- 8,15 ----
  COMPILATION_COMMENT="Source distribution"
  BUGmysql="mysql@lists.mysql.com"
  # This is set by configure
! COMP_ENV_INFO="CC='gcc'  CFLAGS=''  CXX='g++'  CXXFLAGS=''  LDFLAGS=''  ASFLAGS=''"
! CONFIGURE_LINE="./configure '--prefix=/var/lib' '--exec-prefix=/usr' '--datadir=/var/lib/mysql' '--sysconfdir=/etc' '--localstatedir=/var/lib/mysql' '--with-unix-socket-path=/var/lib/mysql/mysql.sock' '--with-mysqld-user=mysql' '--enable-local-infile' '--with-charset=cp1250' '--with-extra-charsets=complex' '--with-mysql=/usr/local/mysql'"
  
  LIBC_INFO=""
  for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-*
***************
*** 231,238 ****
  >Class:		$CLASS_C
  >Release:	mysql-${VERSION} ($COMPILATION_COMMENT)
  `test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
! >C compiler:    gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
! >C++ compiler:  gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
  >Environment:
  	$ENVIRONMENT_C
  `test -n "$SYSTEM"  && echo "System: $SYSTEM"`
--- 231,238 ----
  >Class:		$CLASS_C
  >Release:	mysql-${VERSION} ($COMPILATION_COMMENT)
  `test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"`
! >C compiler:    gcc (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)
! >C++ compiler:  g++ (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)
  >Environment:
  	$ENVIRONMENT_C
  `test -n "$SYSTEM"  && echo "System: $SYSTEM"`
diff -c -r mysql-5.0.17/sql/share/charsets/cp1250.xml mysql-5.0.17.test/sql/share/charsets/cp1250.xml
*** mysql-5.0.17/sql/share/charsets/cp1250.xml	2005-12-15 00:43:58.000000000 +0100
--- mysql-5.0.17.test/sql/share/charsets/cp1250.xml	2005-12-27 16:05:30.000000000 +0100
***************
*** 154,159 ****
--- 154,162 ----
  </collation>
  
  <collation name="cp1250_czech_ci"/>
+ <collation name="cp1250_czech_cs"/>
+ 
+ 
  
  <collation name="cp1250_bin"	flag="binary"/>
  
diff -c -r mysql-5.0.17/sql/share/charsets/Index.xml mysql-5.0.17.test/sql/share/charsets/Index.xml
*** mysql-5.0.17/sql/share/charsets/Index.xml	2005-12-15 00:44:01.000000000 +0100
--- mysql-5.0.17.test/sql/share/charsets/Index.xml	2005-12-30 16:48:28.000000000 +0100
***************
*** 1,6 ****
  <?xml version='1.0' encoding="utf-8"?>
  
! <charsets max-id="98">
  
  <copyright>
   Copyright (C) 2003 MySQL AB
--- 1,6 ----
  <?xml version='1.0' encoding="utf-8"?>
  
! <charsets max-id="100">
  
  <copyright>
   Copyright (C) 2003 MySQL AB
***************
*** 55,60 ****
--- 55,61 ----
    <alias>iso_8859-2:1987</alias>
    <alias>l2</alias>
    <collation name="latin2_czech_cs" 	id="2"	order="Czech" flag="compiled"/>
+   <collation name="latin2_czech_ci" 	id="100" order="Czech" flag="compiled"/>
    <collation name="latin2_general_ci"	id="9"	flag="primary">
      <order>Hungarian</order>
      <order>Polish</order>
***************
*** 373,378 ****
--- 374,382 ----
    <collation name="cp1250_czech_cs"	id="34"	order="Czech">
      <flag>compiled</flag>
    </collation>
+   <collation name="cp1250_czech_ci"	id="99"	order="Czech">
+     <flag>compiled</flag>
+   </collation>
    <collation name="cp1250_bin"		id="66"	order="Binary"	flag="binary"/>
  </charset>
  
diff -c -r mysql-5.0.17/sql/share/charsets/latin2.xml mysql-5.0.17.test/sql/share/charsets/latin2.xml
*** mysql-5.0.17/sql/share/charsets/latin2.xml	2005-12-15 00:43:58.000000000 +0100
--- mysql-5.0.17.test/sql/share/charsets/latin2.xml	2005-12-30 16:39:34.000000000 +0100
***************
*** 155,163 ****
  </collation>
  
  
  <collation name="latin2_czech_ci"/>
  
- 
  <collation name="latin2_hungarian_ci">
  <map>
   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
--- 155,163 ----
  </collation>
  
  
+ <collation name="latin2_czech_cs"/>
  <collation name="latin2_czech_ci"/>
  
  <collation name="latin2_hungarian_ci">
  <map>
   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
diff -c -r mysql-5.0.17/strings/ctype-czech.c mysql-5.0.17.test/strings/ctype-czech.c
*** mysql-5.0.17/strings/ctype-czech.c	2005-12-15 00:33:33.000000000 +0100
--- mysql-5.0.17.test/strings/ctype-czech.c	2005-12-30 17:59:55.000000000 +0100
***************
*** 165,170 ****
--- 165,172 ----
  	Na konci připojíme znak 0
   */
  
+ /* treti kolo je case sensitive */
+ 
  #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))
***************
*** 235,240 ****
--- 237,309 ----
    break;						\
  }
  
+ #define NEXT_CMP_VALUE_CI(src, p, store, pass, value, len)		\
+ while (1)						\
+ {							\
+   if (IS_END(p, src, len))				\
+   {							\
+     /* 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 != 1)					\
+    {							\
+      p= (pass++ == 0) ? store : src;			\
+      value = 1;						\
+    }							\
+    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 == 255)					\
+   {							\
+     int i;						\
+     for (i = 0; i < (int) sizeof(doubles); i++)		\
+     {							\
+       const char * pattern = doubles[i].word;		\
+       const char * q = (const char *) p;		\
+       int j = 0;					\
+       while (pattern[j])				\
+       {							\
+ 	if (IS_END(q, src, len) || (*q != pattern[j]))	\
+ 	 break;						\
+ 	j++; q++;					\
+       }							\
+       if (!(pattern[j]))				\
+       {							\
+ 	value = (int)(doubles[i].outvalue[pass]);	\
+ 	p= (const uchar *) q - 1;			\
+ 	break;						\
+       }							\
+     }							\
+   }							\
+   p++;							\
+   break;						\
+ }
+ 
+ 
  /*
    Function strnncoll, actually strcoll, with Czech sorting, which expect
    the length of the strings being specified
***************
*** 312,317 ****
--- 381,459 ----
    return len;
  }
  
+ 
+ static int my_strnncoll_czech_ci(CHARSET_INFO *cs __attribute__((unused)),
+ 			      const uchar * s1, uint len1, 
+ 			      const uchar * s2, uint len2,
+                               my_bool s2_is_prefix)
+ {
+   int v1, v2;
+   const uchar * p1, * p2, * store1, * store2;
+   int pass1 = 0, pass2 = 0;
+ 
+   if (s2_is_prefix && len1 > len2)
+     len1=len2;
+ 
+   p1 = s1;	p2 = s2;
+   store1 = s1;	store2 = s2;
+ 
+   do
+   {
+     int diff;
+     NEXT_CMP_VALUE_CI(s1, p1, store1, pass1, v1, (int)len1);
+     NEXT_CMP_VALUE_CI(s2, p2, store2, pass2, v2, (int)len2);
+     if ((diff = v1 - v2))
+       return diff;
+   }
+   while (v1);
+   return 0;
+ }
+ 
+ 
+ 
+ /*
+   TODO: Fix this one to compare strings as they are done in ctype-simple1
+ */
+ 
+ static
+ int my_strnncollsp_czech_ci(CHARSET_INFO * cs, 
+                          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_ci(cs,s,slen,t,tlen,0);
+ }
+ 
+ 
+ /*
+   Function strnxfrm, actually strxfrm, with Czech sorting, which expect
+   the length of the strings being specified
+ */
+ 
+ static int my_strnxfrm_czech_ci(CHARSET_INFO *cs __attribute__((unused)), 
+ 			     uchar * dest, uint len,
+ 			     const uchar * src, uint srclen)
+ {
+   int value;
+   const uchar * p, * store;
+   int pass = 0;
+   uint totlen = 0;
+   p = src;	store = src;
+ 
+   do
+   {
+     NEXT_CMP_VALUE_CI(src, p, store, pass, value, (int)srclen);
+     ADD_TO_RESULT(dest, len, totlen, value);
+   }
+   while (value);
+   if (len > totlen)
+     bfill(dest + totlen, len - totlen, ' ');
+   return len;
+ }
+ 
  #undef IS_END
  
  
***************
*** 587,593 ****
  };
  
  
! static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler =
  {
    NULL,			/* init */
    my_strnncoll_czech,
--- 729,735 ----
  };
  
  
! static MY_COLLATION_HANDLER my_collation_latin2_czech_cs_handler =
  {
    NULL,			/* init */
    my_strnncoll_czech,
***************
*** 602,608 ****
    my_propagate_simple
  };
  
! CHARSET_INFO my_charset_latin2_czech_ci =
  {
      2,0,0,                                      /* number    */
      MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
--- 744,750 ----
    my_propagate_simple
  };
  
! CHARSET_INFO my_charset_latin2_czech_cs =
  {
      2,0,0,                                      /* number    */
      MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
***************
*** 631,639 ****
      ' ',                /* pad char      */
      0,                  /* escape_with_backslash_is_dangerous */
      &my_charset_8bit_handler,
!     &my_collation_latin2_czech_ci_handler
  };
  
  
  #endif
  
--- 773,827 ----
      ' ',                /* pad char      */
      0,                  /* escape_with_backslash_is_dangerous */
      &my_charset_8bit_handler,
!     &my_collation_latin2_czech_cs_handler
! };
! 
! static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler =
! {
!   NULL,			/* init */
!   my_strnncoll_czech_ci,
!   my_strnncollsp_czech_ci,
!   my_strnxfrm_czech_ci,
!   my_strnxfrmlen_simple,
!   my_like_range_czech,
!   my_wildcmp_8bit,
!   my_strcasecmp_8bit,
!   my_instr_simple,
!   my_hash_sort_simple,
!   my_propagate_simple
  };
  
+ CHARSET_INFO my_charset_latin2_czech_ci =
+ {
+     100,0,0,                                      /* number    */
+     MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
+     "latin2",                                   /* cs name   */
+     "latin2_czech_ci",                          /* name      */
+     "",                                         /* comment   */
+     NULL,                                       /* tailoring */
+     ctype_czech,
+     to_lower_czech,
+     to_upper_czech,
+     sort_order_czech,
+     NULL,		/* contractions */
+     NULL,		/* sort_order_big*/
+     tab_8859_2_uni,	/* tab_to_uni   */
+     idx_uni_8859_2,	/* tab_from_uni */
+     my_unicase_default, /* caseinfo     */
+     NULL,		/* state_map    */
+     NULL,		/* ident_map    */
+     4,			/* strxfrm_multiply */
+     1,                  /* caseup_multiply  */
+     1,                  /* casedn_multiply  */
+     1,			/* mbminlen   */
+     1,			/* mbmaxlen  */
+     0,			/* min_sort_char */
+     0,			/* max_sort_char */
+     ' ',                /* pad char      */
+     0,                  /* escape_with_backslash_is_dangerous */
+     &my_charset_8bit_handler,
+     &my_collation_latin2_czech_ci_handler
+ };
  
  #endif
  
diff -c -r mysql-5.0.17/strings/ctype-win1250ch.c mysql-5.0.17.test/strings/ctype-win1250ch.c
*** mysql-5.0.17/strings/ctype-win1250ch.c	2005-12-15 00:33:32.000000000 +0100
--- mysql-5.0.17.test/strings/ctype-win1250ch.c	2005-12-29 20:52:10.000000000 +0100
***************
*** 261,267 ****
  
  
  
! static uchar NEAR sort_order_win1250ch[] = {
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
--- 261,267 ----
  
  
  
! static uchar NEAR sort_order_win1250ch_cs[] = {
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
***************
*** 280,285 ****
--- 280,305 ----
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
  };
  
+ static uchar NEAR sort_order_win1250ch_ci[] = {
+ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 71, 72, 76, 78, 83, 84, 85, 86, 90, 91, 92, 96, 97,100,
+ 105,106,107,110,114,117,122,123,124,125,127,131,132,133,134,135,
+ 136, 65, 71, 72, 76, 78, 83, 84, 85, 86, 90, 91, 92, 96, 97,100,
+ 105,106,107,110,114,117,122,123,124,125,127,137,138,139,140,  0,
+ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,255,
+ 66,255, 93,255, 94,111,255,255,255,112,113,115,128,255,129,130,
+ 255, 66,255, 93,255, 94,111,255,255,112,113,115,128,255,129,130,
+ 108, 67, 68, 69, 70, 95, 73, 75, 74, 79, 81, 82, 80, 89, 87, 77,
+ 255, 98, 99,101,102,103,104,255,109,119,118,120,121,126,116,255,
+ 108, 67, 68, 69, 70, 95, 73, 75, 74, 79, 81, 82, 80, 89, 88, 77,
+ 255, 98, 99,101,102,103,104,255,109,119,118,120,121,126,116,255,
+ };
+ 
+ 
  static uchar NEAR _sort_order_win1250ch1[] = {
  0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
  0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
***************
*** 413,419 ****
  	{ (uchar*) "C",  0xa6, 0x01 },
  };
  
! #define NEXT_CMP_VALUE(src, p, pass, value, len)			\
  	while (1) {							\
  		if (IS_END(p, src, len)) {				\
  			if (pass == 0 && len > 0) { p= src; pass++; }	\
--- 433,439 ----
  	{ (uchar*) "C",  0xa6, 0x01 },
  };
  
! #define NEXT_CMP_VALUE_CS(src, p, pass, value, len)			\
  	while (1) {							\
  		if (IS_END(p, src, len)) {				\
  			if (pass == 0 && len > 0) { p= src; pass++; }	\
***************
*** 444,452 ****
  		break;							\
  	}
  
  #define IS_END(p, src, len)	(((char *)p - (char *)src) >= (len))
  
! static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), 
  				  const uchar * s1, uint len1,
                                    const uchar * s2, uint len2,
                                    my_bool s2_is_prefix)
--- 464,501 ----
  		break;							\
  	}
  
+ #define NEXT_CMP_VALUE_CI(src, p, pass, value, len)			\
+ 	while (1) {							\
+ 		if (IS_END(p, src, len)) {				\
+ 			value = 0; break;  				\
+ 		}							\
+ 		value =  _sort_order_win1250ch1[*p];			\
+ 		if (value == 0xff) {					\
+ 			int i;						\
+ 			for (i = 0; i < (int) sizeof(doubles); i++) {	\
+ 				const uchar * patt = doubles[i].word;	\
+ 				const uchar * q = (const uchar *) p;	\
+ 				while (*patt				\
+ 					&& !(IS_END(q, src, len))	\
+ 					&& (*patt == *q)) {		\
+ 					patt++; q++;			\
+ 				}					\
+ 				if (!(*patt)) {				\
+ 					value = (int)(			\
+ 						doubles[i].pass1);	\
+ 					p = (const uchar *) q - 1;	\
+ 					break;				\
+ 				}					\
+ 			}						\
+ 		}							\
+ 		p++;							\
+ 		break;							\
+ 	}
+ 
+ 
  #define IS_END(p, src, len)	(((char *)p - (char *)src) >= (len))
  
! static int my_strnncoll_win1250ch_cs(CHARSET_INFO *cs __attribute__((unused)), 
  				  const uchar * s1, uint len1,
                                    const uchar * s2, uint len2,
                                    my_bool s2_is_prefix)
***************
*** 463,470 ****
  
    do
    {
!     NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1);
!     NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2);
      if ((diff = v1 - v2))
        return diff;
    } while (v1);
--- 512,519 ----
  
    do
    {
!     NEXT_CMP_VALUE_CS(s1, p1, pass1, v1, (int)len1);
!     NEXT_CMP_VALUE_CS(s2, p2, pass2, v2, (int)len2);
      if ((diff = v1 - v2))
        return diff;
    } while (v1);
***************
*** 477,483 ****
  */
  
  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
--- 526,532 ----
  */
  
  static
! int my_strnncollsp_win1250ch_cs(CHARSET_INFO * cs, 
  			     const uchar *s, uint slen, 
  			     const uchar *t, uint tlen,
                               my_bool diff_if_only_endspace_difference
***************
*** 485,495 ****
  {
    for ( ; slen && s[slen-1] == ' ' ; slen--);
    for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
!   return my_strnncoll_win1250ch(cs,s,slen,t,tlen,0);
  }
  
  
! static int my_strnxfrm_win1250ch(CHARSET_INFO * cs  __attribute__((unused)),
  				 uchar * dest, uint len, 
  				 const uchar * src, uint srclen)
  {
--- 534,544 ----
  {
    for ( ; slen && s[slen-1] == ' ' ; slen--);
    for ( ; tlen && t[tlen-1] == ' ' ; tlen--);
!   return my_strnncoll_win1250ch_cs(cs,s,slen,t,tlen,0);
  }
  
  
! static int my_strnxfrm_win1250ch_cs(CHARSET_INFO * cs  __attribute__((unused)),
  				 uchar * dest, uint len, 
  				 const uchar * src, uint srclen)
  {
***************
*** 500,506 ****
    p = src;
  
    do {
!     NEXT_CMP_VALUE(src, p, pass, value, (int)srclen);
      if (totlen <= len)
        dest[totlen] = value;
      totlen++;
--- 549,619 ----
    p = src;
  
    do {
!     NEXT_CMP_VALUE_CS(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;
! }
! 
! static int my_strnncoll_win1250ch_ci(CHARSET_INFO *cs __attribute__((unused)), 
! 				  const uchar * s1, uint len1,
!                                   const uchar * s2, uint len2,
!                                   my_bool s2_is_prefix)
! {
!   int v1, v2;
!   const uchar * p1, * p2;
!   int pass1 = 0, pass2 = 0;
!   int diff;
! 
!   if (s2_is_prefix && len1 > len2)
!     len1=len2;
! 
!   p1 = s1;	p2 = s2;
! 
!   do
!   {
!     NEXT_CMP_VALUE_CI(s1, p1, pass1, v1, (int)len1);
!     NEXT_CMP_VALUE_CI(s2, p2, pass2, v2, (int)len2);
!     if ((diff = v1 - v2))
!       return diff;
!   } while (v1);
!   return 0;
! }
! 
! 
! /*
!   TODO: Has to be fixed as strnncollsp in ctype-simple
! */
! 
! static
! int my_strnncollsp_win1250ch_ci(CHARSET_INFO * cs, 
! 			     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_ci(cs,s,slen,t,tlen,0);
! }
! 
! 
! static int my_strnxfrm_win1250ch_ci(CHARSET_INFO * cs  __attribute__((unused)),
! 				 uchar * dest, uint len, 
! 				 const uchar * src, uint srclen)
! {
!   int value;
!   const uchar * p;
!   int pass = 0;
!   uint totlen = 0;
!   p = src;
! 
!   do {
!     NEXT_CMP_VALUE_CI(src, p, pass, value, (int)srclen);
      if (totlen <= len)
        dest[totlen] = value;
      totlen++;
***************
*** 514,520 ****
  
  #ifdef REAL_MYSQL
  
! static uchar NEAR like_range_prefix_min_win1250ch[]=
  {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
--- 627,633 ----
  
  #ifdef REAL_MYSQL
  
! static uchar NEAR like_range_prefix_min_win1250ch_cs[]=
  {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
***************
*** 558,564 ****
    For all other characters:   prefix_max[i]    == i
  */
  
! static uchar NEAR like_range_prefix_max_win1250ch[]=
  {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
--- 671,678 ----
    For all other characters:   prefix_max[i]    == i
  */
  
! 
! static uchar NEAR like_range_prefix_max_win1250ch_cs[]=
  {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
***************
*** 594,599 ****
--- 708,791 ----
    0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
  };
  
+ /*
+   like_range_prefix_min_win1250ch_ci ~ to_upper_win1250ch
+   like_range_prefix_max_win1250ch_ci ~ modificated to_lower (char C)
+ */
+ 
+ static uchar NEAR like_range_prefix_min_win1250ch_ci[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+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xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbe, 0xbd, 0xbe, 0xbf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
+ };
+ 
+ 
+ 
  #define min_sort_char '\x20'
  #define max_sort_char '\xff'
  
***************
*** 615,621 ****
  */
  
  static my_bool
! my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
  			const char *ptr, uint ptr_length,
  			pbool escape, pbool w_one, pbool w_many,
  			uint res_length,
--- 807,860 ----
  */
  
  static my_bool
! my_like_range_win1250ch_cs(CHARSET_INFO *cs __attribute__((unused)),
! 			const char *ptr, uint ptr_length,
! 			pbool escape, pbool w_one, pbool w_many,
! 			uint res_length,
! 			char *min_str, char *max_str,
! 			uint *min_length, uint *max_length)
! {
! 
!   int only_min_found= 1;
!   const char *end = ptr + ptr_length;
!   char *min_org = min_str;
!   char *min_end = min_str + res_length;
! 
!   /* return 1; */
! 
!   for (; ptr != end && min_str != min_end ; ptr++)
!   {
!     if (*ptr == escape && ptr+1 != end)
!       ptr++;					/* Skip escape */
!     else if (*ptr == w_one || *ptr == w_many)	/* '_' or '%' in SQL */
!       break;
!     *min_str = like_range_prefix_min_win1250ch_cs[(uint)(*ptr)];
!     if (*min_str != min_sort_char)
!       only_min_found= 0;
!     min_str++;
!     *max_str++= like_range_prefix_max_win1250ch_cs[(uint)(*ptr)];
!   }
! 
!   if (cs->state & MY_CS_BINSORT)
!     *min_length= (uint) (min_str - min_org);
!   else
!   {
!     /* 'a\0\0... is the smallest possible string */
!     *min_length= res_length;
!   }
!   /* a\ff\ff... is the biggest possible string */
!   *max_length= res_length;
! 
!   while (min_str != min_end)
!   {
!     *min_str++ = min_sort_char;
!     *max_str++ = max_sort_char;
!   }
!   return (only_min_found);
! }
! 
! static my_bool
! my_like_range_win1250ch_ci(CHARSET_INFO *cs __attribute__((unused)),
  			const char *ptr, uint ptr_length,
  			pbool escape, pbool w_one, pbool w_many,
  			uint res_length,
***************
*** 636,646 ****
        ptr++;					/* Skip escape */
      else if (*ptr == w_one || *ptr == w_many)	/* '_' or '%' in SQL */
        break;
!     *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)];
      if (*min_str != min_sort_char)
        only_min_found= 0;
      min_str++;
!     *max_str++= like_range_prefix_max_win1250ch[(uint)(*ptr)];
    }
  
    if (cs->state & MY_CS_BINSORT)
--- 875,885 ----
        ptr++;					/* Skip escape */
      else if (*ptr == w_one || *ptr == w_many)	/* '_' or '%' in SQL */
        break;
!     *min_str = like_range_prefix_min_win1250ch_ci[(uint)(*ptr)];
      if (*min_str != min_sort_char)
        only_min_found= 0;
      min_str++;
!     *max_str++= like_range_prefix_max_win1250ch_ci[(uint)(*ptr)];
    }
  
    if (cs->state & MY_CS_BINSORT)
***************
*** 661,675 ****
    return (only_min_found);
  }
  
  
  static MY_COLLATION_HANDLER my_collation_czech_ci_handler =
  {
    NULL,				/* init */
!   my_strnncoll_win1250ch,
!   my_strnncollsp_win1250ch,
!   my_strnxfrm_win1250ch,
    my_strnxfrmlen_simple,
!   my_like_range_win1250ch,
    my_wildcmp_8bit,
    my_strcasecmp_8bit,
    my_instr_simple,
--- 900,928 ----
    return (only_min_found);
  }
  
+ static MY_COLLATION_HANDLER my_collation_czech_cs_handler =
+ {
+   NULL,				/* init */
+   my_strnncoll_win1250ch_cs,
+   my_strnncollsp_win1250ch_cs,
+   my_strnxfrm_win1250ch_cs,
+   my_strnxfrmlen_simple,
+   my_like_range_win1250ch_cs,
+   my_wildcmp_8bit,
+   my_strcasecmp_8bit,
+   my_instr_simple,
+   my_hash_sort_simple,
+   my_propagate_simple
+ };
  
  static MY_COLLATION_HANDLER my_collation_czech_ci_handler =
  {
    NULL,				/* init */
!   my_strnncoll_win1250ch_ci,
!   my_strnncollsp_win1250ch_ci,
!   my_strnxfrm_win1250ch_ci,
    my_strnxfrmlen_simple,
!   my_like_range_win1250ch_ci,
    my_wildcmp_8bit,
    my_strcasecmp_8bit,
    my_instr_simple,
***************
*** 678,684 ****
  };
  
  
! CHARSET_INFO my_charset_cp1250_czech_ci =
  {
    34,0,0,                                     /* number    */
    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
--- 931,937 ----
  };
  
  
! CHARSET_INFO my_charset_cp1250_czech_cs =
  {
    34,0,0,                                     /* number    */
    MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
***************
*** 689,695 ****
    ctype_win1250ch,
    to_lower_win1250ch,
    to_upper_win1250ch,
!   sort_order_win1250ch,
    NULL,				/* contractions */
    NULL,				/* sort_order_big*/
    tab_cp1250_uni,		/* tab_to_uni   */
--- 942,948 ----
    ctype_win1250ch,
    to_lower_win1250ch,
    to_upper_win1250ch,
!   sort_order_win1250ch_cs,
    NULL,				/* contractions */
    NULL,				/* sort_order_big*/
    tab_cp1250_uni,		/* tab_to_uni   */
***************
*** 707,715 ****
    ' ',                          /* pad char      */
    0,                            /* escape_with_backslash_is_dangerous */
    &my_charset_8bit_handler,
!   &my_collation_czech_ci_handler
  };
  
  
  #endif /* REAL_MYSQL */
  
--- 960,999 ----
    ' ',                          /* pad char      */
    0,                            /* escape_with_backslash_is_dangerous */
    &my_charset_8bit_handler,
!   &my_collation_czech_cs_handler
  };
  
+ CHARSET_INFO my_charset_cp1250_czech_ci =
+ {
+   99,0,0,                                     /* number    */
+   MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state     */
+   "cp1250",                                   /* cs name   */
+   "cp1250_czech_ci",                          /* name      */
+   "",                                         /* comment   */
+   NULL,                                       /* tailoring */
+   ctype_win1250ch,
+   to_lower_win1250ch,
+   to_upper_win1250ch,
+   sort_order_win1250ch_ci,
+   NULL,				/* contractions */
+   NULL,				/* sort_order_big*/
+   tab_cp1250_uni,		/* tab_to_uni   */
+   idx_uni_cp1250,		/* tab_from_uni */
+   my_unicase_default,           /* caseinfo     */
+   NULL,				/* state_map    */
+   NULL,				/* ident_map    */
+   2,				/* strxfrm_multiply */
+   1,                            /* caseup_multiply  */
+   1,                            /* casedn_multiply  */
+   1,				/* mbminlen  */
+   1,				/* mbmaxlen  */
+   0,				/* min_sort_char */
+   0,				/* max_sort_char */
+   ' ',                          /* pad char      */
+   0,                            /* escape_with_backslash_is_dangerous */
+   &my_charset_8bit_handler,
+   &my_collation_czech_ci_handler
+ };
  
  #endif /* REAL_MYSQL */
  


