Commit 1a963822 authored by Sergei Golubchik's avatar Sergei Golubchik

lp:737104 Crash in DTCollation::set in 5.1-micro

and a different fix for lp:736370

cache temporal expression in Item_cache_int, not in Item_string.
invoke get_datetime_value() to create a correct Item_cache_int.
Implement Item_cache_int::clone, as it's a proper constant
parent 684405e7
......@@ -1497,3 +1497,7 @@ drop table t1;
select now() > coalesce(time('21:43:24'), date('2010-05-03'));
now() > coalesce(time('21:43:24'), date('2010-05-03'))
1
create table t1 (f1 timestamp);
select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
f1
drop table t1;
......@@ -926,7 +926,7 @@ select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
drop table t1;
#
# lp:736791 Crash in make_truncated_value_warningwith LEAST()/GREATEST/COALESCE
# lp:736791 Crash in make_truncated_value_warning with LEAST()/GREATEST/COALESCE
#
create table t1 (f1 timestamp);
insert into t1 values ('0000-00-00 00:00:00');
......@@ -938,3 +938,9 @@ drop table t1;
#
select now() > coalesce(time('21:43:24'), date('2010-05-03'));
#
# lp:737104 Crash in DTCollation::set in 5.1-micro
#
create table t1 (f1 timestamp);
select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
drop table t1;
......@@ -6884,8 +6884,15 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
char *name=item->name; // Alloced by sql_alloc
switch (res_type) {
case TIME_RESULT: // will be handled by get_datetime_value()
case TIME_RESULT:
{
bool is_null;
Item **ref_copy= ref;
get_datetime_value(thd, &ref_copy, &new_item, comp_item, &is_null);
if (is_null)
new_item= new Item_null(name);
break;
}
case STRING_RESULT:
{
char buff[MAX_FIELD_WIDTH];
......
......@@ -3035,6 +3035,12 @@ public:
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return INT_RESULT; }
bool cache_value();
Item *clone_item()
{
Item_cache_int *item= new Item_cache_int(cached_field_type);
item->store(this, value);
return item;
}
};
......
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