mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Generate a warning/error when DATE_SUB/ADD() functions calculate a date
that is outside the acceptable date range. (Bug #10627) mysql-test/r/func_date_add.result: Add new results mysql-test/t/func_date_add.test: Add new regression test sql/item_timefunc.cc: Add warning for error conditions in Item_date_add_interval::get_date() sql/share/errmsg.txt: Add new error message
This commit is contained in:
@@ -45,3 +45,29 @@ visitor_id mts
|
||||
465931136 2000-03-18 16:09:53
|
||||
1092858576 2000-03-19 01:34:45
|
||||
drop table t1;
|
||||
set sql_mode='traditional';
|
||||
create table t1 (d date);
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
ERROR 22008: Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
set sql_mode='';
|
||||
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
|
||||
Warnings:
|
||||
Warning 1437 Datetime function: datetime field overflow
|
||||
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
|
||||
Warnings:
|
||||
Warning 1437 Datetime function: datetime field overflow
|
||||
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
|
||||
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
|
||||
select * from t1;
|
||||
d
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user