summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2005-08-16 20:59:18 +0200
committerunknown <andrey@lmy004.>2005-08-16 20:59:18 +0200
commit8fd77a045c3bf4f08e6c9e00f94692690d01b6f5 (patch)
tree2df5b3cb19e5d50b210ce8b97ab4ea481e71929d
parentace647d158219c47914854f22702de348933e5da (diff)
parentc9fe6b9ff9d00cdee7576f8d5de727aa33a2295e (diff)
downloadmariadb-git-8fd77a045c3bf4f08e6c9e00f94692690d01b6f5.tar.gz
Merge lmy004.:/work/mysql-5.0-clean
into lmy004.:/work/mysql-5.0-bug12595
-rw-r--r--mysql-test/r/select.result11
-rw-r--r--mysql-test/t/select.test11
-rw-r--r--sql/item_cmpfunc.cc8
3 files changed, 29 insertions, 1 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index d3409bf8d39..580ccc44a7c 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2739,3 +2739,14 @@ DROP TABLE t1,t2;
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
16 16 2 2
+CREATE TABLE BUG_12595(a varchar(100));
+INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an");
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
+a
+hakan%
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
+ERROR HY000: Incorrect arguments to ESCAPE
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
+a
+ha%an
+DROP TABLE BUG_12595;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 1de0831ad84..e0c4d66633b 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2350,3 +2350,14 @@ DROP TABLE t1,t2;
#
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
+
+#
+# BUG #12595
+#
+CREATE TABLE BUG_12595(a varchar(100));
+INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an");
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*';
+-- error 1210
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**';
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
+DROP TABLE BUG_12595;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 261f719e502..c305196615a 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2792,8 +2792,14 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
{
/* If we are on execution stage */
String *escape_str= escape_item->val_str(&tmp_value1);
+ /* ESCAPE must be 1 char in length.*/
+ if (escape_str && escape_str->numchars() != 1)
+ {
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
+ return TRUE;
+ }
escape= escape_str ? *(escape_str->ptr()) : '\\';
-
+
/*
We could also do boyer-more for non-const items, but as we would have to
recompute the tables for each row it's not worth it.