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

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Mar 30, 2020
1 parent fbf3de9 commit 1dab736
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,18 @@ const (
type RestoreConfig struct {
Config

Online bool `json:"online" toml:"online"`
NoSchema bool `json:"no-schema" toml:"no-schema"`
MaxIndexLength int `json:"max-index-length" toml:"max-index-length"`
Online bool `json:"online" toml:"online"`
NoSchema bool `json:"no-schema" toml:"no-schema"`
}

// DefineRestoreFlags defines common flags for the restore command.
func DefineRestoreFlags(flags *pflag.FlagSet) {
// TODO remove experimental tag if it's stable
flags.Bool(flagOnline, false, "(experimental) Whether online when restore")
flags.Bool(flagNoSchema, false, "skip creating schemas and tables, reuse existing empty ones")
flags.Int(flagMaxIndexLength, 3072, "need keep this as same as tidb max-index-length")

// Do not expose this flag
_ = flags.MarkHidden(flagNoSchema)
_ = flags.MarkHidden(flagMaxIndexLength)
}

// ParseFromFlags parses the restore-related flags from the flag set.
Expand All @@ -76,10 +73,6 @@ func (cfg *RestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error {
if err != nil {
return errors.Trace(err)
}
cfg.MaxIndexLength, err = flags.GetInt(flagMaxIndexLength)
if err != nil {
return errors.Trace(err)
}
err = cfg.Config.ParseFromFlags(flags)
if err != nil {
return errors.Trace(err)
Expand Down Expand Up @@ -158,9 +151,11 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
}
// execute DDL first

// set max index length before execute DDLs and create tables
// set max-index-length before execute DDLs and create tables
// we set this value to max(3072*4), otherwise we might not restore table
// when upstream and downstream both set this value greater than default(3072)
conf := config.GetGlobalConfig()
conf.MaxIndexLength = cfg.MaxIndexLength
conf.MaxIndexLength = config.DefMaxOfMaxIndexLength
config.StoreGlobalConfig(conf)

err = client.ExecDDLs(ddlJobs)
Expand Down

0 comments on commit 1dab736

Please sign in to comment.