Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The binary literal default value is not handled correctly #57301

Closed
YangKeao opened this issue Nov 11, 2024 · 1 comment · Fixed by #57303
Closed

The binary literal default value is not handled correctly #57301

YangKeao opened this issue Nov 11, 2024 · 1 comment · Fixed by #57303

Comments

@YangKeao
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

func TestBitDefaultValue(t *testing.T) {
	store := testkit.CreateMockStore(t)
	tk := testkit.NewTestKit(t, store)
	tk.MustExec("use test")
	tk.MustExec("create table t(a bit(32) default b'1100010001001110011000100100111')")
	tk.MustExec("insert into t values ()")
	tk.MustQuery("select hex(a) from t").Check(testkit.Rows("62273127"))
}

It's because b'1100010001001110011000100100111' is converted to "b'1'", and then casted to 1.

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

The test passed

3. What did you see instead (Required)

The test failed

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                      |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.4.0-this-is-a-placeholder
Edition: Community
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@YangKeao YangKeao added the type/bug The issue is confirmed as a bug. label Nov 11, 2024
@YangKeao
Copy link
Member Author

Also, the following DDL didn't produce an error:

create table t(a bit(1) default b'1100010001001110011000100100111')

@YangKeao YangKeao self-assigned this Nov 11, 2024
@ti-chi-bot ti-chi-bot bot added may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Nov 11, 2024
@YangKeao YangKeao added affects-6.1 and removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Nov 11, 2024
@jebter jebter added the sig/sql-infra SIG: SQL Infra label Nov 12, 2024
@YangKeao YangKeao added component/expression sig/execution SIG execution affects-5.4 This bug affects 5.4.x versions. and removed sig/sql-infra SIG: SQL Infra labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants