Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Revert "dump: retrieve ANSI_QUOTES from upstream (#909) (#929)" #1111

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 0 additions & 24 deletions mydumper/mydumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"bufio"
"bytes"
"context"
"database/sql"
"fmt"
"os"
"os/exec"
"regexp"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}