Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
fix shemas.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Relax4Life committed Jun 15, 2021
1 parent 29decea commit 33f6b11
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/utils/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
"github.com/pingcap/br/pkg/metautil"
)

// temporaryDBNamePrefix is the prefix name of system db, e.g. mysql system db will be rename to __TiDB_BR_Temporary_mysql
const temporaryDBNamePrefix = "__TiDB_BR_Temporary_"

// NeedAutoID checks whether the table needs backing up with an autoid.
func NeedAutoID(tblInfo *model.TableInfo) bool {
hasRowID := !tblInfo.PKIsHandle && !tblInfo.IsCommonHandle
Expand Down Expand Up @@ -102,12 +105,13 @@ func IsSysDB(dbLowerName string) bool {

// TemporaryDBName makes a 'private' database name.
func TemporaryDBName(db string) model.CIStr {
return model.NewCIStr("__TiDB_BR_Temporary_" + db)
return model.NewCIStr(temporaryDBNamePrefix + db)
}

// GetSysDBName get the original name of system DB
func GetSysDBName(tempDB model.CIStr) (string, bool) {
ok := strings.Contains(tempDB.O, "__TiDB_BR_Temporary_")
i := strings.LastIndex(tempDB.O, "_")
return tempDB.O[i+1:], ok
if ok := strings.HasPrefix(tempDB.O, temporaryDBNamePrefix); !ok {
return tempDB.O, false
}
return tempDB.O[len(temporaryDBNamePrefix):], true
}

0 comments on commit 33f6b11

Please sign in to comment.