Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.2.14
-
None
-
Ubuntu Server 16.04 LTS
Description
In MariaDB 10.2.14 the following SQLs do not work as intended, specifically BETWEEN seems to be broken. In 10.2.13 everything works as expected.
-- Not work
|
SELECT
|
*
|
FROM (SELECT date('2018-01-01') AS DAT |
UNION ALL |
SELECT date('2018-01-01') AS DAT) AS t |
WHERE t.DAT BETWEEN date ('2017-01-01') AND date ('2019-01-01'); |
|
-- not work
|
SELECT
|
*
|
FROM (SELECT date('2018-01-01') AS d) AS t |
WHERE t.d BETWEEN date ('2017-01-01') AND date ('2019-01-01'); |
-- work
|
SELECT 'aaaa' AS d FROM dual |
WHERE date('2018-01-01') BETWEEN date ('2017-01-01') AND date ('2019-01-01'); |
Attachments
Issue Links
- is duplicated by
-
MDEV-15829 BETWEEN datetime not working with derived table and condition pushdown
-
- Closed
-
-
MDEV-15860 Datetime range search in subquery returns an empty resultset
-
- Closed
-
-
MDEV-16195 MariaDB 10.2 Select Query Between Dates Not Returning Data
-
- Closed
-
after be3651b7005ed550be5a2a4b8bb2c600f9870cfa commit (10.2):
explain extended SELECT *
FROM (SELECT date('2018-01-01') AS DAT
UNION ALL
SELECT date('2018-01-01') AS DAT) AS t
WHERE t.DAT BETWEEN date ('2017-01-01') AND date ('2019-01-01');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `t`.`DAT` AS `DAT` from (select cast('2018-01-01' as date) AS `DAT` union all select cast('2018-01-01' as date) AS `DAT`) `t` where `t`.`DAT` between <cache>(cast('2017-01-01' as date)) and <cache>(cast('2019-01-01' as date))
explain extended SELECT *
FROM (SELECT date('2018-01-01') AS d) AS t
WHERE t.d BETWEEN date ('2017-01-01') AND date ('2019-01-01');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select NULL AS `d` from (select cast('2018-01-01' as date) AS `d`) `t` where 0
before:
explain extended SELECT *
FROM (SELECT date('2018-01-01') AS DAT
UNION ALL
SELECT date('2018-01-01') AS DAT) AS t
WHERE t.DAT BETWEEN date ('2017-01-01') AND date ('2019-01-01');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select `t`.`DAT` AS `DAT` from (select cast('2018-01-01' as date) AS `DAT` union all select cast('2018-01-01' as date) AS `DAT`) `t` where `t`.`DAT` between <cache>(cast('2017-01-01' as date)) and <cache>(cast('2019-01-01' as date))
explain extended SELECT *
FROM (SELECT date('2018-01-01') AS d) AS t
WHERE t.d BETWEEN date ('2017-01-01') AND date ('2019-01-01');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select '2018-01-01' AS `d` from dual where 1