Backport of fix to bug #33629 into mysql-next-mr-bugfixing.
Bug #33629: last_day function can return null, but has 'not null' flag set for result LAST_DAY and MAKEDATE functions are documented as returning NULL value, but actually they was implemented as returning NOT NULL typed values. That caused a confusing error "ERROR 1048 (23000): Column '...' cannot be null" on queries like: SELECT 1 FROM (SELECT LAST_DAY('0')) a;
This commit is contained in:
parent
9824a0ca27
commit
bc7c439e6b
@ -194,7 +194,7 @@ date("1997-12-31 23:59:59.000001") as f8,
|
|||||||
time("1997-12-31 23:59:59.000001") as f9;
|
time("1997-12-31 23:59:59.000001") as f9;
|
||||||
describe t1;
|
describe t1;
|
||||||
Field Type Null Key Default Extra
|
Field Type Null Key Default Extra
|
||||||
f1 date NO 0000-00-00
|
f1 date YES NULL
|
||||||
f2 datetime YES NULL
|
f2 datetime YES NULL
|
||||||
f3 time YES NULL
|
f3 time YES NULL
|
||||||
f4 time YES NULL
|
f4 time YES NULL
|
||||||
|
@ -814,7 +814,7 @@ create table t1 select last_day('2000-02-05') as a,
|
|||||||
from_days(to_days("960101")) as b;
|
from_days(to_days("960101")) as b;
|
||||||
describe t1;
|
describe t1;
|
||||||
Field Type Null Key Default Extra
|
Field Type Null Key Default Extra
|
||||||
a date NO 0000-00-00
|
a date YES NULL
|
||||||
b date YES NULL
|
b date YES NULL
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b
|
a b
|
||||||
|
@ -276,3 +276,25 @@ a
|
|||||||
0000-00-01
|
0000-00-01
|
||||||
drop table t1;
|
drop table t1;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
|
#
|
||||||
|
# Bug #33629: last_day function can return null, but has 'not null'
|
||||||
|
# flag set for result
|
||||||
|
#
|
||||||
|
SELECT 1 FROM (SELECT LAST_DAY('0')) a;
|
||||||
|
1
|
||||||
|
1
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Incorrect datetime value: '0'
|
||||||
|
SELECT 1 FROM (SELECT MAKEDATE(2011,0)) a;
|
||||||
|
1
|
||||||
|
1
|
||||||
|
CREATE TABLE t1 AS
|
||||||
|
SELECT LAST_DAY('1970-01-01') AS f1,
|
||||||
|
MAKEDATE(1970, 1) AS f2;
|
||||||
|
DESCRIBE t1;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 date YES NULL
|
||||||
|
f2 date YES NULL
|
||||||
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
End of 6.0 tests
|
||||||
|
@ -247,3 +247,21 @@ select * from t1 where a between '0000-00-01' and '0000-00-02';
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug #33629: last_day function can return null, but has 'not null'
|
||||||
|
--echo # flag set for result
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT 1 FROM (SELECT LAST_DAY('0')) a;
|
||||||
|
SELECT 1 FROM (SELECT MAKEDATE(2011,0)) a;
|
||||||
|
|
||||||
|
CREATE TABLE t1 AS
|
||||||
|
SELECT LAST_DAY('1970-01-01') AS f1,
|
||||||
|
MAKEDATE(1970, 1) AS f2;
|
||||||
|
DESCRIBE t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo End of 6.0 tests
|
||||||
|
@ -871,6 +871,7 @@ public:
|
|||||||
{
|
{
|
||||||
decimals=0;
|
decimals=0;
|
||||||
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
|
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
|
||||||
|
maybe_null= 1;
|
||||||
}
|
}
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
};
|
};
|
||||||
@ -1025,4 +1026,9 @@ public:
|
|||||||
Item_func_last_day(Item *a) :Item_date(a) {}
|
Item_func_last_day(Item *a) :Item_date(a) {}
|
||||||
const char *func_name() const { return "last_day"; }
|
const char *func_name() const { return "last_day"; }
|
||||||
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
|
||||||
|
void fix_length_and_dec()
|
||||||
|
{
|
||||||
|
Item_date::fix_length_and_dec();
|
||||||
|
maybe_null= 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user