Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix the text field in subquery does no… #1390

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions mysql-test/suite/tianmu/r/issue1385.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DROP DATABASE IF EXISTS issue1385_test;
CREATE DATABASE issue1385_test;
USE issue1385_test;
create table ttt(name text);
insert into ttt values('XXXXX');
insert into ttt values('yyyyy');
select * from (select concat(ifnull(name,'')) as c1 from ttt) as x where x.c1 like '%XXXX%';
c1
XXXXX
select * from (select ifnull(name,'') as c1 from ttt) as x where x.c1 like '%XXXX%';
c1
XXXXX
select * from (select concat(name,'') as c1 from ttt) as x where x.c1 like '%XXXX%';
c1
XXXXX
drop table ttt;
DROP DATABASE issue1385_test;
22 changes: 22 additions & 0 deletions mysql-test/suite/tianmu/t/issue1385.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--source include/have_tianmu.inc

--disable_warnings
DROP DATABASE IF EXISTS issue1385_test;
--enable_warnings

CREATE DATABASE issue1385_test;

USE issue1385_test;

create table ttt(name text);

insert into ttt values('XXXXX');
insert into ttt values('yyyyy');

select * from (select concat(ifnull(name,'')) as c1 from ttt) as x where x.c1 like '%XXXX%';
select * from (select ifnull(name,'') as c1 from ttt) as x where x.c1 like '%XXXX%';
select * from (select concat(name,'') as c1 from ttt) as x where x.c1 like '%XXXX%';

drop table ttt;

DROP DATABASE issue1385_test;
3 changes: 3 additions & 0 deletions storage/tianmu/core/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,9 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TabID &tmp_table,
if ((op == common::Operator::O_LIKE || op == common::Operator::O_NOT_LIKE) &&
!(an_arg->field_type() == MYSQL_TYPE_VARCHAR || an_arg->field_type() == MYSQL_TYPE_STRING ||
an_arg->field_type() == MYSQL_TYPE_VAR_STRING || an_arg->field_type() == MYSQL_TYPE_BLOB ||
// for issue 1385: feature: The data type of the field is the text,
// the subquery does not support using the like fuzzy query.
an_arg->field_type() == MYSQL_TYPE_MEDIUM_BLOB || an_arg->field_type() == MYSQL_TYPE_LONG_BLOB ||
an_arg->field_type() == MYSQL_TYPE_NULL)) { // issue: #763, Argument of LIKE is NULL
return CondID(-1); // Argument of LIKE is not a string or null, return to MySQL.
}
Expand Down