Commit 340a29ec authored by Sergei Golubchik's avatar Sergei Golubchik

lp:737450 Second Assertion `item->null_value' failed in 5.1-micro

implement Item_func_min_max::get_date()
parent 79f6e6f6
......@@ -1527,3 +1527,9 @@ NULL
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
drop table t1;
create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
select least(greatest(f3, f2, f4), f5) from t1;
least(greatest(f3, f2, f4), f5)
0000-00-00 00:00:00
drop table t1;
......@@ -960,3 +960,11 @@ select timestampadd(week, 1, f1) from t1;
select timestampadd(week, 1, date("0000-00-00"));
drop table t1;
#
# lp:737450 Second Assertion `item->null_value' failed in 5.1-micro
#
create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
select least(greatest(f3, f2, f4), f5) from t1;
drop table t1;
......@@ -2259,9 +2259,6 @@ void Item_func_min_max::fix_length_and_dec()
/*
Compare item arguments in the DATETIME context.
SYNOPSIS
cmp_datetimes()
DESCRIPTION
Compare item arguments as DATETIME values and return the index of the
least/greatest argument in the arguments array.
......@@ -2273,9 +2270,10 @@ void Item_func_min_max::fix_length_and_dec()
0 Otherwise
*/
bool Item_func_min_max::cmp_datetimes(MYSQL_TIME *ltime)
bool Item_func_min_max::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
longlong UNINIT_VAR(min_max);
DBUG_ASSERT(fixed == 1);
for (uint i=0; i < arg_count ; i++)
{
......@@ -2309,7 +2307,7 @@ String *Item_func_min_max::val_str(String *str)
if (compare_as_dates)
{
MYSQL_TIME ltime;
if (cmp_datetimes(&ltime))
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
char buf[MAX_DATE_STRING_REP_LENGTH];
......@@ -2383,7 +2381,7 @@ double Item_func_min_max::val_real()
if (compare_as_dates)
{
MYSQL_TIME ltime;
if (cmp_datetimes(&ltime))
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
return TIME_to_double(&ltime);
......@@ -2412,7 +2410,7 @@ longlong Item_func_min_max::val_int()
if (compare_as_dates)
{
MYSQL_TIME ltime;
if (cmp_datetimes(&ltime))
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
return TIME_to_ulonglong(&ltime);
......@@ -2442,7 +2440,7 @@ my_decimal *Item_func_min_max::val_decimal(my_decimal *dec)
if (compare_as_dates)
{
MYSQL_TIME ltime;
if (cmp_datetimes(&ltime))
if (get_date(&ltime, TIME_FUZZY_DATE))
return 0;
return date2my_decimal(&ltime, dec);
......
......@@ -769,9 +769,9 @@ class Item_func_min_max :public Item_func
longlong val_int();
String *val_str(String *);
my_decimal *val_decimal(my_decimal *);
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
void fix_length_and_dec();
enum Item_result result_type () const { return cmp_type; }
bool cmp_datetimes(MYSQL_TIME *ltime);
enum_field_types field_type() const { return cached_field_type; }
};
......
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