summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-12-16 20:12:04 +0100
committerSergei Golubchik <serg@mariadb.org>2020-12-19 11:44:42 +0100
commit6f40d5c8d6bf8742b2450410fc024caf3ac114b4 (patch)
tree3e77a49d940dd389f36c1c1e5866304eb1aa3ae7
parent59211ab7b9fb3c106e805bebd393731f42f95abe (diff)
downloadmariadb-git-6f40d5c8d6bf8742b2450410fc024caf3ac114b4.tar.gz
Item_func_like::walk() was ignoring escape_item
in particular, it caused escape_item->is_expensive() property to be lost instead of being properly propagated up.
-rw-r--r--mysql-test/r/func_like.result5
-rw-r--r--mysql-test/t/func_like.test9
-rw-r--r--sql/item_cmpfunc.h7
3 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result
index dcbcd2591ac..5bcd98ca238 100644
--- a/mysql-test/r/func_like.result
+++ b/mysql-test/r/func_like.result
@@ -302,3 +302,8 @@ select * from (select 1 like 2 escape (1 in (select 1 from t1))) x;
1 like 2 escape (1 in (select 1 from t1))
0
drop table t1;
+create table t1 (f int);
+insert t1 values (1),(2);
+create view v1 as select * from t1 where (1 like 2 escape (3 in (('h', 'b') in (select 'k', 'k' union select 'g', 'j'))) and f >= 0);
+drop view v1;
+drop table t1;
diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test
index 465d1df1380..c7a59a6fcbd 100644
--- a/mysql-test/t/func_like.test
+++ b/mysql-test/t/func_like.test
@@ -225,3 +225,12 @@ insert into t1 values(1);
update (select 1 like 2 escape (1 in (select 1 from t1))) x, t1 as d set d.f1 = 1;
select * from (select 1 like 2 escape (1 in (select 1 from t1))) x;
drop table t1;
+
+#
+# Item_func_like::walk
+#
+create table t1 (f int);
+insert t1 values (1),(2);
+create view v1 as select * from t1 where (1 like 2 escape (3 in (('h', 'b') in (select 'k', 'k' union select 'g', 'j'))) and f >= 0);
+drop view v1;
+drop table t1;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 22736339bf6..26469d88929 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -2013,6 +2013,13 @@ public:
return this;
}
+ bool walk(Item_processor processor, bool walk_subquery, void *arg)
+ {
+ return walk_args(processor, walk_subquery, arg)
+ || escape_item->walk(processor, walk_subquery, arg)
+ || (this->*processor)(arg);
+ }
+
bool find_selective_predicates_list_processor(void *arg);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)