List:Internals« Previous MessageNext Message »
From:bar Date:September 6 2005 1:16pm
Subject:bk commit into 4.1 tree (bar:1.2401) BUG#12611
View as plain text  
Below is the list of changes that have just been committed into a local
4.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.2401 05/09/06 16:16:10 bar@stripped +3 -0
  func_like.result, func_like.test:
    adding test case.
  item_cmpfunc.cc:
    Bug#12611
    ESCAPE + LIKE do not work when the escape char is a multibyte one
    Additional fix for 8bit character sets:
    escape character must be converted into
    operation character set.

  mysql-test/r/func_like.result
    1.15 05/09/06 16:15:43 bar@stripped +7 -0
    adding test case.

  mysql-test/t/func_like.test
    1.16 05/09/06 16:15:38 bar@stripped +17 -0
    adding test case.

  sql/item_cmpfunc.cc
    1.194 05/09/06 16:14:56 bar@stripped +18 -1
    Bug#12611
    ESCAPE + LIKE do not work when the escape char is a multibyte one
    Additional fix for 8bit character sets:
    escape character must be converted into
    operation character set.

# 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.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-4.1.b12611

--- 1.193/sql/item_cmpfunc.cc	2005-08-31 14:00:23 +05:00
+++ 1.194/sql/item_cmpfunc.cc	2005-09-06 16:14:56 +05:00
@@ -2307,7 +2307,24 @@
       }
       else
       {
-        escape= *(escape_str->ptr());
+        /*
+          In the case of 8bit character set, we pass native
+          code instead of Unicode code as "escape" argument.
+          Convert to "cs" if charset of escape differs.
+        */
+        uint32 unused;
+        if (escape_str->needs_conversion(escape_str->length(),
+                                         escape_str->charset(), cs, &unused))
+        {
+          char ch;
+          uint errors;
+          uint32 cnvlen= copy_and_convert(&ch, 1, cs, escape_str->ptr(),
+                                          escape_str->length(),
+                                          escape_str->charset(), &errors);
+          escape= cnvlen ? ch : '\\';
+        }
+        else
+          escape= *(escape_str->ptr());
       }
     }
     else

--- 1.14/mysql-test/r/func_like.result	2004-08-18 12:10:17 +05:00
+++ 1.15/mysql-test/r/func_like.result	2005-09-06 16:15:43 +05:00
@@ -158,3 +158,10 @@
 select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin;
 _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin
 1
+set names koi8r;
+select 'andre%' like 'andreÊ%' escape 'Ê';
+'andre%' like 'andreÊ%' escape 'Ê'
+1
+select _cp1251'andre%' like convert('andreÊ%' using cp1251)  escape 'Ê';
+_cp1251'andre%' like convert('andreÊ%' using cp1251)  escape 'Ê'
+1

--- 1.15/mysql-test/t/func_like.test	2005-07-28 05:21:42 +05:00
+++ 1.16/mysql-test/t/func_like.test	2005-09-06 16:15:38 +05:00
@@ -96,4 +96,21 @@
 #
 select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin;
 
+#
+# Check 8bit escape character
+#
+set names koi8r;
+select 'andre%' like 'andreÊ%' escape 'Ê';
+
+# Check 8bit escape character with charset conversion:
+# For "a LIKE b ESCAPE c" expressions,
+# escape character is converted into the operation character set,
+# which is result of aggregation  of character sets of "a" and "b".
+# "c" itself doesn't take part in aggregation, because its collation
+# doesn't matter, escape character is always compared binary.
+# In the example below, escape character is converted from koi8r into cp1251:
+#
+select _cp1251'andre%' like convert('andreÊ%' using cp1251)  escape 'Ê';
+
+#
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (bar:1.2401) BUG#12611bar6 Sep