diff --git a/go/base/utils.go b/go/base/utils.go index aeaf5b64e..76205fbf4 100644 --- a/go/base/utils.go +++ b/go/base/utils.go @@ -6,6 +6,7 @@ package base import ( + "errors" "fmt" "os" "regexp" @@ -62,6 +63,10 @@ func StringContainsAll(s string, substrings ...string) bool { } func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, migrationContext *MigrationContext, name string) (string, error) { + if err := validateOceanBaseConnection(db, migrationContext); err != nil { + return "", err + } + versionQuery := `select @@global.version` var version string @@ -102,3 +107,26 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, return "", fmt.Errorf("Unexpected database port reported: %+v / extra_port: %+v", port, extraPort) } } + +func validateOceanBaseConnection(db *gosql.DB, migrationContext *MigrationContext) error { + versionCommentQuery := `select @@global.version_comment` + var versionComment string + if err := db.QueryRow(versionCommentQuery).Scan(&versionComment); err != nil { + return nil + } + if !strings.Contains(versionComment, "OceanBase") { + return nil + } + + migrationContext.OceanBase = true + + enableLockPriorityQuery := `select value from oceanbase.GV$OB_PARAMETERS where name='enable_lock_priority'` + var enableLockPriority bool + if err := db.QueryRow(enableLockPriorityQuery).Scan(&enableLockPriority); err != nil { + return err + } + if !enableLockPriority { + return errors.New("system parameter 'enable_lock_priority' should be true to support cut-over") + } + return nil +} diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 0f86d6e93..3e6057995 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -86,7 +86,6 @@ func main() { flag.BoolVar(&migrationContext.AliyunRDS, "aliyun-rds", false, "set to 'true' when you execute on Aliyun RDS.") flag.BoolVar(&migrationContext.GoogleCloudPlatform, "gcp", false, "set to 'true' when you execute on a 1st generation Google Cloud Platform (GCP).") flag.BoolVar(&migrationContext.AzureMySQL, "azure", false, "set to 'true' when you execute on Azure Database on MySQL.") - flag.BoolVar(&migrationContext.OceanBase, "oceanbase", false, "set to 'true' when you execute on OceanBase") executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit") flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")