From 455ee425d146f876085c8fe8db0be2f4124640f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Aug 2005 15:28:09 -0700 Subject: 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 --- mysql-test/t/func_date_add.test | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'mysql-test/t/func_date_add.test') diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test index b768e4fec61..e01fce30577 100644 --- a/mysql-test/t/func_date_add.test +++ b/mysql-test/t/func_date_add.test @@ -41,4 +41,27 @@ select visitor_id,max(ts) as mts from t1 group by visitor_id having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW(); drop table t1; +# +# Bug #10627: Invalid date turned to NULL from date_sub/date_add in +# traditional mode +# +set sql_mode='traditional'; +create table t1 (d date); +--error S22008 +insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR); +--error S22008 +insert into t1 (d) select date_add('2000-01-01',interval 8000 year); +# No warnings/errors from the next two +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=''; +# These will all work now, and we'll end up with some NULL entries in the +# table and some warnings. +insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR); +insert into t1 (d) select date_add('2000-01-01',interval 8000 year); +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; +drop table t1; + # End of 4.1 tests -- cgit v1.2.1