Remove GetDB from MigrationContext

This commit is contained in:
Nikhil Mathew 2017-11-10 15:31:45 -08:00
parent d92c037f1b
commit 338a439c91

View File

@ -200,9 +200,6 @@ type MigrationContext struct {
recentBinlogCoordinates mysql.BinlogCoordinates
CanStopStreaming func() bool
knownDBs map[string]*gosql.DB
knownDBsMutex *sync.Mutex
}
type ContextConfig struct {
@ -236,8 +233,6 @@ func NewMigrationContext() *MigrationContext {
pointOfInterestTimeMutex: &sync.Mutex{},
ColumnRenameMap: make(map[string]string),
PanicAbort: make(chan error),
knownDBsMutex: &sync.Mutex{},
knownDBs: make(map[string]*gosql.DB),
}
}
@ -250,23 +245,6 @@ func getSafeTableName(baseName string, suffix string) string {
return fmt.Sprintf("_%s_%s", baseName[0:len(baseName)-extraCharacters], suffix)
}
// GetDB returns a DB instance based on uri.
// bool result indicates whether the DB was returned from cache; err
func (this *MigrationContext) GetDB(mysql_uri string) (*gosql.DB, bool, error) {
this.knownDBsMutex.Lock()
defer this.knownDBsMutex.Unlock()
var exists bool
if _, exists = this.knownDBs[mysql_uri]; !exists {
if db, err := sqlutils.GetDB(mysql_uri); err == nil {
this.knownDBs[mysql_uri] = db
} else {
return db, exists, err
}
}
return this.knownDBs[mysql_uri], exists, nil
}
// GetGhostTableName generates the name of ghost table, based on original table name
// or a given table name
func (this *MigrationContext) GetGhostTableName() string {