-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
TiDB does not trim space from ENUM DEFAULT definition #29327
Comments
Verified against master. The specific issue is the default value is not trimmed for comparison to the list of possible values: tidb> create table t1 (a enum (' ','a','b ') not null default 'b ');
ERROR 1067 (42000): Invalid default value for 'a'
tidb> create table t1 (a enum (' ','a','b ') not null default 'b');
Query OK, 0 rows affected (0.12 sec) |
similar with #18949 |
It looks like it was an incomplete fix when accounting for |
Is there anyone working on this issue, if not, I will fix this :) |
when the default value has the tailing space, MySQL will trim the space. See the
mysql> create table t(a enum('a') not null default 'a ');
Query OK, 0 rows affected (0.03 sec)
mysql> show create table t;
+-------+----------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` enum('a') NOT NULL DEFAULT 'a'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec) tidb will report error because |
@xiongjiwei Are you sure that the default value should be trimmed, no matter whether new collation is enabled? |
actually, I am wrong, it is related to the collation. we should also revert pingcap/parser#1006, that is a wrong fix 😥 |
I think it may be fine to keep trimming the space even when new collation is not enabled, as long as it doesn't lead to any bug. |
I don't see any reason that users DO NOT want trimming spaces for SET/ENUM values. |
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: