Skip to content

Commit

Permalink
Finish MySQL support and fix type bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
christhemorse committed Aug 15, 2024
1 parent dcc3d31 commit 753eec3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 11 additions & 3 deletions cmd/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
o.AdvancedOptionsReq.InnoDBLockWaitTimeout = innoDBLockWaitTimeout
}

iif cmd.Flags().Changed("innodb-log-buffer-size") {
if cmd.Flags().Changed("innodb-log-buffer-size") {
o.AdvancedOptionsReq.InnoDBLogBufferSize = innoDBLogBufferSize
}

Expand All @@ -2216,15 +2216,15 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
}

if cmd.Flags().Changed("innodb-print-all-deadlocks") {
o.AdvancedOptionsReq.InnoDBPrintAllDeadlocks = innoDBPrintAllDeadlocks
o.AdvancedOptionsReq.InnoDBPrintAllDeadlocks = nil
}

if cmd.Flags().Changed("innodb-read-io-threads") {
o.AdvancedOptionsReq.InnoDBReadIOThreads = innoDBReadIOThreads
}

if cmd.Flags().Changed("innodb-rollback-on-timeout") {
o.AdvancedOptionsReq.InnoDBRollbackOnTimeout = innoDBRollbackOnTimeout
o.AdvancedOptionsReq.InnoDBRollbackOnTimeout = nil
}

if cmd.Flags().Changed("innodb-thread-concurrency") {
Expand Down Expand Up @@ -2391,6 +2391,14 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
o.AdvancedOptionsReq.Jit = &jit
}

if cmd.Flags().Changed("innodb-print-all-deadlocks") {
o.AdvancedOptionsReq.InnoDBPrintAllDeadlocks = &innoDBPrintAllDeadlocks
}

if cmd.Flags().Changed("innodb-rollback-on-timeout") {
o.AdvancedOptionsReq.InnoDBRollbackOnTimeout = &innoDBRollbackOnTimeout
}

cur, avail, err := o.updateAdvancedOptions()
if err != nil {
return fmt.Errorf("error updating database advanced options : %v", err)
Expand Down
16 changes: 13 additions & 3 deletions cmd/database/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,19 @@ func (a *AdvancedOptionsPrinter) Data() [][]string {
v := reflect.ValueOf(*a.Configured)
for i := 0; i < v.NumField(); i++ {
if !v.Field(i).IsZero() {
if v.Field(i).Kind() == reflect.Pointer {
data = append(data, []string{v.Type().Field(i).Name, v.Field(i).Elem().Interface().(string)})
} else {
switch v.Field(i).Kind() {
case reflect.Pointer:
data = append(data, []string{v.Type().Field(i).Name, strconv.FormatBool(v.Field(i).Elem().Interface().(bool))})
case reflect.Int:
data = append(data, []string{v.Type().Field(i).Name, strconv.Itoa(v.Field(i).Interface().(int))})
case reflect.Float64:
data = append(data,
[]string{
v.Type().Field(i).Name,
strconv.FormatFloat(float64(v.Field(i).Interface().(float64)), 'f', utils.FloatPrecision, 32),
},
)
default:
data = append(data, []string{v.Type().Field(i).Name, v.Field(i).Interface().(string)})
}
}
Expand Down

0 comments on commit 753eec3

Please sign in to comment.