List:Internals« Previous MessageNext Message »
From:ahristov Date:August 24 2005 12:27pm
Subject:bk commit into 5.0 tree (andrey:1.1908)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of andrey. When andrey 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.1908 05/08/24 12:27:30 andrey@lmy004. +6 -0
  merge

  mysql-test/t/select.test
    1.66 05/08/24 12:27:25 andrey@lmy004. +0 -1
    manual merge

  mysql-test/r/select.result
    1.81 05/08/24 12:27:25 andrey@lmy004. +0 -0
    manual merge

  sql/sql_yacc.yy
    1.417 05/08/24 12:24:42 andrey@lmy004. +0 -0
    Auto merged

  sql/sql_lex.cc
    1.165 05/08/24 12:24:42 andrey@lmy004. +0 -0
    Auto merged

  sql/item_cmpfunc.h
    1.108 05/08/24 12:24:42 andrey@lmy004. +0 -0
    Auto merged

  sql/item_cmpfunc.cc
    1.171 05/08/24 12:24:42 andrey@lmy004. +0 -0
    Auto merged

# 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:	andrey
# Host:	lmy004.
# Root:	/work/mysql-5.0-bug12595-2/RESYNC

--- 1.170/sql/item_cmpfunc.cc	2005-08-22 00:13:18 +02:00
+++ 1.171/sql/item_cmpfunc.cc	2005-08-24 12:24:42 +02:00
@@ -2811,6 +2811,11 @@
   {
     /* If we are on execution stage */
     String *escape_str= escape_item->val_str(&tmp_value1);
+    if (escape_str && escape_used_in_parsing && escape_str->numchars()
!= 1)
+    {
+       my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
+       return TRUE;
+    }
     escape= escape_str ? *(escape_str->ptr()) : '\\';
 
     /*

--- 1.107/sql/item_cmpfunc.h	2005-08-18 11:07:10 +02:00
+++ 1.108/sql/item_cmpfunc.h	2005-08-24 12:24:42 +02:00
@@ -963,13 +963,15 @@
   enum { alphabet_size = 256 };
 
   Item *escape_item;
+  bool escape_used_in_parsing;
 
 public:
   char escape;
 
-  Item_func_like(Item *a,Item *b, Item *escape_arg)
+  Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used)
     :Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0), 
-     bmGs(0), bmBc(0), escape_item(escape_arg) {}
+     bmGs(0), bmBc(0), escape_item(escape_arg),
+     escape_used_in_parsing(escape_used) {}
   longlong val_int();
   enum Functype functype() const { return LIKE_FUNC; }
   optimize_type select_optimize() const;

--- 1.164/sql/sql_lex.cc	2005-08-22 00:13:18 +02:00
+++ 1.165/sql/sql_lex.cc	2005-08-24 12:24:42 +02:00
@@ -173,6 +173,7 @@
   lex->spcont= NULL;
   lex->proc_list.first= 0;
   lex->query_tables_own_last= 0;
+  lex->escape_used= FALSE;
 
   if (lex->sroutines.records)
     my_hash_reset(&lex->sroutines);

--- 1.416/sql/sql_yacc.yy	2005-08-20 12:38:07 +02:00
+++ 1.417/sql/sql_yacc.yy	2005-08-24 12:24:42 +02:00
@@ -4263,9 +4263,9 @@
 	  { $$= new Item_func_eq(new Item_func_soundex($1),
 				 new Item_func_soundex($4)); }
 	| bit_expr LIKE simple_expr opt_escape
-          { $$= new Item_func_like($1,$3,$4); }
+          { $$= new Item_func_like($1,$3,$4,Lex->escape_used); }
 	| bit_expr not LIKE simple_expr opt_escape
-          { $$= new Item_func_not(new Item_func_like($1,$4,$5)); }
+          { $$= new Item_func_not(new Item_func_like($1,$4,$5,Lex->escape_used)); }
 	| bit_expr REGEXP bit_expr	{ $$= new Item_func_regex($1,$3); }
 	| bit_expr not REGEXP bit_expr
           { $$= negate_expression(YYTHD, new Item_func_regex($1,$4)); }
@@ -5594,10 +5594,14 @@
 	;
 
 opt_escape:
-	ESCAPE_SYM simple_expr { $$= $2; }
+	ESCAPE_SYM simple_expr
+          {
+            Lex->escape_used= TRUE;
+            $$= $2;
+          }
 	| /* empty */
           {
-
+            Lex->escape_used= FALSE;
             $$= ((YYTHD->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ?
 		 new Item_string("", 0, &my_charset_latin1) :
                  new Item_string("\\", 1, &my_charset_latin1));

--- 1.80/mysql-test/r/select.result	2005-08-22 13:46:06 +02:00
+++ 1.81/mysql-test/r/select.result	2005-08-24 12:27:25 +02:00
@@ -2756,6 +2756,43 @@
 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
+SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='';
+show local variables like 'SQL_MODE';
+Variable_name	Value
+sql_mode	
+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 'hakan**%' ESCAPE '';
+ERROR HY000: Incorrect arguments to ESCAPE
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
+a
+ha%an
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\';
+a
+ha%an
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '\|';
+a
+ha%an
+SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
+show local variables like 'SQL_MODE';
+Variable_name	Value
+sql_mode	NO_BACKSLASH_ESCAPES
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
+a
+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 'hakan\n%' ESCAPE '\n';
+ERROR HY000: Incorrect arguments to ESCAPE
+SET @@SQL_MODE=@OLD_SQL_MODE;
+DROP TABLE BUG_12595;
 create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
 create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY
(f3,f4));
 insert into t1 values (" 2", 2);

--- 1.65/mysql-test/t/select.test	2005-08-22 13:46:06 +02:00
+++ 1.66/mysql-test/t/select.test	2005-08-24 12:27:25 +02:00
@@ -2350,6 +2350,34 @@
 select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
 
 #
+# BUG #12595
+#
+SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='';
+show local variables like 'SQL_MODE';
+
+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 '**';
+-- error 1210
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '';
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%';
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha\%an' ESCAPE '\\';
+SELECT * FROM BUG_12595 WHERE a LIKE 'ha|%an' ESCAPE '\|';
+
+SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
+show local variables like 'SQL_MODE';
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%';
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan|%' ESCAPE '|';
+-- error 1210
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\%' ESCAPE '\\';
+-- error 1210
+SELECT * FROM BUG_12595 WHERE a LIKE 'hakan\n%' ESCAPE '\n';
+
+SET @@SQL_MODE=@OLD_SQL_MODE;
+DROP TABLE BUG_12595;
+#
 # Bug #11398 Bug in field_conv() results in wrong result of join with index
 #
 create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null);
Thread
bk commit into 5.0 tree (andrey:1.1908)ahristov24 Aug