Skip to content

Commit

Permalink
Add possibility to modify max allowed packet size
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg0 committed Jul 18, 2019
1 parent 5cd7a5e commit 664e822
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.12
require (
github.com/fatih/color v1.7.0
github.com/go-sql-driver/mysql v1.4.1
github.com/greg0/go-mysqldump v0.4.4
github.com/greg0/go-mysqldump v0.4.7
github.com/mattn/go-colorable v0.1.2 // indirect
gopkg.in/yaml.v2 v2.2.2
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ github.com/greg0/go-mysqldump v0.4.3 h1:022rVmevOvXCOycKENOtKO3u4gO37THch2Lzxh+E
github.com/greg0/go-mysqldump v0.4.3/go.mod h1:mnGQCn4TO0r/+hujgI4HiJVukSEErNyNXtbexRbiTME=
github.com/greg0/go-mysqldump v0.4.4 h1:oNOxeQvaGjZCugI3TgmYeg9im/65RKWVvW/YgkBD3Ek=
github.com/greg0/go-mysqldump v0.4.4/go.mod h1:mnGQCn4TO0r/+hujgI4HiJVukSEErNyNXtbexRbiTME=
github.com/greg0/go-mysqldump v0.4.5 h1:bLfDjvL2s8BSXESRFOE9qFelxxh4mXv6GYi22DZqarg=
github.com/greg0/go-mysqldump v0.4.5/go.mod h1:mnGQCn4TO0r/+hujgI4HiJVukSEErNyNXtbexRbiTME=
github.com/greg0/go-mysqldump v0.4.6 h1:Wp+otD4sBaLKhvv0rDRCDXH/o2dBcz+uxyVcMSyItag=
github.com/greg0/go-mysqldump v0.4.6/go.mod h1:mnGQCn4TO0r/+hujgI4HiJVukSEErNyNXtbexRbiTME=
github.com/greg0/go-mysqldump v0.4.7 h1:gEEXR25u4abFuHaSyQnDhy1y5+IgXWaiJGNnhYXHkSo=
github.com/greg0/go-mysqldump v0.4.7/go.mod h1:mnGQCn4TO0r/+hujgI4HiJVukSEErNyNXtbexRbiTME=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Options struct {
IgnoredTables []string
StructureOnlyTables []string
OutputDirectory string
PacketSize int
}

func main() {
Expand Down Expand Up @@ -82,6 +83,7 @@ func main() {
dumpFilenameFormat,
options.StructureOnlyTables,
options.IgnoredTables,
options.PacketSize,
)
if err != nil {
fmt.Println("Error registering databse:", err)
Expand Down Expand Up @@ -131,6 +133,9 @@ func GetOptions() *Options {
var outputdir string
flag.StringVar(&outputdir, "output", "", "Dump output dir. Default is current working directory")

var packetSize int
flag.IntVar(&packetSize, "packetSize", 1048576, "Max allowed packet size. Default 1048576 (1MB)")

if len(os.Args) <= 1 || os.Args[1] == "--help" {
flag.PrintDefaults()
os.Exit(1)
Expand Down Expand Up @@ -179,7 +184,8 @@ func GetOptions() *Options {
database,
ignoredTablesArray,
structOnlyTablesArray,
outputdir)
outputdir,
packetSize)

stropts, _ := json.MarshalIndent(opts, "", "\t")
printMessage("Running with parameters", Info)
Expand All @@ -205,7 +211,7 @@ func FillArrayWithFileLines(filePath string) []string {
return array
}

func (o *Options) create(name string, address string, username string, password string, database string, ignoredTables []string, structOnlyTables []string, outputDir string) *Options {
func (o *Options) create(name string, address string, username string, password string, database string, ignoredTables []string, structOnlyTables []string, outputDir string, packetSize int) *Options {

database = strings.Replace(database, " ", "", -1)
database = strings.Replace(database, " , ", ",", -1)
Expand All @@ -221,6 +227,7 @@ func (o *Options) create(name string, address string, username string, password
IgnoredTables: ignoredTables,
StructureOnlyTables: structOnlyTables,
OutputDirectory: outputDir,
PacketSize: packetSize,
}
}

Expand Down

0 comments on commit 664e822

Please sign in to comment.