-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: the 'max-index-length' check does not respect non-restricted sql_mode #34931
Comments
@CbcWestwolf @bb7133 Has this issue been resolved? I wanna try it. |
Sure :-) Please have a try. |
Thank you! I will reassign this issue to you, glad to hear that. |
@e11jah , just a kind reminder: The `max-index-length' in MySQL(with InnoDB) is hard-coded to 3072, but it is configurable in TiDB because of some histroical reason: https://docs.pingcap.com/tidb/dev/tidb-configuration-file#max-index-length |
@bb7133 @CbcWestwolf Is the implicit truncation behavior in non-restrict sql mode reasonable? Coz I had found that the index truncation behavior in mysql looks like only working with a single varchar column index (not unique). And the multiple column index in which the length sum exceeds the maximum size will return an error instead produce a warning. mysql> select version();
+-------------------------+
| version() |
+-------------------------+
| 8.0.29-0ubuntu0.20.04.3 |
+-------------------------+
1 row in set (0.00 sec)
mysql> create table t (id int(32), name varchar(512), alias varchar(1024),index(name,alias)) charset utf8;
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes
mysql> set @@sql_mode='';
Query OK, 0 rows affected (0.00 sec)
mysql> create table t (id int(32), name varchar(512), alias varchar(1024),index(name,alias)) charset utf8;
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes And the documentation doesn't clearly describe this.
|
According to the documentation posted here, I think we can do such truncation on non-unique index, regardless of one-column index or multi-columns index. In |
@e11jah @CbcWestwolf I think we should follow the behavior of MySQL, TiDB aims to be 100% compatible with MySQL(although it is not possible for all the cases). So for multi columns, please report an error still. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
In MySQL 5.7 & MySQL 8:
Notice that in non-strict SQL mode, MySQL converted the error to warning and truncated the index
name
as a prefix one("name
(1024)"), which met the maximum length of index(3072 bytes / 3 bytes per utf8 encoding = 1024).3. What did you see instead (Required)
In TiDB(all versions with default configuration):
4. What is your TiDB version? (Required)
I am using v6.0 but it applies to all existing versions.
The text was updated successfully, but these errors were encountered: