Bug #95466 ERROR 1525 (HY000): Incorrect TIMESTAMP value: 'CURRENT_TIMESTAMP'
| Submitted: | 22 May 2019 3:55 | Modified: | 12 Jun 2019 15:03 |
|---|---|---|---|
| Reporter: | Franz Eisenkölbl | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 8.0.16 | OS: | Linux |
| Assigned to: | CPU Architecture: | x86 | |
| Tags: | current_timestamp, ERROR 1525, regression | ||
[22 May 2019 3:55]
Franz Eisenkölbl
[22 May 2019 6:17]
MySQL Verification Team
Hello Franz Eisenkölbl, Thank you for the report. regards, Umesh
[11 Jun 2019 14:25]
Catalin Besleaga
Posted by developer: Fix should be to use the correct DATETIME values: in this case CURRENT_TIMESTMAP without quotes as the quoted version leads to string comparison between two strings: the STRING "CURRENT_TIMESTAMP" and the string resulted from converting the datetime column to string. The behavior is documented already in 8.0.16 change log as following: When comparing DATE values with constant strings, MySQL first tries to convert the string to a DATE and then to perform the comparison. When the conversion failed, MySQL executed the comparison treating the DATE as a string, which could lead to unpredictable behavior. Now in such cases, if the conversion of the string to a DATE fails, the comparison fails with ER_WRONG_VALUE. (Bug #29025656)
[12 Jun 2019 15:03]
Jon Stephens
Hi, This is NOT a regression. Here's an example of a bad thing that could happen prior to the fix for BUG#93513: mysql> SELECT VERSION(); +-----------+ | VERSION() | +-----------+ | 8.0.15 | +-----------+ 1 row in set (0.02 sec) mysql> CREATE TABLE t (a BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, b TIMESTAMP); Query OK, 0 rows affected (0.25 sec) mysql> INSERT INTO t VALUES (NULL, NOW()); Query OK, 1 row affected (0.04 sec) mysql> INSERT INTO t VALUES (NULL, NOW()); Query OK, 1 row affected (0.03 sec) # Insert a date well into the future mysql> INSERT INTO t VALUES (NULL, DATE_ADD(NOW(), INTERVAL 1 YEAR)); Query OK, 1 row affected (0.03 sec) mysql> INSERT INTO t VALUES (NULL, NOW()); Query OK, 1 row affected (0.03 sec) mysql> INSERT INTO t VALUES (NULL, NOW()); Query OK, 1 row affected (0.03 sec) # No quotes - correct result mysql> SELECT * FROM t WHERE b <= CURRENT_TIMESTAMP; +---+---------------------+ | a | b | +---+---------------------+ | 1 | 2019-06-12 10:49:02 | | 2 | 2019-06-12 10:49:08 | | 4 | 2019-06-12 10:50:13 | | 5 | 2019-06-12 10:50:16 | +---+---------------------+ 4 rows in set (0.00 sec) # With quotes - result is clearly not correct mysql> SELECT * FROM t WHERE b <= 'CURRENT_TIMESTAMP'; +---+---------------------+ | a | b | +---+---------------------+ | 1 | 2019-06-12 10:49:02 | | 2 | 2019-06-12 10:49:08 | | 3 | 2020-06-12 10:50:08 | | 4 | 2019-06-12 10:50:13 | | 5 | 2019-06-12 10:50:16 | +---+---------------------+ 5 rows in set, 1 warning (0.01 sec) cheers jon.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.042 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.