Skip to content

Commit 232dc91

Browse files
committed
bugfix: Item_func_like::print() was losing ESCAPE clause
1 parent 660355c commit 232dc91

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

mysql-test/r/func_like.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,11 @@ DROP TABLE t1;
254254
#
255255
# End of 10.1 tests
256256
#
257+
create view v1 as select 'foo!' like 'foo!!', 'foo!' like 'foo!!' escape '!';
258+
show create view v1;
259+
View Create View character_set_client collation_connection
260+
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select ('foo!' like 'foo!!') AS `'foo!' like 'foo!!'`,('foo!' like 'foo!!' escape '!') AS `'foo!' like 'foo!!' escape '!'` koi8r koi8r_general_ci
261+
select * from v1;
262+
'foo!' like 'foo!!' 'foo!' like 'foo!!' escape '!'
263+
0 1
264+
drop view v1;

mysql-test/t/func_like.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,11 @@ DROP TABLE t1;
185185
--echo #
186186
--echo # End of 10.1 tests
187187
--echo #
188+
189+
#
190+
# Item_func_line::print()
191+
#
192+
create view v1 as select 'foo!' like 'foo!!', 'foo!' like 'foo!!' escape '!';
193+
show create view v1;
194+
select * from v1;
195+
drop view v1;

sql/item_cmpfunc.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5076,6 +5076,22 @@ bool Item_bool_func2::count_sargable_conds(void *arg)
50765076
return 0;
50775077
}
50785078

5079+
void Item_func_like::print(String *str, enum_query_type query_type)
5080+
{
5081+
str->append('(');
5082+
args[0]->print(str, query_type);
5083+
str->append(' ');
5084+
str->append(func_name());
5085+
str->append(' ');
5086+
args[1]->print(str, query_type);
5087+
if (escape_used_in_parsing)
5088+
{
5089+
str->append(STRING_WITH_LEN(" escape "));
5090+
escape_item->print(str, query_type);
5091+
}
5092+
str->append(')');
5093+
}
5094+
50795095

50805096
longlong Item_func_like::val_int()
50815097
{

sql/item_cmpfunc.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,10 +1868,7 @@ class Item_func_like :public Item_bool_func2
18681868
escape_used_in_parsing(escape_used), use_sampling(0) {}
18691869
longlong val_int();
18701870
enum Functype functype() const { return LIKE_FUNC; }
1871-
void print(String *str, enum_query_type query_type)
1872-
{
1873-
Item_func::print_op(str, query_type);
1874-
}
1871+
void print(String *str, enum_query_type query_type);
18751872
CHARSET_INFO *compare_collation() const
18761873
{ return cmp_collation.collation; }
18771874
cond_result eq_cmp_result() const

0 commit comments

Comments
 (0)