Commit 256185c5 authored by Sergei Golubchik's avatar Sergei Golubchik

lp:736370 Datetime functions in subquery context cause wrong result and bogus...

lp:736370 Datetime functions in subquery context cause wrong result and bogus warnings in mysql-5.1-micro

Don't cache temporal value in an Item_string, it is compared differently.
parent d72f05fc
...@@ -1478,7 +1478,7 @@ convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetim ...@@ -1478,7 +1478,7 @@ convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetim
NULL NULL
create table t1 (f1 integer, f2 date); create table t1 (f1 integer, f2 date);
insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'); insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05');
select * from t1 where (f1, f2) in (select f1, makedate(2011 , 125) from t1); select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
f1 f2 f1 f2
1 2011-05-05 1 2011-05-05
2 2011-05-05 2 2011-05-05
......
...@@ -922,7 +922,7 @@ select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as ...@@ -922,7 +922,7 @@ select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as
# #
create table t1 (f1 integer, f2 date); create table t1 (f1 integer, f2 date);
insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'); insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05');
select * from t1 where (f1, f2) in (select f1, makedate(2011 , 125) from t1); select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
drop table t1; drop table t1;
# #
......
...@@ -6880,11 +6880,12 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) ...@@ -6880,11 +6880,12 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
Item *new_item= NULL; Item *new_item= NULL;
if (item->basic_const_item()) if (item->basic_const_item())
return; // Can't be better return; // Can't be better
Item_result res_type=item_cmp_type(comp_item->result_type(), Item_result res_type=item_cmp_type(comp_item->cmp_type(), item->cmp_type());
item->result_type());
char *name=item->name; // Alloced by sql_alloc char *name=item->name; // Alloced by sql_alloc
switch (res_type) { switch (res_type) {
case TIME_RESULT: // will be handled by get_datetime_value()
break;
case STRING_RESULT: case STRING_RESULT:
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
......
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