mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix bug#11325 Wrong date comparison in views
Wrong comparing method were choosen which results in false comparison. Make Item_bool_func2::fix_length_and_dec() to get type and field from real_item() to make REF_ITEM pass the check. sql/item_cmpfunc.cc: Fix bug#11325 Wrong date comparison in views mysql-test/t/view.test: Test case for bug#11325 Wrong date comparison in views. mysql-test/r/view.result: Test case for bug#11325 Wrong date comparison in views.
This commit is contained in:
@ -1831,3 +1831,14 @@ select * from v1;
|
|||||||
t
|
t
|
||||||
01:00
|
01:00
|
||||||
drop view v1;
|
drop view v1;
|
||||||
|
create table t1 (f1 date);
|
||||||
|
insert into t1 values ('2005-01-01'),('2005-02-02');
|
||||||
|
create view v1 as select * from t1;
|
||||||
|
select * from v1 where f1='2005.02.02';
|
||||||
|
f1
|
||||||
|
2005-02-02
|
||||||
|
select * from v1 where '2005.02.02'=f1;
|
||||||
|
f1
|
||||||
|
2005-02-02
|
||||||
|
drop view v1;
|
||||||
|
drop table t1;
|
||||||
|
@ -1673,3 +1673,14 @@ create view v1(k, K) as select 1,2;
|
|||||||
create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
|
create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
|
||||||
select * from v1;
|
select * from v1;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# bug #11325 Wrong date comparison in views
|
||||||
|
#
|
||||||
|
create table t1 (f1 date);
|
||||||
|
insert into t1 values ('2005-01-01'),('2005-02-02');
|
||||||
|
create view v1 as select * from t1;
|
||||||
|
select * from v1 where f1='2005.02.02';
|
||||||
|
select * from v1 where '2005.02.02'=f1;
|
||||||
|
drop view v1;
|
||||||
|
drop table t1;
|
||||||
|
@ -238,9 +238,10 @@ void Item_bool_func2::fix_length_and_dec()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0]->type() == FIELD_ITEM)
|
Item *real_item= args[0]->real_item();
|
||||||
|
if (real_item->type() == FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Field *field=((Item_field*) args[0])->field;
|
Field *field= ((Item_field*) real_item)->field;
|
||||||
if (field->can_be_compared_as_longlong())
|
if (field->can_be_compared_as_longlong())
|
||||||
{
|
{
|
||||||
if (convert_constant_item(thd, field,&args[1]))
|
if (convert_constant_item(thd, field,&args[1]))
|
||||||
@ -251,9 +252,10 @@ void Item_bool_func2::fix_length_and_dec()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[1]->type() == FIELD_ITEM /* && !args[1]->const_item() */)
|
real_item= args[1]->real_item();
|
||||||
|
if (real_item->type() == FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Field *field=((Item_field*) args[1])->field;
|
Field *field= ((Item_field*) real_item)->field;
|
||||||
if (field->can_be_compared_as_longlong())
|
if (field->can_be_compared_as_longlong())
|
||||||
{
|
{
|
||||||
if (convert_constant_item(thd, field,&args[0]))
|
if (convert_constant_item(thd, field,&args[0]))
|
||||||
|
Reference in New Issue
Block a user