Skip to content

Commit e0de69b

Browse files
author
Shlomi Noach
committed
a noop operation dumps SHOW CREATE TABLE
1 parent 45625a6 commit e0de69b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

go/logic/inspect.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,14 @@ func (this *Inspector) getSharedColumns(originalColumns, ghostColumns *sql.Colum
516516
return sql.NewColumnList(sharedColumnNames), sql.NewColumnList(mappedSharedColumnNames)
517517
}
518518

519+
// showCreateTable returns the `show create table` statement for given table
520+
func (this *Inspector) showCreateTable(tableName string) (createTableStatement string, err error) {
521+
var dummy string
522+
query := fmt.Sprintf(`show /* gh-ost */ create table %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(tableName))
523+
err = this.db.QueryRow(query).Scan(&dummy, &createTableStatement)
524+
return createTableStatement, err
525+
}
526+
519527
// readChangelogState reads changelog hints
520528
func (this *Inspector) readChangelogState() (map[string]string, error) {
521529
query := fmt.Sprintf(`

go/logic/migrator.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,16 @@ func (this *Migrator) executeWriteFuncs() error {
11731173
// finalCleanup takes actions at very end of migration, dropping tables etc.
11741174
func (this *Migrator) finalCleanup() error {
11751175
atomic.StoreInt64(&this.cleanupImminentFlag, 1)
1176+
1177+
if this.migrationContext.Noop {
1178+
if createTableStatement, err := this.inspector.showCreateTable(this.migrationContext.GetGhostTableName()); err == nil {
1179+
log.Infof("New table structure follows")
1180+
fmt.Println(createTableStatement)
1181+
} else {
1182+
log.Errore(err)
1183+
}
1184+
}
1185+
11761186
if err := this.retryOperation(this.applier.DropChangelogTable); err != nil {
11771187
return err
11781188
}

0 commit comments

Comments
 (0)