diff --git a/pkg/backup/client.go b/pkg/backup/client.go index 6cd8abe45..72563096b 100644 --- a/pkg/backup/client.go +++ b/pkg/backup/client.go @@ -224,6 +224,16 @@ func BuildBackupRangeAndSchema( zap.Stringer("table", tableInfo.Name), zap.Int64("AutoIncID", globalAutoID)) + // remove all non-public indices + n := 0 + for _, index := range tableInfo.Indices { + if index.State == model.StatePublic { + tableInfo.Indices[n] = index + n++ + } + } + tableInfo.Indices = tableInfo.Indices[:n] + if dbData == nil { dbData, err = json.Marshal(dbInfo) if err != nil { diff --git a/pkg/gluetidb/glue.go b/pkg/gluetidb/glue.go index f6378c6e9..73ef66e4f 100644 --- a/pkg/gluetidb/glue.go +++ b/pkg/gluetidb/glue.go @@ -74,7 +74,16 @@ func (gs *tidbSession) CreateDatabase(ctx context.Context, schema *model.DBInfo) // CreateTable implements glue.Session func (gs *tidbSession) CreateTable(ctx context.Context, dbName model.CIStr, table *model.TableInfo) error { d := domain.GetDomain(gs.se).DDL() - return d.CreateTableWithInfo(gs.se, dbName, table.Clone(), ddl.OnExistIgnore, true) + + // Clone() does not clone partitions yet :( + table = table.Clone() + if table.Partition != nil { + newPartition := *table.Partition + newPartition.Definitions = append([]model.PartitionDefinition{}, table.Partition.Definitions...) + table.Partition = &newPartition + } + + return d.CreateTableWithInfo(gs.se, dbName, table, ddl.OnExistIgnore, true) } // Close implements glue.Session