Skip to content

bug: the length of the Bit type is different as expected #1180

@davidshiz

Description

@davidshiz

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

mysql> CREATE TABLE bit_table(b BIT(11));
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO bit_table VALUES (B'10');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO bit_table VALUES (B'00000000000');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO bit_table VALUES (B'11011000000');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO bit_table VALUES (B'01010101010');
Query OK, 1 row affected (0.00 sec)

mysql> select length(b) from bit_table;
+-----------+
| length(b) |
+-----------+
|         1 |
|         1 |
|         4 |
|         3 |
+-----------+
4 rows in set (0.00 sec)

Expected behavior

mysql> select length(b) from bit_table;
+-----------+
| length(b) |
+-----------+
|         2 |
|         2 |
|         2 |
|         2 |
+-----------+
4 rows in set (0.00 sec)

How To Reproduce

CREATE TABLE bit_table(b BIT(11));
INSERT INTO bit_table VALUES (B'10');
INSERT INTO bit_table VALUES (B'00000000000');
INSERT INTO bit_table VALUES (B'11011000000');
INSERT INTO bit_table VALUES (B'01010101010');
select length(b) from bit_table;

Environment

root@ub01:~# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
Repository address: https://github.com/hustjieke/stonedb.git:feat_support_bit_type_issue919
Branch name: feat_support_bit_type_issue919
Last commit ID: https://github.com/stoneatom/stonedb/commit/38982a599b4f302f63f1612206d8f74d1606098f
Last commit time: Date: Tue Dec 27 08:44:36 2022 +0000
Build time: Date: Thu Dec 29 13:08:25 CST 2022
[root@localhost ~]# cat /etc/system-release
CentOS Linux release 7.9.2009 (Core)

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!

Metadata

Metadata

Assignees

Labels

A-bugSomething isn't workingB-storagedata type, data storage, insert,update,delete, transactionsprio: lowLow priority

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions