tidb: conv bit error
Description
Please answer these questions before submitting your issue. Thanks!
- What did you do?
CREATE TABLE `bit` (
`b` bit(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `bit` (`b`)
VALUES
(0b0000010101),
(0b0000010101),
(NULL),
(0b0000000001),
(0b0000000000),
(0b1111111111),
(0b1111111111),
(0b1111111111),
(0b0000000000),
(0b0000000000),
(0b0000000000),
(0b0000000000),
(0b0000100000);
select conv(b, 2, 2) from `bit`;
- What did you expect to see?
+---------------+
| conv(b, 2, 2) |
+---------------+
| 10101 |
| 10101 |
| NULL |
| 1 |
| 0 |
| 1111111111 |
| 1111111111 |
| 1111111111 |
| 0 |
| 0 |
| 0 |
| 0 |
| 100000 |
+---------------+
13 rows in set (0.00 sec)
- What did you see instead?
+---------------+
| conv(b, 2, 2) |
+---------------+
| 0 |
| 0 |
| NULL |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
| 0 |
+---------------+
13 rows in set (0.01 sec)
- What version of TiDB are you using (
tidb-server -V
or runselect tidb_version();
on TiDB)?
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v1.1.0-alpha-544-gbe1eeac-dirty
Git Commit Hash: be1eeaccb90e75f2ce6defd8947a5218e0372378
Git Branch: master
UTC Build Time: 2018-02-07 03:54:18 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
SIG slack channel
Score
- 300
Mentor
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (14 by maintainers)
@zz-jason I was investigating this issue, found that
strconv.ParseUint
is the problem, it is unable to parse values like “b’0100’” which is how the storage engine gives the value. We have identified adiditonal cases where this would give the wrong resultconv("0XB", 16, 10)
. We have started working on it. Expect a PR in the next few weeks.