Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The following variables are available on all hooks:

The following variable are available on particular hooks:

- `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.
- `GH_OST_COMMAND` is only available in `gh-ost-on-interactive-command`
- `GH_OST_STATUS` is only available in `gh-ost-on-status`
- `GH_OST_LAST_BATCH_COPY_ERROR` is only available in `gh-ost-on-batch-copy-retry`
Expand Down
5 changes: 3 additions & 2 deletions go/logic/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ func (this *HooksExecutor) onInteractiveCommand(command string) error {
return this.executeHooks(onInteractiveCommand, v)
}

func (this *HooksExecutor) onSuccess() error {
return this.executeHooks(onSuccess)
func (this *HooksExecutor) onSuccess(instantDDL bool) error {
v := fmt.Sprintf("GH_OST_INSTANT_DDL=%t", instantDDL)
return this.executeHooks(onSuccess, v)
}

func (this *HooksExecutor) onFailure() error {
Expand Down
2 changes: 2 additions & 0 deletions go/logic/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func TestHooksExecutorExecuteHooks(t *testing.T) {
require.Equal(t, 50.0, progress)
case "GH_OST_TABLE_NAME":
require.Equal(t, migrationContext.OriginalTableName, split[1])
case "GH_OST_INSTANT_DDL":
require.Equal(t, "false", split[1])
case "TEST":
require.Equal(t, t.Name(), split[1])
}
Expand Down
6 changes: 3 additions & 3 deletions go/logic/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (this *Migrator) Migrate() (err error) {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(true); err != nil {
return err
}
this.migrationContext.Log.Infof("Success! table %s.%s migrated instantly", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down Expand Up @@ -620,7 +620,7 @@ func (this *Migrator) Migrate() (err error) {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(false); err != nil {
return err
}
this.migrationContext.Log.Infof("Done migrating %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down Expand Up @@ -734,7 +734,7 @@ func (this *Migrator) Revert() error {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(false); err != nil {
return err
}
this.migrationContext.Log.Infof("Done reverting %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down
Loading