pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.27k stars 5.84k forks source link

Convert from `VARCHAR`/`CHAR` to `BIT` doesn't behave well #57312

Closed YangKeao closed 1 day ago

YangKeao commented 1 day ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (a bit(32));
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t values ('b\'1\'');
Query OK, 1 row affected (0.01 sec)

mysql> select * from t;
+------------+
| a          |
+------------+
| 0x00000001 |
+------------+
1 row in set (0.00 sec)

2. What did you expect to see? (Required)

mysql> insert into t values ('b\'1\'');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t;
+------------+
| a          |
+------------+
| 0x62273127 |
+------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

v8.3.0.

This bug is introduced by https://github.com/pingcap/tidb/pull/21310

YangKeao commented 1 day ago

In MySQL, even in LOAD DATA, the b'1' is not parsed. I don't know why it's implemented as Parse in https://github.com/pingcap/tidb/pull/21310