rename parameters

This commit is contained in:
Shlomi Noach 2018-03-07 16:30:02 +02:00
parent 186f083db8
commit 2209136258
6 changed files with 12 additions and 11 deletions

View File

@ -91,7 +91,7 @@ type MigrationContext struct {
SkipRenamedColumns bool
IsTungsten bool
DiscardForeignKeys bool
IncludeRiskCharset bool
IncludeRiskyCharsets bool
config ContextConfig
configMutex *sync.Mutex

View File

@ -120,7 +120,7 @@ func main() {
version := flag.Bool("version", false, "Print version & exit")
checkFlag := flag.Bool("check-flag", false, "Check if another flag exists/supported. This allows for cross-version scripting. Exits with 0 when all additional provided flags exist, nonzero otherwise. You must provide (dummy) values for flags that require a value. Example: gh-ost --check-flag --cut-over-lock-timeout-seconds --nice-ratio 0")
flag.StringVar(&migrationContext.ForceTmpTableName, "force-table-names", "", "table name prefix to be used on the temporary tables")
flag.BoolVar(&migrationContext.IncludeRiskCharset, "include-risk-charset", false, "charset includes risk encoding, e.g. gbk, gb2312, big5, cp932, sjis")
flag.BoolVar(&migrationContext.IncludeRiskyCharsets, "include-risk-charset", false, "charset includes risk encoding, e.g. gbk, gb2312, big5, cp932, sjis")
flag.CommandLine.SetOutput(os.Stdout)
flag.Parse()

View File

@ -69,7 +69,7 @@ func NewApplier(migrationContext *base.MigrationContext) *Applier {
func (this *Applier) InitDBConnections() (err error) {
applierUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
applierUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskyCharsets)
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, applierUri); err != nil {
return err
}

View File

@ -40,7 +40,7 @@ func NewInspector(migrationContext *base.MigrationContext) *Inspector {
}
func (this *Inspector) InitDBConnections() (err error) {
inspectorUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
inspectorUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskyCharsets)
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, inspectorUri); err != nil {
return err
}

View File

@ -103,7 +103,7 @@ func (this *EventsStreamer) notifyListeners(binlogEvent *binlog.BinlogDMLEvent)
}
func (this *EventsStreamer) InitDBConnections() (err error) {
EventsStreamerUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
EventsStreamerUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskyCharsets)
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, EventsStreamerUri); err != nil {
return err
}

View File

@ -49,17 +49,18 @@ func (this *ConnectionConfig) Equals(other *ConnectionConfig) bool {
return this.Key.Equals(&other.Key) || this.ImpliedKey.Equals(other.ImpliedKey)
}
func (this *ConnectionConfig) GetDBUri(databaseName string, includeRiskCharset bool) string {
func (this *ConnectionConfig) GetDBUri(databaseName string, IncludeRiskyCharsets bool) string {
hostname := this.Key.Hostname
var ip = net.ParseIP(hostname)
if (ip != nil) && (ip.To4() == nil) {
// Wrap IPv6 literals in square brackets
hostname = fmt.Sprintf("[%s]", hostname)
}
var riskCharset string
interpolateParams := !includeRiskCharset
if includeRiskCharset {
riskCharset = ",gbk,gb2312,big5,cp932,sjis"
riskyCharsets := ""
interpolateParams := true
if IncludeRiskyCharsets {
interpolateParams = false
riskyCharsets = ",gbk,gb2312,big5,cp932,sjis"
}
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=%t&autocommit=true&charset=utf8mb4,utf8,latin1%s", this.User, this.Password, hostname, this.Key.Port, databaseName, interpolateParams, riskCharset)
return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?interpolateParams=%t&autocommit=true&charset=utf8mb4,utf8,latin1%s", this.User, this.Password, hostname, this.Key.Port, databaseName, interpolateParams, riskyCharsets)
}