Bug #87257 bit(1) values buffer overflow
Submitted: 31 Jul 2017 8:27 Modified: 13 Sep 2017 17:33
Reporter: Alessandro Cannini Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:Windows
Assigned to: MySQL Verification Team CPU Architecture:Any

[31 Jul 2017 8:27] Alessandro Cannini
Description:
bit(1) cannot be properly read.

phpMyAdmin and see 1111111111111111111111111111111 for both 0 and 1.

PHP see the string 668556962937438208 for 0, instead it see the string 668556962937438209 for 1.

This problem seems to be Windows specific.

How to repeat:
- Install XAMPP 7.1.7-0 for Windows
- Create a database and a table with a field of type bit(1)
- From PHP set its value to 0 or 1
- Enter in phpMyAdmin and see the value, it always display 1111111111111111111111111111111.
[31 Jul 2017 15:40] MySQL Verification Team
Hi,

This looks like phpmysql bug, not mysql bug.

create table t (trt bit(1));
insert into t values (1);
insert into t values (0);
select hex(trt) from t;
+----------+
| hex(trt) |
+----------+
| 1        |
| 0        |
+----------+

everything as expected

Can you confirm connecting directly to mysql that you have a problem or not?

all best
Bogdan
[3 Aug 2017 7:27] Alessandro Cannini
You must use 32-bit mysql on 64-bit Windows.

mysql -uroot -e"CREATE TABLE test1 (bit_column_1 bit(1) NOT NULL) DEFAULT CHARSET=utf8" test_db
mysql -uroot -e"INSERT INTO test1 (bit_column_1) VALUES (0)" test_db
mysql -uroot -e"INSERT INTO test1 (bit_column_1) VALUES (1)" test_db
mysql -uroot -e"SELECT bit_column_1 FROM test1" test_db
+--------------+
| bit_column_1 |
+--------------+
|              |
| ☺            |
+--------------+
[3 Aug 2017 7:33] Alessandro Cannini
Ok, now I have used hex and it works, sorry for the bother.
The bug is definitely not in mysql.
[13 Sep 2017 17:33] Alessandro Cannini
The bug is this: https://bugs.php.net/bug.php?id=75018
[13 Sep 2017 21:13] MySQL Verification Team
Thanks for the update :D

all best
Bogdan