summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-03-17 18:19:47 +0100
committerSergei Golubchik <sergii@pisem.net>2011-03-17 18:19:47 +0100
commit256185c50d5f8ccfa05abf07129fc7bbc7a15991 (patch)
tree1f89523b951f2f1936d11f474adfe9e36d167922
parentd72f05fc5b330c3507b44538d5e5559a2c70288a (diff)
downloadmariadb-git-256185c50d5f8ccfa05abf07129fc7bbc7a15991.tar.gz
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.
-rw-r--r--mysql-test/r/func_time.result2
-rw-r--r--mysql-test/t/func_time.test2
-rw-r--r--sql/item.cc5
3 files changed, 5 insertions, 4 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 5ee050e5cba..964828c6c7e 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1478,7 +1478,7 @@ convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetim
NULL
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');
-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
1 2011-05-05
2 2011-05-05
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 646b55ad25a..669da515e49 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -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);
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;
#
diff --git a/sql/item.cc b/sql/item.cc
index 7f7e39c9dac..92df6bb0953 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -6880,11 +6880,12 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
Item *new_item= NULL;
if (item->basic_const_item())
return; // Can't be better
- Item_result res_type=item_cmp_type(comp_item->result_type(),
- item->result_type());
+ Item_result res_type=item_cmp_type(comp_item->cmp_type(), item->cmp_type());
char *name=item->name; // Alloced by sql_alloc
switch (res_type) {
+ case TIME_RESULT: // will be handled by get_datetime_value()
+ break;
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];