diff options
author | unknown <jimw@mysql.com> | 2005-08-02 15:28:09 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-08-02 15:28:09 -0700 |
commit | 455ee425d146f876085c8fe8db0be2f4124640f8 (patch) | |
tree | 0aa7f4ebd49ff0e98d9e3384d984bfe5b01824f3 /mysql-test/t/func_date_add.test | |
parent | 6eb7a80aff5363f3f0d714d5c7c1d46561a42ba1 (diff) | |
download | mariadb-git-455ee425d146f876085c8fe8db0be2f4124640f8.tar.gz |
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
Diffstat (limited to 'mysql-test/t/func_date_add.test')
-rw-r--r-- | mysql-test/t/func_date_add.test | 23 |
1 files changed, 23 insertions, 0 deletions
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 |