Bug #111385 varbinary_col in (0) result incorrect
Submitted: 13 Jun 6:35 Modified: 13 Jun 12:34
Reporter: haizhen xue Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[13 Jun 6:35] haizhen xue
Description:
create table test (varbinary_col varbinary(255) DEFAULT NULL);
insert into test values(0);
insert into test values(_binary 'dddddddddd1');
mysql> select * from test where varbinary_col in (0);
+------------------------------+
| varbinary_col                |
+------------------------------+
| 0x30                         |
| 0x6464646464646464646431     |
+------------------------------+
2 rows in set, 1 warning (0.00 sec)

expect result is: 0x30

How to repeat:
create table test (varbinary_col varbinary(255) DEFAULT NULL);
insert into test values(0);
insert into test values(_binary 'dddddddddd1');
mysql> select * from test where varbinary_col in (0);
+------------------------------+
| varbinary_col                |
+------------------------------+
| 0x30                         |
| 0x6464646464646464646431     |
+------------------------------+
2 rows in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------+
| Level   | Code | Message                                         |
+---------+------+-------------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'dddddddddd1' |
+---------+------+-------------------------------------------------+
1 row in set (0.00 sec)

expect result is: 0x30

Suggested fix:
select * from test where varbinary_col in (0);
expect result is: 0x30
[13 Jun 12:34] MySQL Verification Team
Hi Mr. xue,

Thank you for your bug report.

However, this is not a bug.

Since VARBINARY belongs to VARCHAR domains, then you will find '0' in  any '0x..........." value.

Not a bug.