Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func indexColumnsLen(cols []*model.ColumnInfo, idxCols []*model.IndexColumn, col

// checkIndexColumn will be run for all non-columnar indexes.
func checkIndexColumn(col *model.ColumnInfo, indexColumnLen int, suppressTooLongKeyErr bool) error {
if col.GetFlen() == 0 && (types.IsTypeChar(col.FieldType.GetType()) || types.IsTypeVarchar(col.FieldType.GetType())) {
if col.FieldType.GetType() == mysql.TypeNull || (col.GetFlen() == 0 && (types.IsTypeChar(col.FieldType.GetType()) || types.IsTypeVarchar(col.FieldType.GetType()))) {
if col.Hidden {
return errors.Trace(dbterror.ErrWrongKeyColumnFunctionalIndex.GenWithStackByArgs(col.GeneratedExprString))
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integrationtest/r/ddl/db_integration.result
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ Error 3800 (HY000): Expression of expression index 'k' cannot refer to a row val
create table t (j json, key k ((j+1),(j+1)));
create table t1 (col1 int, index ((concat(''))));
Error 3761 (HY000): The used storage engine cannot index the expression 'concat(_utf8mb4'')'
create table t1 (col1 int, index ((null)));
Error 3761 (HY000): The used storage engine cannot index the expression 'null'
CREATE TABLE t1 (col1 INT, PRIMARY KEY ((ABS(col1))) NONCLUSTERED);
Error 3756 (HY000): The primary key cannot be an expression index
drop table if exists t;
Expand Down
2 changes: 2 additions & 0 deletions tests/integrationtest/t/ddl/db_integration.test
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ create table t (j json, key k (((j,j))));
create table t (j json, key k ((j+1),(j+1)));
-- error 3761
create table t1 (col1 int, index ((concat(''))));
-- error 3761
create table t1 (col1 int, index ((null)));
-- error 3756
CREATE TABLE t1 (col1 INT, PRIMARY KEY ((ABS(col1))) NONCLUSTERED);

Expand Down