[MDEV-8712] Wrong result for SELECT..WHERE latin1_bin_column=_latin1'a' AND latin1_bin_column='A' Created: 2015-08-31 Updated: 2015-09-11 Resolved: 2015-09-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1 |
| Fix Version/s: | 10.1.8 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
This script:
correctly returns empty set for both SELECT queries. If I now change the order of the two conditions in the second SELECT query:
it erroneously returns one row:
The same problem is repeatable with character set introducers
The problem happens in Item_equal::add_const(), in this code:
It does not take into account the column collation (latin1_bin) and compares the two constants as latin1_swedish_ci, which gives TRUE. The second part of the AND is then eliminated from the query. So:
gets rewritten to:
which returns no rows, while:
gets rewritten as
which returns one row. |