[MDEV-6052] Inconsistent results with bit type Created: 2014-04-09  Updated: 2014-08-06  Resolved: 2014-08-06

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.10
Fix Version/s: 10.0.13

Type: Bug Priority: Critical
Reporter: Sergey Vojtovich Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File unknown_bug.patch    
Issue Links:
PartOf
is part of MDEV-4784 merge test cases from 5.6 Stalled

 Description   

Found while merging type_bit test. type_bit patch attached.

CREATE TABLE t1(f1 bit(2) NOT NULL default b'10',f2 bit(14) NOT NULL default b'11110000111100');
INSERT INTO t1 (f1) VALUES (DEFAULT);
INSERT INTO t1 VALUES (b'',b''),('','');
SELECT HEX(f1), HEX(f2) FROM t1;
HEX(f1)	HEX(f2)
2	3C3C
2	3C8F <!-------- should be 0 0?
0	0
DROP TABLE t1;



 Comments   
Comment by Igor Babaev [ 2014-08-05 ]

Here' s what we have for MyISAM (the correct result):

MariaDB [test]> CREATE TABLE t1(f1 bit(2)) ENGINE=MYISAM;
Query OK, 0 rows affected (0.01 sec)
 
MariaDB [test]> INSERT INTO t1 VALUES (b'');
Query OK, 1 row affected (0.00 sec)
 
MariaDB [test]> SELECT HEX(f1) from t1;
+---------+
| HEX(f1) |
+---------+
| 0       |
+---------+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT bin(f1) from t1;
+---------+
| bin(f1) |
+---------+
| 0       |
+---------+
1 row in set (0.00 sec)

And here's what we have for INNODB (an incorrect result):

MariaDB [test]> CREATE TABLE t2(f1 bit(2)) ENGINE=INNODB;
Query OK, 0 rows affected (0.06 sec)
 
MariaDB [test]> INSERT INTO t2 VALUES (b'');
Query OK, 1 row affected (0.01 sec)
 
MariaDB [test]> SELECT HEX(f1) from t2;
+---------+
| HEX(f1) |
+---------+
| 8F      |
+---------+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT bin(f1) from t2;
+----------+
| bin(f1)  |
+----------+
| 10001111 |
+----------+
1 row in set (0.00 sec)

mysql-5.6 returns the correct result in both cases.

Generated at Thu Feb 08 07:09:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.