rename includeMultibyteCharset -> includeRiskCharset, multibyteCharset -> riskCharset
This commit is contained in:
parent
14315ee2cc
commit
330650baa9
@ -91,7 +91,7 @@ type MigrationContext struct {
|
|||||||
SkipRenamedColumns bool
|
SkipRenamedColumns bool
|
||||||
IsTungsten bool
|
IsTungsten bool
|
||||||
DiscardForeignKeys bool
|
DiscardForeignKeys bool
|
||||||
IncludeMultibyteCharset bool
|
IncludeRiskCharset bool
|
||||||
|
|
||||||
config ContextConfig
|
config ContextConfig
|
||||||
configMutex *sync.Mutex
|
configMutex *sync.Mutex
|
||||||
|
@ -121,7 +121,7 @@ func main() {
|
|||||||
version := flag.Bool("version", false, "Print version & exit")
|
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")
|
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.StringVar(&migrationContext.ForceTmpTableName, "force-table-names", "", "table name prefix to be used on the temporary tables")
|
||||||
flag.BoolVar(&migrationContext.IncludeMultibyteCharset, "include-multibyte-charset", false, "charset includes multibyte encoding, e.g. gbk, gb2312, big5, cp932, sjis")
|
flag.BoolVar(&migrationContext.IncludeRiskCharset, "include-risk-charset", false, "charset includes risk encoding, e.g. gbk, gb2312, big5, cp932, sjis")
|
||||||
flag.CommandLine.SetOutput(os.Stdout)
|
flag.CommandLine.SetOutput(os.Stdout)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -69,7 +69,7 @@ func NewApplier(migrationContext *base.MigrationContext) *Applier {
|
|||||||
|
|
||||||
func (this *Applier) InitDBConnections() (err error) {
|
func (this *Applier) InitDBConnections() (err error) {
|
||||||
|
|
||||||
applierUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeMultibyteCharset)
|
applierUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
|
||||||
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, applierUri); err != nil {
|
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, applierUri); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ func NewInspector(migrationContext *base.MigrationContext) *Inspector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Inspector) InitDBConnections() (err error) {
|
func (this *Inspector) InitDBConnections() (err error) {
|
||||||
inspectorUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeMultibyteCharset)
|
inspectorUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
|
||||||
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, inspectorUri); err != nil {
|
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, inspectorUri); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ func (this *EventsStreamer) notifyListeners(binlogEvent *binlog.BinlogDMLEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *EventsStreamer) InitDBConnections() (err error) {
|
func (this *EventsStreamer) InitDBConnections() (err error) {
|
||||||
EventsStreamerUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeMultibyteCharset)
|
EventsStreamerUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName, this.migrationContext.IncludeRiskCharset)
|
||||||
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, EventsStreamerUri); err != nil {
|
if this.db, _, err = mysql.GetDB(this.migrationContext.Uuid, EventsStreamerUri); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,17 @@ func (this *ConnectionConfig) Equals(other *ConnectionConfig) bool {
|
|||||||
return this.Key.Equals(&other.Key) || this.ImpliedKey.Equals(other.ImpliedKey)
|
return this.Key.Equals(&other.Key) || this.ImpliedKey.Equals(other.ImpliedKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ConnectionConfig) GetDBUri(databaseName string, includeMultibyte bool) string {
|
func (this *ConnectionConfig) GetDBUri(databaseName string, includeRiskCharset bool) string {
|
||||||
hostname := this.Key.Hostname
|
hostname := this.Key.Hostname
|
||||||
var ip = net.ParseIP(hostname)
|
var ip = net.ParseIP(hostname)
|
||||||
if (ip != nil) && (ip.To4() == nil) {
|
if (ip != nil) && (ip.To4() == nil) {
|
||||||
// Wrap IPv6 literals in square brackets
|
// Wrap IPv6 literals in square brackets
|
||||||
hostname = fmt.Sprintf("[%s]", hostname)
|
hostname = fmt.Sprintf("[%s]", hostname)
|
||||||
}
|
}
|
||||||
var multibyteCharset string
|
var riskCharset string
|
||||||
if includeMultibyte {
|
interpolateParams := !includeRiskCharset
|
||||||
multibyteCharset = ",gbk,gb2312,big5,cp932,sjis"
|
if includeRiskCharset {
|
||||||
|
riskCharset = ",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, !includeMultibyte, multibyteCharset)
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user