Bug #99831 | UNEXPECTED RETURNED VALUE by SELECT FROM COLUMN(BINARY) | ||
---|---|---|---|
Submitted: | 10 Jun 2020 5:42 | Modified: | 10 Jun 2020 13:59 |
Reporter: | ick R | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Data Types | Severity: | S3 (Non-critical) |
Version: | 5.7.30 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[10 Jun 2020 5:42]
ick R
[10 Jun 2020 8:35]
ick R
mysql> select * from test where col=binary ''; Empty set (0.00 sec) Still can't get the value.
[10 Jun 2020 9:06]
Yushan ZHANG
Interestingly, it saves the '' as 0 into the table. But it cannot display the value with 0. And it cannot be selected with `binary ''`. mysql> select col = 0 from test; +---------+ | col = 0 | +---------+ | 1 | +---------+ 1 row in set, 1 warning (0.00 sec) mysql> select col != 0 from test; +----------+ | col != 0 | +----------+ | 0 | +----------+ 1 row in set, 1 warning (0.00 sec) mysql> show warnings; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: '\x00\x00' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec) mysql> select binary col = 0 from test; +----------------+ | binary col = 0 | +----------------+ | 1 | +----------------+ 1 row in set (0.00 sec) mysql> select binary col != 0 from test; +-----------------+ | binary col != 0 | +-----------------+ | 0 | +-----------------+ 1 row in set (0.00 sec) mysql> select hex(col) from test; +----------+ | hex(col) | +----------+ | 0000 | +----------+ 1 row in set (0.00 sec) mysql> select binary col = binary '' from test; +------------------------+ | binary col = binary '' | +------------------------+ | 0 | +------------------------+ 1 row in set (0.00 sec) mysql> select binary col != binary '' from test; +-------------------------+ | binary col != binary '' | +-------------------------+ | 1 | +-------------------------+ 1 row in set (0.00 sec)
[10 Jun 2020 12:53]
MySQL Verification Team
Hi Mr. R, Thank you for your bug report. Actually, with your last comment, you have answered your own questions. Since the column is BINARY and not CHAR, this is exactly the expected behaviour. Hence, for empty string, you only have a zero byte. This is all explained in our Reference Manual. Not a bug.
[10 Jun 2020 13:00]
Yushan ZHANG
I have another consideration, why the `zero` byte is not displayed when using `select * from test;`? If empty string means `inserting a zero`, why it is not displayed?
[10 Jun 2020 13:01]
MySQL Verification Team
The answer is simple. It denotes the empty string.