Remove GetDB from MigrationContext
This commit is contained in:
parent
d92c037f1b
commit
338a439c91
@ -200,9 +200,6 @@ type MigrationContext struct {
|
|||||||
recentBinlogCoordinates mysql.BinlogCoordinates
|
recentBinlogCoordinates mysql.BinlogCoordinates
|
||||||
|
|
||||||
CanStopStreaming func() bool
|
CanStopStreaming func() bool
|
||||||
|
|
||||||
knownDBs map[string]*gosql.DB
|
|
||||||
knownDBsMutex *sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContextConfig struct {
|
type ContextConfig struct {
|
||||||
@ -236,8 +233,6 @@ func NewMigrationContext() *MigrationContext {
|
|||||||
pointOfInterestTimeMutex: &sync.Mutex{},
|
pointOfInterestTimeMutex: &sync.Mutex{},
|
||||||
ColumnRenameMap: make(map[string]string),
|
ColumnRenameMap: make(map[string]string),
|
||||||
PanicAbort: make(chan error),
|
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)
|
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
|
// GetGhostTableName generates the name of ghost table, based on original table name
|
||||||
// or a given table name
|
// or a given table name
|
||||||
func (this *MigrationContext) GetGhostTableName() string {
|
func (this *MigrationContext) GetGhostTableName() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user