mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed bug #18618.
If the second or the third argument of a BETWEEN predicate was a constant expression, like '2005.09.01' - INTERVAL 6 MONTH, while the other two arguments were fields then the predicate was evaluated incorrectly and the query returned a wrong result set. The bug was introduced in 5.0.17 when in the fix for 12612. mysql-test/r/func_time.result: Added a test case for bug #18618. mysql-test/t/func_time.test: Added a test case for bug #18618.
This commit is contained in:
@ -847,3 +847,28 @@ timestampdiff(year,'2004-02-28','2005-02-28')
|
||||
select timestampdiff(year,'2004-02-29','2005-02-28');
|
||||
timestampdiff(year,'2004-02-29','2005-02-28')
|
||||
0
|
||||
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, day date);
|
||||
CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, day date);
|
||||
INSERT INTO t1 VALUES
|
||||
(1, '2005-06-01'), (2, '2005-02-01'), (3, '2005-07-01');
|
||||
INSERT INTO t2 VALUES
|
||||
(1, '2005-08-01'), (2, '2005-06-15'), (3, '2005-07-15');
|
||||
SELECT * FROM t1, t2
|
||||
WHERE t1.day BETWEEN
|
||||
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
|
||||
id day id day
|
||||
1 2005-06-01 1 2005-08-01
|
||||
3 2005-07-01 1 2005-08-01
|
||||
1 2005-06-01 2 2005-06-15
|
||||
1 2005-06-01 3 2005-07-15
|
||||
3 2005-07-01 3 2005-07-15
|
||||
SELECT * FROM t1, t2
|
||||
WHERE CAST(t1.day AS DATE) BETWEEN
|
||||
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
|
||||
id day id day
|
||||
1 2005-06-01 1 2005-08-01
|
||||
3 2005-07-01 1 2005-08-01
|
||||
1 2005-06-01 2 2005-06-15
|
||||
1 2005-06-01 3 2005-07-15
|
||||
3 2005-07-01 3 2005-07-15
|
||||
DROP TABLE t1,t2;
|
||||
|
Reference in New Issue
Block a user