List:Commits« Previous MessageNext Message »
From:eugene Date:December 27 2005 5:17pm
Subject:bk commit into 4.1 tree (evgen:1.2467) BUG#14583
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of evgen. When evgen 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.2467 05/12/27 20:16:59 evgen@stripped +3 -0
  Fix bug#14583 
  
  When InnoDB compares varchar field in ucs2 with given key using bin collation,
  it calls my_strnncollsp_ucs2_bin() to perform comparison.
  Because field length was lesser than length of key field should be padded
  with trailing spaces in order to get correct result. 
  Because  my_strnncollsp_ucs2_bin() was calling my_strnncollp_ucs2_bin(), which
  doesn't pads field, wrong comparison result was returned. This results in
  wrong result set.
  
  my_strnncollsp_ucs2_bin() now compares fields like my_strnncollsp_ucs2 do,
  but using binary collation.

  strings/ctype-ucs2.c
    1.46 05/12/27 20:15:43 evgen@stripped +39 -2
    Fix bug#14583 Wrong my_strnncollsp_ucs2_bin() behaviour results in skipping
    correct records.my_strnncollsp_ucs2_bin() now compares fields like my_strnncollsp_ucs2 do,
    but using binary collation.

  mysql-test/r/ctype_ucs.result
    1.27 05/12/27 20:15:25 evgen@stripped +7 -0
    Test case for bug#14583  Wrong my_strnncollsp_ucs2_bin() behaviour results in skipping correct records.

  mysql-test/t/ctype_ucs.test
    1.26 05/12/27 20:14:51 evgen@stripped +8 -0
    Test case for bug#14583  Wrong my_strnncollsp_ucs2_bin() behaviour results in skipping
    correct records.

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/14583-bug-4.1-mysql

--- 1.26/mysql-test/r/ctype_ucs.result	2005-09-21 21:17:29 +04:00
+++ 1.27/mysql-test/r/ctype_ucs.result	2005-12-27 20:15:25 +03:00
@@ -677,3 +677,10 @@
 005B
 803D
 drop table t1;
+create table t1(f1 varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL) engine=InnoDB;
+insert into t1 values('a');
+create index t1f1 on t1(f1);
+select f1 from t1 where f1 like 'a%';
+f1
+a
+drop table t1;

--- 1.25/mysql-test/t/ctype_ucs.test	2005-09-21 21:13:36 +04:00
+++ 1.26/mysql-test/t/ctype_ucs.test	2005-12-27 20:14:51 +03:00
@@ -419,4 +419,12 @@
 select hex(a) from t1;
 drop table t1;
 
+#
+# Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation
+#
+create table t1(f1 varchar(5) CHARACTER SET ucs2 COLLATE ucs2_bin NOT NULL) engine=InnoDB;
+insert into t1 values('a');
+create index t1f1 on t1(f1);
+select f1 from t1 where f1 like 'a%';
+drop table t1;
 # End of 4.1 tests

--- 1.45/strings/ctype-ucs2.c	2005-10-18 19:03:21 +04:00
+++ 1.46/strings/ctype-ucs2.c	2005-12-27 20:15:43 +03:00
@@ -1352,11 +1352,48 @@
   return t_is_prefix ? (int) (t - te) : (int) ((se-s) - (te-t));
 }
 
-static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs, 
+static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), 
                                    const uchar *s, uint slen, 
                                    const uchar *t, uint tlen)
 {
-  return my_strnncoll_ucs2_bin(cs,s,slen,t,tlen,0);
+  const uchar *se, *te;
+  uint minlen;
+
+  /* extra safety to make sure the lengths are even numbers */
+  slen= (slen >> 1) << 1;
+  tlen= (tlen >> 1) << 1;
+
+  se= s + slen;
+  te= t + tlen;
+
+  for (minlen= min(slen, tlen); minlen; minlen-= 2)
+  {
+    int s_wc= s[0] * 256 + s[1];
+    int t_wc= t[0] * 256 + t[1];
+    if ( s_wc != t_wc )
+      return  s_wc > t_wc ? 1 : -1;
+
+    s+= 2;
+    t+= 2;
+  }
+
+  if (slen != tlen)
+  {
+    int swap= 1;
+    if (slen < tlen)
+    {
+      s= t;
+      se= te;
+      swap= -1;
+    }
+
+    for ( ; s < se ; s+= 2)
+    {
+      if (s[0] || s[1] != ' ')
+        return (s[0] == 0 && s[1] < ' ') ? -swap : swap;
+    }
+  }
+  return 0;
 }
 
 
Thread
bk commit into 4.1 tree (evgen:1.2467) BUG#14583eugene27 Dec