Commit b948b5f7 authored by Sergei Golubchik's avatar Sergei Golubchik

bugfix: Item_func_min_max stored thd internally

It was used for get_datetime_value() and for thd->is_error().

But in fact, get_datetime_value() never used thd argument, because the
cache ptr argument was NULL. And thd->is_error() check was not needed
at that place at all.
parent 798fcb54
......@@ -44,3 +44,18 @@ Warning 1292 Incorrect datetime value: '1'
Warning 1292 Incorrect datetime value: '1'
Warning 1292 Incorrect datetime value: '2'
drop table t1;
create table t1 (a datetime,
b datetime as (least(a,1)) # Item_func_min_max::get_date
);
insert t1 (a) values ('2010-10-10 10:10:10');
select * from t1;
a b
2010-10-10 10:10:10 0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '1'
select * from t1;
a b
2010-10-10 10:10:10 0000-00-00 00:00:00
Warnings:
Warning 1292 Incorrect datetime value: '1'
drop table t1;
......@@ -22,3 +22,14 @@ disconnect con1;
connection default;
select * from t1;
drop table t1;
connect con1, localhost, root;
create table t1 (a datetime,
b datetime as (least(a,1)) # Item_func_min_max::get_date
);
insert t1 (a) values ('2010-10-10 10:10:10');
select * from t1;
disconnect con1;
connection default;
select * from t1;
drop table t1;
......@@ -2856,7 +2856,6 @@ void Item_func_min_max::fix_length_and_dec()
decimals=0;
max_length=0;
maybe_null=0;
thd= current_thd;
cmp_type=args[0]->result_type();
for (uint i=0 ; i < arg_count ; i++)
......@@ -2929,13 +2928,11 @@ bool Item_func_min_max::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{
Item **arg= args + i;
bool is_null;
longlong res= get_datetime_value(thd, &arg, 0, compare_as_dates, &is_null);
longlong res= get_datetime_value(0, &arg, 0, compare_as_dates, &is_null);
/* Check if we need to stop (because of error or KILL) and stop the loop */
if (thd->is_error() || args[i]->null_value)
{
if (args[i]->null_value)
return (null_value= 1);
}
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
min_max= res;
......
......@@ -1068,7 +1068,6 @@ class Item_func_min_max :public Item_func
int cmp_sign;
/* An item used for issuing warnings while string to DATETIME conversion. */
Item *compare_as_dates;
THD *thd;
protected:
enum_field_types cached_field_type;
public:
......
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