Skip to content

Commit 07ca784

Browse files
WiFengsiddontang
authored andcommitted
fix mysqldump option (go-mysql-org#449)
* fix mysqldump option
1 parent 7a7f047 commit 07ca784

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

canal/canal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func (c *Canal) prepareDumper() error {
155155
c.dumper.SkipMasterData(c.cfg.Dump.SkipMasterData)
156156
c.dumper.SetMaxAllowedPacket(c.cfg.Dump.MaxAllowedPacketMB)
157157
c.dumper.SetProtocol(c.cfg.Dump.Protocol)
158+
c.dumper.SetExtraOptions(c.cfg.Dump.ExtraOptions)
158159
// Use hex blob for mysqldump
159160
c.dumper.SetHexBlob(true)
160161

canal/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ type DumpConfig struct {
3939

4040
// Set to change the default protocol to connect with
4141
Protocol string `toml:"protocol"`
42+
43+
// Set extra options
44+
ExtraOptions []string `toml:"extra_options"`
4245
}
4346

4447
type Config struct {

dump/dump.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type Dumper struct {
3333

3434
IgnoreTables map[string][]string
3535

36+
ExtraOptions []string
37+
3638
ErrOut io.Writer
3739

3840
masterDataSkipped bool
@@ -59,6 +61,7 @@ func NewDumper(executionPath string, addr string, user string, password string)
5961
d.Databases = make([]string, 0, 16)
6062
d.Charset = DEFAULT_CHARSET
6163
d.IgnoreTables = make(map[string][]string)
64+
d.ExtraOptions = make([]string, 0, 5)
6265
d.masterDataSkipped = false
6366

6467
d.ErrOut = os.Stderr
@@ -78,6 +81,10 @@ func (d *Dumper) SetWhere(where string) {
7881
d.Where = where
7982
}
8083

84+
func (d *Dumper) SetExtraOptions(options []string) {
85+
d.ExtraOptions = options
86+
}
87+
8188
func (d *Dumper) SetErrOut(o io.Writer) {
8289
d.ErrOut = o
8390
}
@@ -185,6 +192,10 @@ func (d *Dumper) Dump(w io.Writer) error {
185192
args = append(args, fmt.Sprintf("--where=%s", d.Where))
186193
}
187194

195+
if len(d.ExtraOptions) != 0 {
196+
args = append(args, d.ExtraOptions...)
197+
}
198+
188199
if len(d.Tables) == 0 && len(d.Databases) == 0 {
189200
args = append(args, "--all-databases")
190201
} else if len(d.Tables) == 0 {

0 commit comments

Comments
 (0)