[MDEV-17342] Mariadb is giving warning for this query and table Created: 2018-10-02 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.2.18, 10.3.9 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Amit Singh | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
ubuntu 18 |
||
| Issue Links: |
|
||||||||
| Description |
|
Please create the following table,
you will get following warning while running them (use adminer to see them) Level Code Message his query is actually part of a bigger set of queries. It has been reduced to this level to highlight the warnings. The issue is not with CURDATE. if you write date(meta_value) is NOT NULL it will give warnings. In fact, it will give warnings with all date related functions in where clause. It does not seem that it could be an optimization issue. Try the following queries with a join. At this point, the optimizer cannot optimize since I am comparing with another table. It will still give a warning.
Now try another query:
This will not give an error. |
| Comments |
| Comment by Alice Sherepa [ 2018-10-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Could you please explain why you consider this as a bug.
The second query can not be transformed the same way because of the limit, so derived table is used (and after performing (where meta_key='lead_date') there are no incorrect datetime values left), so the query does not return warnings.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If I try EXPLAIN EXTENDED for this query:
It gets rewritten to:
So the condition with meta_value is evaluated first, hence the warning. This does not look correct. The query should probably be rewritten as:
to make the condition on meta_key evaluate first, as in the original query. sanja, can you please have a look into this? Thanks. |