Commit 7ff0c397 authored by gluh@gluh.mysql.r18.ru's avatar gluh@gluh.mysql.r18.ru

Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-4.0

into gluh.mysql.r18.ru:/home/gluh/MySQL-BUGS/mysql-4.0
parents e05f79da 23535cce
...@@ -80,3 +80,21 @@ NULL ...@@ -80,3 +80,21 @@ NULL
select b from t1 having binary b like ''; select b from t1 having binary b like '';
b b
drop table t1; drop table t1;
create table t1( firstname char(20), lastname char(20));
insert into t1 values ("john","doe"),("John","Doe");
select * from t1 where firstname='john' and firstname like binary 'john';
firstname lastname
john doe
select * from t1 where firstname='john' and binary 'john' = firstname;
firstname lastname
john doe
select * from t1 where firstname='john' and firstname = binary 'john';
firstname lastname
john doe
select * from t1 where firstname='John' and firstname like binary 'john';
firstname lastname
john doe
select * from t1 where firstname='john' and firstname like binary 'John';
firstname lastname
John Doe
drop table t1;
...@@ -49,3 +49,16 @@ select b from t1 where binary b like ''; ...@@ -49,3 +49,16 @@ select b from t1 where binary b like '';
select b from t1 group by binary b like ''; select b from t1 group by binary b like '';
select b from t1 having binary b like ''; select b from t1 having binary b like '';
drop table t1; drop table t1;
#
# Bug5134: WHERE x = 'bar' AND x LIKE BINARY 'bar' returns wrong results
#
create table t1( firstname char(20), lastname char(20));
insert into t1 values ("john","doe"),("John","Doe");
select * from t1 where firstname='john' and firstname like binary 'john';
select * from t1 where firstname='john' and binary 'john' = firstname;
select * from t1 where firstname='john' and firstname = binary 'john';
select * from t1 where firstname='John' and firstname like binary 'john';
select * from t1 where firstname='john' and firstname like binary 'John';
drop table t1;
...@@ -3371,7 +3371,10 @@ change_cond_ref_to_const(I_List<COND_CMP> *save_list,Item *and_father, ...@@ -3371,7 +3371,10 @@ change_cond_ref_to_const(I_List<COND_CMP> *save_list,Item *and_father,
Item *right_item= func->arguments()[1]; Item *right_item= func->arguments()[1];
Item_func::Functype functype= func->functype(); Item_func::Functype functype= func->functype();
if (right_item->eq(field,0) && left_item != value) if (right_item->eq(field,0) && left_item != value &&
(left_item->result_type() != STRING_RESULT ||
value->result_type() != STRING_RESULT ||
left_item->binary == value->binary))
{ {
Item *tmp=value->new_item(); Item *tmp=value->new_item();
if (tmp) if (tmp)
...@@ -3390,7 +3393,10 @@ change_cond_ref_to_const(I_List<COND_CMP> *save_list,Item *and_father, ...@@ -3390,7 +3393,10 @@ change_cond_ref_to_const(I_List<COND_CMP> *save_list,Item *and_father,
func->arguments()[1]->result_type())); func->arguments()[1]->result_type()));
} }
} }
else if (left_item->eq(field,0) && right_item != value) else if (left_item->eq(field,0) && right_item != value &&
(right_item->result_type() != STRING_RESULT ||
value->result_type() != STRING_RESULT ||
right_item->binary == value->binary))
{ {
Item *tmp=value->new_item(); Item *tmp=value->new_item();
if (tmp) if (tmp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment