diff options
-rw-r--r-- | mysql-test/r/func_like.result | 5 | ||||
-rw-r--r-- | mysql-test/t/func_like.test | 10 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 |
3 files changed, 15 insertions, 2 deletions
diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index 0ba8e41f164..ee8f9734754 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -289,3 +289,8 @@ a b c d 3 f_ 1 0 1 3 f\_ 0 1 0 drop table t1; +create table t1 (f int); +insert t1 values (1),(2); +select 1 from (select distinct * from t1) as x where f < (select 1 like 2 escape (3=1)); +1 +drop table t1; diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 5026bb76aa3..bc0000046ef 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -187,7 +187,7 @@ DROP TABLE t1; --echo # # -# Item_func_line::print() +# Item_func_like::print() # create view v1 as select 'foo!' like 'foo!!', 'foo!' like 'foo!!' escape '!'; show create view v1; @@ -207,3 +207,11 @@ insert t1 (a) values ('3 f_'), ('3 f\_'); set sql_mode=default; select * from t1; drop table t1; + +# +# Item_func_like::fix_fields() +# +create table t1 (f int); +insert t1 values (1),(2); +select 1 from (select distinct * from t1) as x where f < (select 1 like 2 escape (3=1)); +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2a0972216f8..d0941ef58c2 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5413,7 +5413,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); if (Item_bool_func2::fix_fields(thd, ref) || - escape_item->fix_fields(thd, &escape_item) || + (!escape_item->fixed && escape_item->fix_fields(thd, &escape_item)) || fix_escape_item(thd, escape_item, &cmp_value1, escape_used_in_parsing, cmp_collation.collation, &escape)) return TRUE; |