Details
-
Bug
-
Status: Closed (View Workflow)
-
Resolution: Not a Bug
-
None
-
None
-
None
Description
The following query on the attached table & data yields different results in MySQL 5.5 & MariaDB 5.5:
SELECT id, date_i, date_ontop, date_until
FROM
(
SELECT id, date_i, date_ontop, date_until
FROM news
WHERE
date_i <= CURRENT_TIMESTAMP
AND
date_ontop >= CURRENT_TIMESTAMP
ORDER BY date_i DESC
) AS ontop
UNION
SELECT id, date_i, date_ontop, date_until
FROM
(
SELECT id, date_i, date_ontop, date_until
FROM news
WHERE
date_i <= CURRENT_TIMESTAMP
AND
( date_until >= CURRENT_TIMESTAMP OR date_until IS NULL)
AND
( date_ontop IS NULL OR date_ontop < CURRENT_TIMESTAMP )
ORDER BY date_i DESC
) AS therest
LIMIT 0, 18
In MariaDB 5.2 it gives the same results as MySQL 5.5.
It may be related to Bug#1010116 because if I switch optimizer_switch='derived_merge=off' it give the correct results.
Re: Incorect results in union & subqueries