Bug #90825 Bit display does not display by default from the CLI
Submitted: 10 May 2018 21:28 Modified: 11 May 2018 1:54
Reporter: Steve Northup Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: bit, cli, display

[10 May 2018 21:28] Steve Northup
Description:
bit data cannot be viewed in the cli by default.  It attempts to print it as binary, at best being completely unreadable, at worst messing up the terminal.

How to repeat:
Create a table with a 'bit' type column.  Preform a select.

Suggested fix:
Print bit columns as the BIN() or HEX() would print them.  Or allow users to configure how they display.
[11 May 2018 1:54] MySQL Verification Team
Thank you for the bug report. Use col+0, see below:

mysql 5.7 > create table z (col bit);
Query OK, 0 rows affected (0,28 sec)

mysql 5.7 > insert into z values (b'1');
Query OK, 1 row affected (0,04 sec)

mysql 5.7 > select col from z;
+------+
| col  |
+------+
|     |
+------+
1 row in set (0,00 sec)

mysql 5.7 > select col+0 from z;
+-------+
| col+0 |
+-------+
|     1 |
+-------+
1 row in set (0,00 sec)

mysql 5.7 >

See: https://dev.mysql.com/doc/refman/5.7/en/bit-value-literals.html

"Bit values in result sets are returned as binary values, which may not display well. To convert a bit value to printable form,....."