List:Internals« Previous MessageNext Message »
From:eugene Date:September 11 2005 12:34am
Subject:bk commit into 4.1 tree (evgen:1.2417) BUG#13046
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.2417 05/09/11 02:34:01 evgen@stripped +10 -0
  Fix bug #13046 Escape length was included into key length
  
  Bug present in function my_like_range_simple() and same functions with 
  _big5(), _cp932(), _gbk(), _mb(), _sjis() endings. When they are generating
  min and max keys for like range they skip escape char itself but include length
  of escape char in key length, thus generating wrong key.
  
  Added test cases for my_like_range_simple() and _mb() functions.

  mysql-test/t/ctype_utf8.test
    1.67 05/09/11 02:30:04 evgen@stripped +9 -0
    Test case for bug#13046Escape length was included into key length

  mysql-test/t/ctype_latin1.test
    1.6 05/09/11 02:29:51 evgen@stripped +9 -0
    Test case for bug#13046Escape length was included into key length

  mysql-test/r/ctype_utf8.result
    1.65 05/09/11 02:29:35 evgen@stripped +9 -0
    Test case for bug#13046Escape length was included into key length

  mysql-test/r/ctype_latin1.result
    1.6 05/09/11 02:29:08 evgen@stripped +9 -0
    Test case for bug#13046Escape length was included into key length

  strings/ctype-sjis.c
    1.81 05/09/11 02:28:38 evgen@stripped +11 -0
     Fix bug #13046 Escape length was included into key length

  strings/ctype-simple.c
    1.66 05/09/11 02:28:27 evgen@stripped +11 -0
    Fix bug #13046 Escape length was included into key length

  strings/ctype-mb.c
    1.41 05/09/11 02:28:09 evgen@stripped +11 -0
    Fix bug #13046 Escape length was included into key length

  strings/ctype-gbk.c
    1.72 05/09/11 02:27:56 evgen@stripped +11 -0
    Fix bug #13046 Escape length was included into key length

  strings/ctype-cp932.c
    1.7 05/09/11 02:27:42 evgen@stripped +11 -0
    Fix bug #13046 Escape length was included into key length

  strings/ctype-big5.c
    1.78 05/09/11 02:27:08 evgen@stripped +11 -0
    Fix bug #13046 Escape length was included into key length

# 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/13046-bug-4.1-mysql

--- 1.77/strings/ctype-big5.c	2005-08-17 12:26:27 +04:00
+++ 1.78/strings/ctype-big5.c	2005-09-11 02:27:08 +04:00
@@ -395,10 +395,12 @@
   const char *end;
   char *min_org=min_str;
   char *min_end=min_str+res_length;
+  uint orig_ptr_length= ptr_length;
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
 
   if (charlen < ptr_length)
     ptr_length= charlen;
+  orig_ptr_length-= ptr_length;
   end= ptr + ptr_length;
 
   for (; ptr != end && min_str != min_end ; ptr++)
@@ -413,6 +415,15 @@
     {
       ptr++;				/* Skip escape */
       *min_str++= *max_str++ = *ptr;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one)		/* '_' in SQL */

--- 1.71/strings/ctype-gbk.c	2005-08-17 12:26:28 +04:00
+++ 1.72/strings/ctype-gbk.c	2005-09-11 02:27:56 +04:00
@@ -2708,11 +2708,13 @@
   const char *end;
   char *min_org=min_str;
   char *min_end=min_str+res_length;
+  uint orig_ptr_length= ptr_length;
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
 
   if (charlen < ptr_length)
     ptr_length= charlen;
   end= ptr + ptr_length;
+  orig_ptr_length-= ptr_length;
 
   for (; ptr != end && min_str != min_end ; ptr++)
   {
@@ -2726,6 +2728,15 @@
     {
       ptr++;				/* Skip escape */
       *min_str++= *max_str++ = *ptr;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one)		/* '_' in SQL */

--- 1.80/strings/ctype-sjis.c	2005-08-17 12:26:28 +04:00
+++ 1.81/strings/ctype-sjis.c	2005-09-11 02:28:38 +04:00
@@ -325,11 +325,13 @@
   const char *end;
   char *min_org=min_str;
   char *min_end=min_str+res_length;
+  uint orig_ptr_length= ptr_length;
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
 
   if (charlen < ptr_length)
     ptr_length= charlen;
   end= ptr + ptr_length;
+  orig_ptr_length-= ptr_length;
 
   while (ptr < end && min_str < min_end) {
     if (ismbchar_sjis(cs, ptr, end)) {
@@ -344,6 +346,15 @@
 	*min_str++ = *max_str++ = *ptr++;
       if (min_str < min_end)
 	*min_str++ = *max_str++ = *ptr++;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one) {		/* '_' in SQL */

--- 1.5/mysql-test/r/ctype_latin1.result	2005-07-21 15:03:15 +04:00
+++ 1.6/mysql-test/r/ctype_latin1.result	2005-09-11 02:29:08 +04:00
@@ -330,3 +330,12 @@
 SELECT '„a' as str;
 str
 „a
+create table t1(f1 char(5), index(f1(3)));
+insert into t1 values('_bcde'),('abc_e');
+select * from t1 where f1 like '\_bcde';
+f1
+_bcde
+select * from t1 where f1 like '#_bcde' escape '#';
+f1
+_bcde
+drop table t1;

--- 1.5/mysql-test/t/ctype_latin1.test	2005-07-28 04:21:40 +04:00
+++ 1.6/mysql-test/t/ctype_latin1.test	2005-09-11 02:29:51 +04:00
@@ -76,4 +76,13 @@
 CREATE TABLE „a (a int);
 SELECT '„a' as str;
 
+#
+# Bug #13046 Escape length was included into key length
+#
+create table t1(f1 char(5), index(f1(3)));
+insert into t1 values('_bcde'),('abc_e');
+select * from t1 where f1 like '\_bcde';
+select * from t1 where f1 like '#_bcde' escape '#';
+drop table t1;
+
 # End of 4.1 tests

--- 1.64/mysql-test/r/ctype_utf8.result	2005-08-31 13:01:25 +04:00
+++ 1.65/mysql-test/r/ctype_utf8.result	2005-09-11 02:29:35 +04:00
@@ -1020,3 +1020,12 @@
 5B
 E880BD
 drop table t1;
+create table t1(f1 char(5) charset utf8, index(f1(3)));
+insert into t1 values('_bcde'),('abc_e');
+select * from t1 where f1 like '\_bcde';
+f1
+_bcde
+select * from t1 where f1 like '#_bcde' escape '#';
+f1
+_bcde
+drop table t1;

--- 1.66/mysql-test/t/ctype_utf8.test	2005-08-31 13:01:19 +04:00
+++ 1.67/mysql-test/t/ctype_utf8.test	2005-09-11 02:30:04 +04:00
@@ -863,4 +863,13 @@
 select hex(a) from t1;
 drop table t1;
 
+#
+# Bug #13046 Escape length was included into key length
+#
+create table t1(f1 char(5) charset utf8, index(f1(3)));
+insert into t1 values('_bcde'),('abc_e');
+select * from t1 where f1 like '\_bcde';
+select * from t1 where f1 like '#_bcde' escape '#';
+drop table t1;
+
 # End of 4.1 tests

--- 1.40/strings/ctype-mb.c	2005-07-26 15:36:27 +04:00
+++ 1.41/strings/ctype-mb.c	2005-09-11 02:28:09 +04:00
@@ -506,11 +506,13 @@
   char *min_org= min_str;
   char *min_end= min_str + res_length;
   char *max_end= max_str + res_length;
+  uint orig_ptr_length= ptr_length;
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
 
   if (charlen < ptr_length)
     ptr_length= charlen;
   end= ptr + ptr_length;
+  orig_ptr_length-= ptr_length;
 
   for (; ptr != end && min_str != min_end ; ptr++)
   {
@@ -518,6 +520,15 @@
     {
       ptr++;					/* Skip escape */
       *min_str++= *max_str++ = *ptr;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one || *ptr == w_many)	/* '_' and '%' in SQL */

--- 1.65/strings/ctype-simple.c	2005-07-26 15:36:29 +04:00
+++ 1.66/strings/ctype-simple.c	2005-09-11 02:28:27 +04:00
@@ -1000,12 +1000,14 @@
   const char *end;
   char *min_org=min_str;
   char *min_end=min_str+res_length;
+  uint orig_ptr_length= ptr_length;
 #ifdef USE_MB
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
   if (charlen < ptr_length)
     ptr_length= charlen;
 #endif
   end= ptr + ptr_length;
+  orig_ptr_length-= ptr_length;
 
   for (; ptr != end && min_str != min_end ; ptr++)
   {
@@ -1013,6 +1015,15 @@
     {
       ptr++;					/* Skip escape */
       *min_str++= *max_str++ = *ptr;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one)				/* '_' in SQL */

--- 1.6/strings/ctype-cp932.c	2005-08-17 12:26:27 +04:00
+++ 1.7/strings/ctype-cp932.c	2005-09-11 02:27:42 +04:00
@@ -325,11 +325,13 @@
   const char *end;
   char *min_org=min_str;
   char *min_end=min_str+res_length;
+  uint orig_ptr_length= ptr_length;
   uint charlen= my_charpos(cs, ptr, ptr+ptr_length, res_length/cs->mbmaxlen);
 
   if (charlen < ptr_length)
     ptr_length= charlen;
   end= ptr + ptr_length;
+  orig_ptr_length-= ptr_length;
 
   while (ptr < end && min_str < min_end) {
     if (ismbchar_cp932(cs, ptr, end)) {
@@ -344,6 +346,15 @@
 	*min_str++ = *max_str++ = *ptr++;
       if (min_str < min_end)
 	*min_str++ = *max_str++ = *ptr++;
+      /*
+        if requested key len < like mask move end further so escape char
+        lenght doesn't included in key length.
+      */
+      if (orig_ptr_length)
+      {
+        orig_ptr_length--;
+        end++;
+      }
       continue;
     }
     if (*ptr == w_one) {		/* '_' in SQL */
Thread
bk commit into 4.1 tree (evgen:1.2417) BUG#13046eugene11 Sep