[MDEV-16195] MariaDB 10.2 Select Query Between Dates Not Returning Data Created: 2018-05-16  Updated: 2018-06-04  Resolved: 2018-06-04

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.2.14
Fix Version/s: 10.2.15

Type: Bug Priority: Major
Reporter: Jeremy Romine Assignee: Alice Sherepa
Resolution: Duplicate Votes: 0
Labels: between, dates, query, select
Environment:

CloudLinux release 7.5 (Viktor Gorbatko) with cPanel 11.70.0.39


Attachments: File testdb.sql    
Issue Links:
Duplicate
duplicates MDEV-15765 BETWEEN not working in certain cases Closed

 Description   

Hello,

We have found that as of MariaDB 10.2 queries using BETWEEN to compare dates no longer work as expected. The following query works just fine on MariaDB 10.1 and MySQL 5.7, but not on MariaDB 10.2. With MariaDB 10.2 this query just returns no rows but the query is executed as valid with no warnings.

SELECT * FROM ( SELECT 'ProduceFD' AS `Type`,
`inspections_fresh_produce_fd`.* FROM `inspections_fresh_produce_fd`
UNION ALL SELECT 'ProduceP' AS `Type`, `inspections_fresh_produce_p`.*
FROM `inspections_fresh_produce_p` UNION ALL SELECT 'Prepped' AS `Type`,
`inspections_prepped`.* FROM `inspections_prepped`) AS query WHERE
`DataCheck`=1 AND `InspectionDate` BETWEEN '2017-04-16' AND '2017-05-13'
ORDER BY `InspectionDate` DESC

This similar query not using "BETWEEN" works as expected and returns the correct data on MariaDB 10.2:
SELECT * FROM ( SELECT 'ProduceFD' AS `Type`, `inspections_fresh_produce_fd`.* FROM `inspections_fresh_produce_fd` UNION ALL SELECT 'ProduceP' AS `Type`, `inspections_fresh_produce_p`.* FROM `inspections_fresh_produce_p` UNION ALL SELECT 'Prepped' AS `Type`, `inspections_prepped`.* FROM `inspections_prepped`) AS query WHERE `DataCheck`=1 AND InspectionDate > '2017-04-16' AND InspectionDate < '2017-05-13' ORDER BY `InspectionDate` DESC;

We have attached an SQL backup that can be used to reproduce this issue.



 Comments   
Comment by Alice Sherepa [ 2018-06-04 ]

Fixed by Igor Babaev, commit 740fc2ae084f8f81990de557d696

Generated at Thu Feb 08 08:27:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.