File tree Expand file tree Collapse file tree 4 files changed +9
-5
lines changed
Expand file tree Collapse file tree 4 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ The following variables are available on all hooks:
8181
8282The following variable are available on particular hooks:
8383
84+ - ` GH_OST_INSTANT_DDL ` is only available in ` gh-ost-on-success ` . The value is ` true ` if instant DDL was successful, and ` false ` if it was not.
8485- ` GH_OST_COMMAND ` is only available in ` gh-ost-on-interactive-command `
8586- ` GH_OST_STATUS ` is only available in ` gh-ost-on-status `
8687- ` GH_OST_LAST_BATCH_COPY_ERROR ` is only available in ` gh-ost-on-batch-copy-retry `
Original file line number Diff line number Diff line change @@ -148,8 +148,9 @@ func (this *HooksExecutor) onInteractiveCommand(command string) error {
148148 return this .executeHooks (onInteractiveCommand , v )
149149}
150150
151- func (this * HooksExecutor ) onSuccess () error {
152- return this .executeHooks (onSuccess )
151+ func (this * HooksExecutor ) onSuccess (instantDDL bool ) error {
152+ v := fmt .Sprintf ("GH_OST_INSTANT_DDL=%t" , instantDDL )
153+ return this .executeHooks (onSuccess , v )
153154}
154155
155156func (this * HooksExecutor ) onFailure () error {
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ func TestHooksExecutorExecuteHooks(t *testing.T) {
105105 require .Equal (t , 50.0 , progress )
106106 case "GH_OST_TABLE_NAME" :
107107 require .Equal (t , migrationContext .OriginalTableName , split [1 ])
108+ case "GH_OST_INSTANT_DDL" :
109+ require .Equal (t , "false" , split [1 ])
108110 case "TEST" :
109111 require .Equal (t , t .Name (), split [1 ])
110112 }
Original file line number Diff line number Diff line change @@ -617,7 +617,7 @@ func (this *Migrator) Migrate() (err error) {
617617 if err := this .finalCleanup (); err != nil {
618618 return nil
619619 }
620- if err := this .hooksExecutor .onSuccess (); err != nil {
620+ if err := this .hooksExecutor .onSuccess (false ); err != nil {
621621 return err
622622 }
623623 this .migrationContext .Log .Infof ("Done migrating %s.%s" , sql .EscapeName (this .migrationContext .DatabaseName ), sql .EscapeName (this .migrationContext .OriginalTableName ))
@@ -731,7 +731,7 @@ func (this *Migrator) Revert() error {
731731 if err := this .finalCleanup (); err != nil {
732732 return nil
733733 }
734- if err := this .hooksExecutor .onSuccess (); err != nil {
734+ if err := this .hooksExecutor .onSuccess (false ); err != nil {
735735 return err
736736 }
737737 this .migrationContext .Log .Infof ("Done reverting %s.%s" , sql .EscapeName (this .migrationContext .DatabaseName ), sql .EscapeName (this .migrationContext .OriginalTableName ))
@@ -1093,7 +1093,7 @@ func (this *Migrator) attemptInstantDDLEarly() error {
10931093 return err
10941094 }
10951095
1096- if err := this .hooksExecutor .onSuccess (); err != nil {
1096+ if err := this .hooksExecutor .onSuccess (true ); err != nil {
10971097 return err
10981098 }
10991099 this .migrationContext .Log .Infof ("Successfully executed instant DDL on %s.%s (no ghost table was needed)" ,
You can’t perform that action at this time.
0 commit comments