From 1126924755f664286d8bb4fa1e43cafc61c9324a Mon Sep 17 00:00:00 2001 From: lance6716 Date: Sun, 27 Sep 2020 17:43:11 +0800 Subject: [PATCH] Revert "dump: retrieve ANSI_QUOTES from upstream (#909) (#929)" This reverts commit 3b16803e32c8ce9d6d1e43f4d273288dc2a8be25. --- dm/config/task.go | 2 ++ mydumper/mydumper.go | 24 ------------------------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/dm/config/task.go b/dm/config/task.go index 4aa540fffb..9c50073a56 100644 --- a/dm/config/task.go +++ b/dm/config/task.go @@ -557,6 +557,8 @@ func (c *TaskConfig) SubTaskConfigs(sources map[string]DBConfig) ([]*SubTaskConf cfg.CleanDumpFile = c.CleanDumpFile + cfg.EnableANSIQuotes = c.EnableANSIQuotes + err := cfg.Adjust(true) if err != nil { return nil, terror.Annotatef(err, "source %s", inst.SourceID) diff --git a/mydumper/mydumper.go b/mydumper/mydumper.go index 97a361813a..433601c277 100644 --- a/mydumper/mydumper.go +++ b/mydumper/mydumper.go @@ -17,8 +17,6 @@ import ( "bufio" "bytes" "context" - "database/sql" - "fmt" "os" "os/exec" "regexp" @@ -62,7 +60,6 @@ func NewMydumper(cfg *config.SubTaskConfig) *Mydumper { func (m *Mydumper) Init(ctx context.Context) error { var err error m.args, err = m.constructArgs() - m.detectAnsiQuotes() return err } @@ -319,24 +316,3 @@ func (m *Mydumper) logArgs(cfg *config.SubTaskConfig) []string { } return args } - -// detectAnsiQuotes tries to detect ANSI_QUOTES from upstream. If success, change EnableANSIQuotes in subtask config -func (m *Mydumper) detectAnsiQuotes() { - dbCfg := m.cfg.From - dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/", dbCfg.User, dbCfg.Password, dbCfg.Host, dbCfg.Port) - db, err := sql.Open("mysql", dsn) - if err != nil { - return - } - defer db.Close() - enable, err := utils.HasAnsiQuotesMode(db) - if err != nil { - return - } - if enable != m.cfg.EnableANSIQuotes { - m.logger.Warn("found mismatched ANSI_QUOTES setting, going to overwrite it to DB specified", - zap.Bool("DB specified", enable), - zap.Bool("config file specified", m.cfg.EnableANSIQuotes)) - } - m.cfg.EnableANSIQuotes = enable -}