[MDEV-16878] Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer Created: 2018-08-02 Updated: 2018-08-13 Resolved: 2018-08-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.3.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
I create and populate a table like this:
Now I do some time arithmetic:
Now I put the same arithmetic expressions into WHERE:
So far so good:
Now I mix these two conditions using AND and expect to get empty set again:
However, the server returned one row. This is wrong! The following EXPLAIN script demonstrates that the second condition part was erroneously eliminated by the optimizer:
Notice, there is no the ADDTIME() condition in the optimzed query. The problem happens because Item_func_add_time::func_name() erroneously always returns the same value, which makes the equal expression propagation code erroneously think ADDTIME() and SUBTIME() are equal to each other. Item_func_add_time::func_name() should return three different names depending on the exact SQL function it handles:
|