Skip to content

Commit

Permalink
MDEV-7831 Bad warning for DATE_ADD(timestamp_column, INTERVAL 10 SECOND)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Mar 25, 2015
1 parent bd2ae78 commit 651a142
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
16 changes: 8 additions & 8 deletions mysql-test/r/partition_datatype.result
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ a tz
2038-01-19 03:14:06 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1264 Out of range value for column 'a' at row 34
Warning 1264 Out of range value for column 'a' at row 35
SELECT MIN(a), MAX(a) FROM t2;
Expand Down Expand Up @@ -782,9 +782,9 @@ a tz
2011-10-30 00:00:02 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
SELECT MIN(a), MAX(a) FROM t2;
MIN(a) MAX(a)
1970-01-01 00:00:01 2038-01-19 03:14:06
Expand Down Expand Up @@ -1179,7 +1179,7 @@ a tz
2038-01-19 06:14:06 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 8
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 9
Warning 1264 Out of range value for column 'a' at row 34
Expand Down Expand Up @@ -1264,9 +1264,9 @@ a tz
2011-10-30 03:00:02 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 18
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 19
SELECT MIN(a), MAX(a) FROM t2;
Expand Down
17 changes: 17 additions & 0 deletions mysql-test/r/type_timestamp.result
Original file line number Diff line number Diff line change
Expand Up @@ -691,3 +691,20 @@ drop function f1;
set timestamp=0;
SET time_zone=DEFAULT;
End of 10.0 tests
#
# Start of 10.1 tests
#
#
# MDEV-7831 Bad warning for DATE_ADD(timestamp_column, INTERVAL 10 SECOND)
#
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES ('0000-00-00 00:00:00');
SELECT DATE_ADD(a, INTERVAL 10 SECOND) FROM t1;
DATE_ADD(a, INTERVAL 10 SECOND)
NULL
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
DROP TABLE t1;
#
# End of 10.1 tests
#
4 changes: 2 additions & 2 deletions mysql-test/suite/vcol/r/vcol_misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ tsv TIMESTAMP AS (ADDDATE(ts, INTERVAL 1 DAY)) VIRTUAL
) ENGINE=MyISAM;
INSERT INTO t1 (tsv) VALUES (DEFAULT);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
INSERT DELAYED INTO t1 (tsv) VALUES (DEFAULT);
Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
FLUSH TABLES;
SELECT COUNT(*) FROM t1;
COUNT(*)
Expand Down
17 changes: 17 additions & 0 deletions mysql-test/t/type_timestamp.test
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,20 @@ set timestamp=0;
SET time_zone=DEFAULT;

--echo End of 10.0 tests

--echo #
--echo # Start of 10.1 tests
--echo #

--echo #
--echo # MDEV-7831 Bad warning for DATE_ADD(timestamp_column, INTERVAL 10 SECOND)
--echo #
CREATE TABLE t1 (a TIMESTAMP);
INSERT INTO t1 VALUES ('0000-00-00 00:00:00');
SELECT DATE_ADD(a, INTERVAL 10 SECOND) FROM t1;
DROP TABLE t1;


--echo #
--echo # End of 10.1 tests
--echo #
2 changes: 1 addition & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4842,7 +4842,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ /* Zero time is "000000" */
if (fuzzydate & TIME_NO_ZERO_DATE)
return 1;
bzero((char*) ltime,sizeof(*ltime));
set_zero_time(ltime, MYSQL_TIMESTAMP_DATETIME);
}
else
{
Expand Down

0 comments on commit 651a142

Please sign in to comment.