[MDEV-21388] Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on Created: 2019-12-24 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Views |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.4, 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
I create two tables and a view as follows:
and run this query:
So far so good. Now I add and extra condition to select only Sunday records:
Everything is still fine. Now I change the optimizer switch and run the same query:
It retuns empty set with the following warning:
The result of the last query looks wrong. It should return two records, like the previous query does. |
| Comments |
| Comment by Alexander Barkov [ 2019-12-24 ] | |||||||||||||||||
|
The problem happens because Item_func_dayname derives from Item_func_weekday but it does not override this method:
| |||||||||||||||||
| Comment by Alexander Barkov [ 2019-12-24 ] | |||||||||||||||||
|
More anomalies happen because Item_func_dayname erroneously derives from Item_func_weekday. For some reasons this query returns a non-zero result although 'Saturday'+5 should return 0 with a warning:
Note, if I apply the explicit CAST, it does return 0 with a warning, as expected:
This inconsistency should be fixed. Item_func_dayname should derive from Item_int_func rather than from Item_func_weekday. | |||||||||||||||||
| Comment by Alice Sherepa [ 2022-12-05 ] | |||||||||||||||||
|
currently returns correct results on 10.3 (4e9206736c403206915c)-10.10 |