Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ywqzzy committed Mar 25, 2024
1 parent 25b1f77 commit 725e2e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -2049,3 +2049,12 @@ func getChangingColumnOriginName(changingColumn *model.ColumnInfo) string {
}
return columnName[:pos]
}

func getExpressionIndexOriginName(expressionIdx *model.ColumnInfo) string {
columnName := strings.TrimPrefix(expressionIdx.Name.O, expressionIndexPrefix+"_")
var pos int
if pos = strings.LastIndex(columnName, "_"); pos == -1 {
return columnName
}
return columnName[:pos]
}
5 changes: 3 additions & 2 deletions pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2568,8 +2568,9 @@ func renameIndexes(tblInfo *model.TableInfo, from, to model.CIStr) {

func renameHiddenColumns(tblInfo *model.TableInfo, from, to model.CIStr) {
for _, col := range tblInfo.Columns {
if strings.Contains(col.Name.O, fmt.Sprintf("%s_%s", expressionIndexPrefix, from)) {
col.Name = model.NewCIStr(strings.ReplaceAll(col.Name.O, from.O, to.O))
if getExpressionIndexOriginName(col) == from.O {
col.Name.L = strings.Replace(col.Name.L, from.L, to.L, 1)
col.Name.O = strings.Replace(col.Name.O, from.O, to.O, 1)
}
}
}

0 comments on commit 725e2e6

Please sign in to comment.