[MDEV-11482] Incorrect result for (time_expr BETWEEN timestamp_exp1 AND timestamp_expr2) Created: 2016-12-05  Updated: 2017-04-07  Resolved: 2016-12-13

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.3.0

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a TIMESTAMP,b TIMESTAMP);
INSERT INTO t1 VALUES ('2001-01-01 00:00:00','2001-01-01 23:59:59');
SELECT * FROM t1 WHERE TIME'10:20:30' BETWEEN a and b;

erroneously returns empty set.

If I change one of the columns from TIMESTAMP to DATETIME it correctly returns one row:

SET @@timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a TIMESTAMP,b DATETIME);
INSERT INTO t1 VALUES ('2001-01-01 00:00:00','2001-01-01 23:59:59');
SELECT * FROM t1 WHERE TIME'10:20:30' BETWEEN a and b;

+---------------------+---------------------+
| a                   | b                   |
+---------------------+---------------------+
| 2001-01-01 00:00:00 | 2001-01-01 23:59:59 |
+---------------------+---------------------+



 Comments   
Comment by Alexander Barkov [ 2016-12-13 ]

The patch for MDEV-11485 fixed this problem.

Generated at Thu Feb 08 07:50:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.