Bug #976 Using heex data works with 'like' but not with '='
Submitted: 1 Aug 2003 6:29 Modified: 1 Aug 2003 8:38
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.10 (also 3.23.54) OS:FreeBSD (FreeBSD)
Assigned to: CPU Architecture:Any

[1 Aug 2003 6:29] [ name withheld ]
Description:
Using the query:

select * from _pfkit_unique where name = 0x746573745F756E69717565;

returns no results, but using the query

select * from _pfkit_unique where name like 0x746573745F756E69717565;

does work. the hex data in question is for the string 'test_unique'
which matches one row in the database.

How to repeat:
Create a table with this format:

mysql> desc _pfkit_unique;
+-------+---------------------+------+-----+---------+-------+
| Field | Type                | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+-------+
| name  | varchar(32) binary  |      | PRI |         |       |
| value | bigint(20) unsigned |      |     | 0       |       |
+-------+---------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

Insert a single row so the data looks like this:

mysql> select * from _pfkit_unique;
+-------------+-------+
| name        | value |
+-------------+-------+
| test_unique |     2 |
+-------------+-------+
1 row in set (0.00 sec)

Now try the two select statements:

select * from _pfkit_unique where name like 0x746573745F756E69717565;
+-------------+-------+
| name        | value |
+-------------+-------+
| test_unique |     2 |
+-------------+-------+
1 row in set (0.01 sec)

mysql> select * from _pfkit_unique where name = 0x746573745F756E69717565;
Empty set (0.00 sec)

As the hex is for the string 'test_unique' then both queries should match the
database row, but only the query using 'like' works. If you us explain
on the second query you get the result:

mysql> explain select * from _pfkit_unique where name = 0x746573745F756E69717565;
+-----------------------------------------------------+
| Comment                                             |
+-----------------------------------------------------+
| Impossible WHERE noticed after reading const tables |
+-----------------------------------------------------+
1 row in set (0.00 sec)
[1 Aug 2003 8:38] Alexander Keremidarski
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.

Same as Bug #794 
http://bugs.mysql.com/bug.php?id=794