1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-11 09:43:05 +03:00

MDEV-7831 Bad warning for DATE_ADD(timestamp_column, INTERVAL 10 SECOND)

This commit is contained in:
Alexander Barkov
2015-03-25 13:06:04 +04:00
parent bd2ae787ea
commit 651a142ad0
5 changed files with 45 additions and 11 deletions

View File

@@ -699,7 +699,7 @@ a tz
2038-01-19 03:14:06 Moscow 2038-01-19 03:14:06 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a);
Warnings: 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 34
Warning 1264 Out of range value for column 'a' at row 35 Warning 1264 Out of range value for column 'a' at row 35
SELECT MIN(a), MAX(a) FROM t2; SELECT MIN(a), MAX(a) FROM t2;
@@ -782,9 +782,9 @@ a tz
2011-10-30 00:00:02 Moscow 2011-10-30 00:00:02 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a);
Warnings: Warnings:
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' Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
Warning 1292 Incorrect datetime value: '0000-00-00' Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
SELECT MIN(a), MAX(a) FROM t2; SELECT MIN(a), MAX(a) FROM t2;
MIN(a) MAX(a) MIN(a) MAX(a)
1970-01-01 00:00:01 2038-01-19 03:14:06 1970-01-01 00:00:01 2038-01-19 03:14:06
@@ -1179,7 +1179,7 @@ a tz
2038-01-19 06:14:06 Moscow 2038-01-19 06:14:06 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a); UPDATE t2 SET a = TIMESTAMPADD(SECOND, 1, a);
Warnings: 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 8
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 9 Warning 1299 Invalid TIMESTAMP value in column 'a' at row 9
Warning 1264 Out of range value for column 'a' at row 34 Warning 1264 Out of range value for column 'a' at row 34
@@ -1264,9 +1264,9 @@ a tz
2011-10-30 03:00:02 Moscow 2011-10-30 03:00:02 Moscow
UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a); UPDATE t2 SET a = TIMESTAMPADD(SECOND, -1, a);
Warnings: Warnings:
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' Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
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 18 Warning 1299 Invalid TIMESTAMP value in column 'a' at row 18
Warning 1299 Invalid TIMESTAMP value in column 'a' at row 19 Warning 1299 Invalid TIMESTAMP value in column 'a' at row 19
SELECT MIN(a), MAX(a) FROM t2; SELECT MIN(a), MAX(a) FROM t2;

View File

@@ -691,3 +691,20 @@ drop function f1;
set timestamp=0; set timestamp=0;
SET time_zone=DEFAULT; SET time_zone=DEFAULT;
End of 10.0 tests 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
#

View File

@@ -188,10 +188,10 @@ tsv TIMESTAMP AS (ADDDATE(ts, INTERVAL 1 DAY)) VIRTUAL
) ENGINE=MyISAM; ) ENGINE=MyISAM;
INSERT INTO t1 (tsv) VALUES (DEFAULT); INSERT INTO t1 (tsv) VALUES (DEFAULT);
Warnings: 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); INSERT DELAYED INTO t1 (tsv) VALUES (DEFAULT);
Warnings: Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00' Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
FLUSH TABLES; FLUSH TABLES;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)

View File

@@ -493,3 +493,20 @@ set timestamp=0;
SET time_zone=DEFAULT; SET time_zone=DEFAULT;
--echo End of 10.0 tests --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 #

View File

@@ -4842,7 +4842,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ /* Zero time is "000000" */ { /* Zero time is "000000" */
if (fuzzydate & TIME_NO_ZERO_DATE) if (fuzzydate & TIME_NO_ZERO_DATE)
return 1; return 1;
bzero((char*) ltime,sizeof(*ltime)); set_zero_time(ltime, MYSQL_TIMESTAMP_DATETIME);
} }
else else
{ {