Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: dry run suffix tmp tables (#12708)
p0nybc14e4e7c47b
diff --git a/backend/component/ghost/config.go b/backend/component/ghost/config.goindex 44e3d2039a..cca9db454f 100644--- a/backend/component/ghost/config.go+++ b/backend/component/ghost/config.go@@ -186,7 +186,7 @@ func GetPostponeFlagFilename(taskID int, taskCreatedTs int64, databaseID int, da}// NewMigrationContext is the context for gh-ost migration.-func NewMigrationContext(ctx context.Context, taskID int, taskCreatedTs int64, database *store.DatabaseMessage, dataSource *store.DataSourceMessage, secret string, tableName string, statement string, noop bool, flags map[string]string, serverIDOffset uint) (*base.MigrationContext, error) {+func NewMigrationContext(ctx context.Context, taskID int, taskCreatedTs int64, database *store.DatabaseMessage, dataSource *store.DataSourceMessage, secret string, tableName string, tmpTableNameSuffix string, statement string, noop bool, flags map[string]string, serverIDOffset uint) (*base.MigrationContext, error) {password, err := common.Unobfuscate(dataSource.ObfuscatedPassword, secret)if err != nil {return nil, errors.Wrapf(err, "failed to get password")@@ -316,6 +316,8 @@ func NewMigrationContext(ctx context.Context, taskID int, taskCreatedTs int64, d// Uses specified port. GCP, Aliyun, Azure are equivalent here.migrationContext.GoogleCloudPlatform = true+ migrationContext.ForceTmpTableName = tableName + tmpTableNameSuffix+if migrationContext.SwitchToRowBinlogFormat && migrationContext.AssumeRBR {return nil, errors.Errorf("switchToRBR and assumeRBR are mutually exclusive")}diff --git a/backend/runner/plancheck/ghost_sync_executor.go b/backend/runner/plancheck/ghost_sync_executor.goindex 8febd68a63..dc65a0891a 100644--- a/backend/runner/plancheck/ghost_sync_executor.go+++ b/backend/runner/plancheck/ghost_sync_executor.go@@ -2,7 +2,9 @@ package plancheckimport ("context"+ "fmt""math/rand"+ "time""github.com/github/gh-ost/go/logic""github.com/pkg/errors"@@ -102,7 +104,7 @@ func (e *GhostSyncExecutor) Run(ctx context.Context, config *storepb.PlanCheckRureturn nil, common.Wrapf(err, common.Internal, "failed to parse table name from statement, statement: %v", statement)}- migrationContext, err := ghost.NewMigrationContext(ctx, rand.Intn(10000000), rand.Int63n(10000000), database, adminDataSource, e.secret, tableName, renderedStatement, true, config.GhostFlags, 20000000)+ migrationContext, err := ghost.NewMigrationContext(ctx, rand.Intn(10000000), rand.Int63n(10000000), database, adminDataSource, e.secret, tableName, fmt.Sprintf("_dryrun_%d", time.Now().Unix()), renderedStatement, true, config.GhostFlags, 20000000)if err != nil {return nil, common.Wrapf(err, common.Internal, "failed to create migration context")}diff --git a/backend/runner/taskrun/schema_update_ghost_sync_executor.go b/backend/runner/taskrun/schema_update_ghost_sync_executor.goindex 661d591ab5..7b013e39c0 100644--- a/backend/runner/taskrun/schema_update_ghost_sync_executor.go+++ b/backend/runner/taskrun/schema_update_ghost_sync_executor.go@@ -102,7 +102,7 @@ func (exec *SchemaUpdateGhostSyncExecutor) runGhostMigration(ctx context.Context// To avoid leaking the rendered statement, the error message should use the original statement and not the rendered statement.renderedStatement := utils.RenderStatement(statement, materials)- migrationContext, err := ghost.NewMigrationContext(ctx, task.ID, task.CreatedTs, database, adminDataSource, exec.secret, tableName, renderedStatement, false, flags, 10000000)+ migrationContext, err := ghost.NewMigrationContext(ctx, task.ID, task.CreatedTs, database, adminDataSource, exec.secret, tableName, "", renderedStatement, false, flags, 10000000)if err != nil {return true, nil, errors.Wrap(err, "failed to init migrationContext for gh-ost")}