[MDEV-8740] Wrong result for SELECT..WHERE year_field=10 AND NULLIF(year_field,2011.1)='2011' Created: 2015-09-03 Updated: 2015-09-12 Resolved: 2015-09-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1 |
| Fix Version/s: | 10.1.8 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | propagation, upstream | ||
| Issue Links: |
|
||||||||||||
| Description |
|
This script:
returns
Now if I put the same expression into WHERE:
it erroneously returns one row:
The expected result is to have the expression evaluate into the same result in the SELECT list and in WHERE. The problem is that Item_func_nullif::const_item() returns true and its val_real() is called from eval_const_cond().
but the returned value referenced by m_args0_copy is not a constant item:
The return argument should probably be stored in arg[2] instead, so the standard Item_func methods can see it and update Used_tables_cache taking into account the return value (not only the compared values). |
| Comments |
| Comment by Alexander Barkov [ 2015-09-12 ] | |||||||||||||||||
|
MySQL-5.7.8 seems to return a correct result:
but the EXPLAIN output is not really correct:
MariaDB returns a more correct result:
|