Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support to use OceanBase as instance (#5353)

He Wangb4d3046d2984
diff --git a/backend/api/v1/common.go b/backend/api/v1/common.go
index 3d8af7ef20..f9a0d64342 100644
--- a/backend/api/v1/common.go
+++ b/backend/api/v1/common.go
@@ -506,6 +506,8 @@ func convertToEngine(engine db.Type) v1pb.Engine {
return v1pb.Engine_REDSHIFT
case db.MariaDB:
return v1pb.Engine_MARIADB
+ case db.OceanBase:
+ return v1pb.Engine_OCEANBASE
}
return v1pb.Engine_ENGINE_UNSPECIFIED
}
@@ -538,6 +540,8 @@ func convertEngine(engine v1pb.Engine) db.Type {
return db.Redshift
case v1pb.Engine_MARIADB:
return db.MariaDB
+ case v1pb.Engine_OCEANBASE:
+ return db.OceanBase
}
return db.UnknownType
}
diff --git a/backend/api/v1/instance_role_service.go b/backend/api/v1/instance_role_service.go
index c4636ad81b..38cb133dbb 100644
--- a/backend/api/v1/instance_role_service.go
+++ b/backend/api/v1/instance_role_service.go
@@ -289,7 +289,7 @@ func validateRole(dbType db.Type, upsert *db.DatabaseRoleUpsertMessage) error {
return status.Errorf(codes.InvalidArgument, "Invalid timestamp for valid_until, timestamp should in '2006-01-02T15:04:05+08:00' format.")
}
}
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
if v := upsert.ConnectionLimit; v != nil && *v < int32(0) {
return status.Errorf(codes.InvalidArgument, "Invalid connection limit, it should greater than or equal to -1")
}
diff --git a/backend/component/dbfactory/dbfactory.go b/backend/component/dbfactory/dbfactory.go
index bc48b1b7b2..93c4074c79 100644
--- a/backend/component/dbfactory/dbfactory.go
+++ b/backend/component/dbfactory/dbfactory.go
@@ -41,7 +41,7 @@ func (d *DBFactory) GetAdminDatabaseDriver(ctx context.Context, instance *store.
dbBinDir := ""
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
// TODO(d): use maria mysqlbinlog for MariaDB.
dbBinDir = d.mysqlBinDir
case db.Postgres:
@@ -124,7 +124,7 @@ func (d *DBFactory) GetReadOnlyDatabaseDriver(ctx context.Context, instance *sto
dbBinDir := ""
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
// TODO(d): use maria mysqlbinlog for MariaDB.
dbBinDir = d.mysqlBinDir
case db.Postgres:
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index 4f5297101f..1d64c85af7 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -27,6 +27,8 @@ const (
ClickHouse Type = "CLICKHOUSE"
// MySQL is the database type for MYSQL.
MySQL Type = "MYSQL"
+ // OceanBase is the database type for OCEANBASE.
+ OceanBase Type = "OCEANBASE"
// Postgres is the database type for POSTGRES.
Postgres Type = "POSTGRES"
// Snowflake is the database type for SNOWFLAKE.
diff --git a/backend/plugin/db/mysql/dump.go b/backend/plugin/db/mysql/dump.go
index 75f4791d8f..118dfe5c9e 100644
--- a/backend/plugin/db/mysql/dump.go
+++ b/backend/plugin/db/mysql/dump.go
@@ -19,6 +19,7 @@ import (
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
api "github.com/bytebase/bytebase/backend/legacyapi"
+ "github.com/bytebase/bytebase/backend/plugin/db"
"github.com/bytebase/bytebase/backend/plugin/db/util"
"github.com/bytebase/bytebase/backend/resources/mysqlutil"
)
@@ -122,8 +123,8 @@ func (driver *Driver) Dump(ctx context.Context, out io.Writer, schemaOnly bool)
}
options := sql.TxOptions{}
- // TiDB does not support readonly, so we only set for MySQL.
- if driver.dbType == "MYSQL" {
+ // TiDB does not support readonly, so we only set for MySQL and OceanBase.
+ if driver.dbType == "MYSQL" || driver.dbType == "OCEANBASE" {
options.ReadOnly = true
}
// If `schemaOnly` is false, now we are still holding the tables' exclusive locks.
@@ -136,7 +137,7 @@ func (driver *Driver) Dump(ctx context.Context, out io.Writer, schemaOnly bool)
defer txn.Rollback()
log.Debug("begin to dump database", zap.String("database", driver.databaseName), zap.Bool("schemaOnly", schemaOnly))
- if err := dumpTxn(ctx, txn, driver.databaseName, out, schemaOnly); err != nil {
+ if err := dumpTxn(ctx, txn, driver.dbType, driver.databaseName, out, schemaOnly); err != nil {
return "", err
}
@@ -183,7 +184,7 @@ func FlushTablesWithReadLock(ctx context.Context, conn *sql.Conn, database strin
return txn.Commit()
}
-func dumpTxn(ctx context.Context, txn *sql.Tx, database string, out io.Writer, schemaOnly bool) error {
+func dumpTxn(ctx context.Context, txn *sql.Tx, dbType db.Type, database string, out io.Writer, schemaOnly bool) error {
// Find all dumpable databases
dbNames, err := getDatabases(ctx, txn)
if err != nil {
@@ -300,7 +301,7 @@ func dumpTxn(ctx context.Context, txn *sql.Tx, database string, out io.Writer, s
}
// Procedure and function (routine) statements.
- routines, err := getRoutines(txn, dbName)
+ routines, err := getRoutines(txn, dbType, dbName)
if err != nil {
return errors.Wrapf(err, "failed to get routines of database %q", dbName)
}
@@ -310,14 +311,17 @@ func dumpTxn(ctx context.Context, txn *sql.Tx, database string, out io.Writer, s
}
}
- // Event statements.
- events, err := getEvents(txn, dbName)
- if err != nil {
- return errors.Wrapf(err, "failed to get events of database %q", dbName)
- }
- for _, et := range events {
- if _, err := io.WriteString(out, fmt.Sprintf("%s\n", et.statement)); err != nil {
- return err
+ // OceanBase doesn't support "Event Scheduler"
+ if dbType != "OCEANBASE" {
+ // Event statements.
+ events, err := getEvents(txn, dbName)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get events of database %q", dbName)
+ }
+ for _, et := range events {
+ if _, err := io.WriteString(out, fmt.Sprintf("%s\n", et.statement)); err != nil {
+ return err
+ }
}
}
@@ -622,12 +626,17 @@ func isNumeric(t string) bool {
}
// getRoutines gets all routines of a database.
-func getRoutines(txn *sql.Tx, dbName string) ([]*routineSchema, error) {
+func getRoutines(txn *sql.Tx, dbType db.Type, dbName string) ([]*routineSchema, error) {
var routines []*routineSchema
for _, routineType := range []string{"FUNCTION", "PROCEDURE"} {
if err := func() error {
- query := fmt.Sprintf("SHOW %s STATUS WHERE Db = ?;", routineType)
- rows, err := txn.Query(query, dbName)
+ var query string
+ if dbType == "OCEANBASE" {
+ query = fmt.Sprintf("SHOW %s STATUS FROM `%s`;", routineType, dbName)
+ } else {
+ query = fmt.Sprintf("SHOW %s STATUS WHERE Db = '%s';", routineType, dbName)
+ }
+ rows, err := txn.Query(query)
if err != nil {
return err
}
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index 598f65141c..5108740add 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -31,6 +31,7 @@ func init() {
db.Register(db.MySQL, newDriver)
db.Register(db.TiDB, newDriver)
db.Register(db.MariaDB, newDriver)
+ db.Register(db.OceanBase, newDriver)
}
// Driver is the MySQL driver.
@@ -69,9 +70,13 @@ func (driver *Driver) Open(ctx context.Context, dbType db.Type, connCfg db.Conne
port := connCfg.Port
if port == "" {
- port = "3306"
- if dbType == db.TiDB {
+ switch dbType {
+ case db.TiDB:
port = "4000"
+ case db.OceanBase:
+ port = "2883"
+ default:
+ port = "3306"
}
}
diff --git a/backend/plugin/db/mysql/sync.go b/backend/plugin/db/mysql/sync.go
index 975a96bf51..1d69da4ba6 100644
--- a/backend/plugin/db/mysql/sync.go
+++ b/backend/plugin/db/mysql/sync.go
@@ -27,11 +27,16 @@ import (
var (
systemDatabases = map[string]bool{
"information_schema": true,
- // TiDB only
- "metrics_schema": true,
"mysql": true,
"performance_schema": true,
"sys": true,
+ // TiDB only
+ "metrics_schema": true,
+ // OceanBase only
+ "oceanbase": true,
+ "SYS": true,
+ "LBACSYS": true,
+ "ORAAUDITOR": true,
}
)
diff --git a/backend/plugin/db/util/mask_sensitive_data.go b/backend/plugin/db/util/mask_sensitive_data.go
index a3fb59f4eb..8f9edb7310 100644
--- a/backend/plugin/db/util/mask_sensitive_data.go
+++ b/backend/plugin/db/util/mask_sensitive_data.go
@@ -38,7 +38,7 @@ func extractSensitiveField(dbType db.Type, statement string, currentDatabase str
}
switch dbType {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
extractor := &sensitiveFieldExtractor{
currentDatabase: currentDatabase,
schemaInfo: schemaInfo,
diff --git a/backend/plugin/parser/differ/mysql/differ.go b/backend/plugin/parser/differ/mysql/differ.go
index 69ed048422..a1124298b6 100644
--- a/backend/plugin/parser/differ/mysql/differ.go
+++ b/backend/plugin/parser/differ/mysql/differ.go
@@ -35,6 +35,7 @@ var (
func init() {
differ.Register(bbparser.MySQL, &SchemaDiffer{})
differ.Register(bbparser.TiDB, &SchemaDiffer{})
+ differ.Register(bbparser.OceanBase, &SchemaDiffer{})
}
const (
diff --git a/backend/plugin/parser/parser.go b/backend/plugin/parser/parser.go
index ea5b9f80b2..b6455f5440 100644
--- a/backend/plugin/parser/parser.go
+++ b/backend/plugin/parser/parser.go
@@ -30,6 +30,8 @@ const (
MSSQL EngineType = "MSSQL"
// Redshift is the engine type for redshift.
Redshift EngineType = "REDSHIFT"
+ // OceanBase is the engine type for OceanBase.
+ OceanBase EngineType = "OCEANBASE"
// DeparseIndentString is the string for each indent level.
DeparseIndentString = " "
diff --git a/backend/plugin/parser/transform/mysql/transform.go b/backend/plugin/parser/transform/mysql/transform.go
index 36f6d5cf60..be21d0b050 100644
--- a/backend/plugin/parser/transform/mysql/transform.go
+++ b/backend/plugin/parser/transform/mysql/transform.go
@@ -27,6 +27,7 @@ var (
func init() {
transform.Register(bbparser.MySQL, &SchemaTransformer{})
transform.Register(bbparser.TiDB, &SchemaTransformer{})
+ transform.Register(bbparser.OceanBase, &SchemaTransformer{})
}
// SchemaTransformer it the transformer for MySQL dialect.
diff --git a/backend/plugin/parser/utils.go b/backend/plugin/parser/utils.go
index e6c6ce5437..59d5c30039 100644
--- a/backend/plugin/parser/utils.go
+++ b/backend/plugin/parser/utils.go
@@ -206,7 +206,7 @@ func SplitMultiSQL(engineType EngineType, statement string) ([]SingleSQL, error)
case Postgres, Redshift:
t := newTokenizer(statement)
list, err = t.splitPostgreSQLMultiSQL()
- case MySQL, TiDB, MariaDB:
+ case MySQL, TiDB, MariaDB, OceanBase:
t := newTokenizer(statement)
list, err = t.splitMySQLMultiSQL()
default:
@@ -241,7 +241,7 @@ func SplitMultiSQLStream(engineType EngineType, src io.Reader, f func(string) er
case Postgres, Redshift:
t := newStreamTokenizer(src, f)
list, err = t.splitPostgreSQLMultiSQL()
- case MySQL, TiDB, MariaDB:
+ case MySQL, TiDB, MariaDB, OceanBase:
t := newStreamTokenizer(src, f)
list, err = t.splitMySQLMultiSQL()
default:
@@ -429,7 +429,7 @@ func TypeString(tp byte) string {
// ExtractDatabaseList extracts all databases from statement.
func ExtractDatabaseList(engineType EngineType, statement string) ([]string, error) {
switch engineType {
- case MySQL, TiDB, MariaDB:
+ case MySQL, TiDB, MariaDB, OceanBase:
return extractMySQLDatabaseList(statement)
default:
return nil, errors.Errorf("engine type is not supported: %s", engineType)
diff --git a/backend/plugin/parser/validate_sql_for_editor.go b/backend/plugin/parser/validate_sql_for_editor.go
index daf857ba2b..54e4b50ce0 100644
--- a/backend/plugin/parser/validate_sql_for_editor.go
+++ b/backend/plugin/parser/validate_sql_for_editor.go
@@ -23,7 +23,7 @@ func ValidateSQLForEditor(engine EngineType, statement string) bool {
switch engine {
case Postgres:
return postgresValidateSQLForEditor(statement)
- case MySQL, TiDB, MariaDB:
+ case MySQL, TiDB, MariaDB, OceanBase:
return mysqlValidateSQLForEditor(statement)
default:
return standardValidateSQLForEditor(statement)
@@ -158,7 +158,7 @@ func removeQuotedTextAndComment(engine EngineType, statement string) (string, er
switch engine {
case Postgres:
return "", errors.Errorf("unsupported engine type: %s", engine)
- case MySQL, TiDB, MariaDB:
+ case MySQL, TiDB, MariaDB, OceanBase:
return mysqlRemoveQuotedTextAndComment(statement)
case Standard, Oracle, MSSQL:
return standardRemoveQuotedTextAndComment(statement)
diff --git a/backend/runner/taskcheck/statement_advisor_simple_executor.go b/backend/runner/taskcheck/statement_advisor_simple_executor.go
index 15b5a82ee0..ca87e75650 100644
--- a/backend/runner/taskcheck/statement_advisor_simple_executor.go
+++ b/backend/runner/taskcheck/statement_advisor_simple_executor.go
@@ -60,7 +60,7 @@ func (e *StatementAdvisorSimpleExecutor) Run(ctx context.Context, taskCheckRun *
advisorType = advisor.Fake
case api.TaskCheckDatabaseStatementSyntax:
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
advisorType = advisor.MySQLSyntax
case db.Postgres:
advisorType = advisor.PostgreSQLSyntax
diff --git a/backend/runner/taskcheck/statement_type_executor.go b/backend/runner/taskcheck/statement_type_executor.go
index f8c03910a0..e520af2a4a 100644
--- a/backend/runner/taskcheck/statement_type_executor.go
+++ b/backend/runner/taskcheck/statement_type_executor.go
@@ -70,7 +70,7 @@ func (exec *StatementTypeExecutor) Run(ctx context.Context, _ *store.TaskCheckRu
if err != nil {
return nil, err
}
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
result, err = mysqlStatementTypeCheck(payload.Statement, dbSchema.Metadata.CharacterSet, dbSchema.Metadata.Collation, task.Type)
if err != nil {
return nil, err
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index de7ba8960d..a5fee9bf8d 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -257,7 +257,7 @@ func (exec *DatabaseCreateExecutor) createInitialSchema(ctx context.Context, env
func getConnectionStatement(dbType db.Type, databaseName string) (string, error) {
switch dbType {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
return fmt.Sprintf("USE `%s`;\n", databaseName), nil
case db.MSSQL:
return fmt.Sprintf(`USE "%s";\n`, databaseName), nil
diff --git a/backend/runner/utils/sdl_utils.go b/backend/runner/utils/sdl_utils.go
index 420b35d322..39eb497bc0 100644
--- a/backend/runner/utils/sdl_utils.go
+++ b/backend/runner/utils/sdl_utils.go
@@ -37,7 +37,7 @@ func ComputeDatabaseSchemaDiff(ctx context.Context, instance *store.InstanceMess
switch instance.Engine {
case db.Postgres:
engine = parser.Postgres
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
engine = parser.MySQL
default:
return "", errors.Errorf("unsupported database engine %q", instance.Engine)
diff --git a/backend/server/database.go b/backend/server/database.go
index 33e3fbd7b9..8b02341df0 100644
--- a/backend/server/database.go
+++ b/backend/server/database.go
@@ -252,7 +252,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {
// We only support MySQL now.
var engineType parser.EngineType
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
engineType = parser.MySQL
default:
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Not support SDL format for %s instance", instance.Engine))
diff --git a/backend/server/instance.go b/backend/server/instance.go
index cee162e39c..12dced752c 100644
--- a/backend/server/instance.go
+++ b/backend/server/instance.go
@@ -373,7 +373,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {
if isSDL {
var engineType parser.EngineType
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
engineType = parser.MySQL
default:
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Not support SDL format for %s instance", instance.Engine))
diff --git a/backend/server/issue.go b/backend/server/issue.go
index ab71a23a9a..3b9f0b5179 100644
--- a/backend/server/issue.go
+++ b/backend/server/issue.go
@@ -1121,7 +1121,7 @@ func (s *Server) createDatabaseCreateTaskList(ctx context.Context, c api.CreateD
case db.Snowflake:
// Snowflake needs to use upper case of DatabaseName.
databaseName = strings.ToUpper(databaseName)
- case db.MySQL, db.MariaDB:
+ case db.MySQL, db.MariaDB, db.OceanBase:
// For MySQL, we need to use different case of DatabaseName depends on the variable `lower_case_table_names`.
// https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html
// And also, meet an error in here is not a big deal, we will just use the original DatabaseName.
@@ -1258,7 +1258,7 @@ func (s *Server) createPITRTaskList(ctx context.Context, originDatabase *store.D
func getCreateDatabaseStatement(dbType db.Type, createDatabaseContext api.CreateDatabaseContext, databaseName, adminDatasourceUser string) (string, error) {
var stmt string
switch dbType {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
return fmt.Sprintf("CREATE DATABASE `%s` CHARACTER SET %s COLLATE %s;", databaseName, createDatabaseContext.CharacterSet, createDatabaseContext.Collation), nil
case db.MSSQL:
return fmt.Sprintf(`CREATE DATABASE "%s";`, databaseName), nil
diff --git a/backend/server/sql.go b/backend/server/sql.go
index e3b08d9432..f8d33685ad 100644
--- a/backend/server/sql.go
+++ b/backend/server/sql.go
@@ -261,7 +261,7 @@ func (s *Server) registerSQLRoutes(g *echo.Group) {
// Database Access Control for MySQL dialect.
// MySQL dialect can query cross the database.
// We need special check.
- if instance.Engine == db.MySQL || instance.Engine == db.TiDB || instance.Engine == db.MariaDB {
+ if instance.Engine == db.MySQL || instance.Engine == db.TiDB || instance.Engine == db.MariaDB || instance.Engine == db.OceanBase {
databaseList, err := parser.ExtractDatabaseList(parser.MySQL, exec.Statement)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to extract database list: %q", exec.Statement)).SetInternal(err)
@@ -385,7 +385,7 @@ func (s *Server) registerSQLRoutes(g *echo.Group) {
var sensitiveSchemaInfo *db.SensitiveSchemaInfo
switch instance.Engine {
- case db.MySQL, db.TiDB, db.MariaDB:
+ case db.MySQL, db.TiDB, db.MariaDB, db.OceanBase:
databaseList, err := parser.ExtractDatabaseList(parser.MySQL, exec.Statement)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to get database list: %s", exec.Statement)).SetInternal(err)
@@ -644,7 +644,7 @@ func (s *Server) registerSQLRoutes(g *echo.Group) {
var singleSQLResults []api.SingleSQLResult
// We split the query into multiple statements and execute them one by one for MySQL and PostgreSQL.
- if instance.Engine == db.MySQL || instance.Engine == db.TiDB || instance.Engine == db.MariaDB || instance.Engine == db.Postgres || instance.Engine == db.Oracle || instance.Engine == db.Redshift {
+ if instance.Engine == db.MySQL || instance.Engine == db.TiDB || instance.Engine == db.MariaDB || instance.Engine == db.Postgres || instance.Engine == db.Oracle || instance.Engine == db.Redshift || instance.Engine == db.OceanBase {
singleSQLs, err := parser.SplitMultiSQL(parser.EngineType(instance.Engine), exec.Statement)
if err != nil {
return nil, errors.Wrapf(err, "failed to split statements")
@@ -789,6 +789,8 @@ func convertToParserEngine(engine db.Type) parser.EngineType {
return parser.Oracle
case db.MSSQL:
return parser.MSSQL
+ case db.OceanBase:
+ return parser.OceanBase
}
return parser.Standard
}
diff --git a/frontend/src/assets/db-oceanbase.png b/frontend/src/assets/db-oceanbase.png
new file mode 100644
index 0000000000..103fde7659
Binary files /dev/null and b/frontend/src/assets/db-oceanbase.png differ
diff --git a/frontend/src/components/CreateDataSourceExample.vue b/frontend/src/components/CreateDataSourceExample.vue
index ee3d2643da..f255cab816 100644
--- a/frontend/src/components/CreateDataSourceExample.vue
+++ b/frontend/src/components/CreateDataSourceExample.vue
@@ -29,7 +29,11 @@
class="mt-2 text-sm text-main w-208"
>
<template
- v-if="props.engineType == 'MYSQL' || props.engineType == 'TIDB'"
+ v-if="
+ props.engineType == 'MYSQL' ||
+ props.engineType == 'TIDB' ||
+ props.engineType == 'OceanBase'
+ "
>
<i18n-t
tag="p"
@@ -197,6 +201,8 @@ const grantStatement = (
return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE VIEW, \nDELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, PROCESS, REFERENCES, \nSELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, UPDATE, USAGE, \nRELOAD, LOCK TABLES, REPLICATION CLIENT, REPLICATION SLAVE \n/*!80000 , REPLICATION_APPLIER, SYSTEM_VARIABLES_ADMIN */\nON *.* to bytebase@'%';";
case "TIDB":
return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE VIEW, \nDELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, PROCESS, REFERENCES, \nSELECT, SHOW DATABASES, SHOW VIEW, TRIGGER, UPDATE, USAGE, \nLOCK TABLES, REPLICATION CLIENT, REPLICATION SLAVE \nON *.* to bytebase@'%';";
+ case "OCEANBASE":
+ return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALTER, CREATE, CREATE VIEW, DELETE, DROP, INDEX, INSERT, \nPROCESS, SELECT, SHOW DATABASES, SHOW VIEW, UPDATE, USAGE, \nREPLICATION CLIENT, REPLICATION SLAVE \nON *.* to bytebase@'%';";
case "CLICKHOUSE":
return "CREATE USER bytebase IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT ALL ON *.* TO bytebase WITH GRANT OPTION;";
case "SNOWFLAKE":
@@ -247,6 +253,7 @@ GRANT ALL PRIVILEGES ON DATABASE {{YOUR_DB_NAME}} TO ROLE BYTEBASE;
switch (engineType) {
case "MYSQL":
case "TIDB":
+ case "OCEANBASE":
return "CREATE USER bytebase@'%' IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT SELECT, SHOW DATABASES, SHOW VIEW, USAGE ON *.* to bytebase@'%';";
case "CLICKHOUSE":
return "CREATE USER bytebase IDENTIFIED BY 'YOUR_DB_PWD';\n\nGRANT SHOW TABLES, SELECT ON database.* TO bytebase;";
diff --git a/frontend/src/components/InstanceEngineIcon.vue b/frontend/src/components/InstanceEngineIcon.vue
index 0d8ef5a933..dcb4e26481 100644
--- a/frontend/src/components/InstanceEngineIcon.vue
+++ b/frontend/src/components/InstanceEngineIcon.vue
@@ -47,6 +47,7 @@ export default defineComponent({
MSSQL: new URL("../assets/db-mssql.svg", import.meta.url).href,
REDSHIFT: new URL("../assets/db-redshift.svg", import.meta.url).href,
MARIADB: new URL("../assets/db-mariadb.png", import.meta.url).href,
+ OCEANBASE: new URL("../assets/db-oceanbase.png", import.meta.url).href,
};
const SelectedEngineIconPath = computed(() => {
return EngineIconPath[props.instance.engine];
diff --git a/frontend/src/components/InstanceForm.vue b/frontend/src/components/InstanceForm.vue
index e4553d0768..37f7f2893c 100644
--- a/frontend/src/components/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm.vue
@@ -719,6 +719,8 @@ const getDefaultPort = (engine: EngineType) => {
return "1433";
} else if (engine === "REDSHIFT") {
return "5439";
+ } else if (engine === "OCEANBASE") {
+ return "2883";
}
return "3306";
};
@@ -772,6 +774,7 @@ const EngineIconPath = {
MSSQL: new URL("../assets/db-mssql.svg", import.meta.url).href,
REDSHIFT: new URL("../assets/db-redshift.svg", import.meta.url).href,
MARIADB: new URL("../assets/db-mariadb.png", import.meta.url).href,
+ OCEANBASE: new URL("../assets/db-oceanbase.png", import.meta.url).href,
};
const mongodbConnectionStringSchemaList = ["mongodb://", "mongodb+srv://"];
@@ -865,6 +868,8 @@ const defaultPort = computed(() => {
return "5439";
} else if (basicInformation.value.engine == "MARIADB") {
return "3306";
+ } else if (basicInformation.value.engine == "OCEANBASE") {
+ return "2883";
}
return "3306";
});
diff --git a/frontend/src/types/instance.ts b/frontend/src/types/instance.ts
index 33007d17ff..5e0b4fe8fb 100644
--- a/frontend/src/types/instance.ts
+++ b/frontend/src/types/instance.ts
@@ -23,6 +23,7 @@ export const EngineTypeList = [
"MSSQL",
"REDSHIFT",
"MARIADB",
+ "OCEANBASE",
] as const;
export type EngineType = typeof EngineTypeList[number];
@@ -53,6 +54,8 @@ export function convertEngineType(type: EngineType): Engine {
return Engine.REDSHIFT;
case "MARIADB":
return Engine.MARIADB;
+ case "OCEANBASE":
+ return Engine.OCEANBASE;
}
return Engine.ENGINE_UNSPECIFIED;
}
@@ -65,6 +68,7 @@ export function defaultCharset(type: EngineType): string {
case "MYSQL":
case "TIDB":
case "MARIADB":
+ case "OCEANBASE":
return "utf8mb4";
case "POSTGRES":
return "UTF8";
@@ -109,6 +113,8 @@ export function engineName(type: EngineType): string {
return "Redshift";
case "MARIADB":
return "MariaDB";
+ case "OCEANBASE":
+ return "OceanBase";
}
}
@@ -120,6 +126,7 @@ export function defaultCollation(type: EngineType): string {
case "MYSQL":
case "TIDB":
case "MARIADB":
+ case "OCEANBASE":
return "utf8mb4_general_ci";
// For postgres, we don't explicitly specify a default since the default might be UNSET (denoted by "C").
// If that's the case, setting an explicit default such as "en_US.UTF-8" might fail if the instance doesn't
diff --git a/frontend/src/types/proto/v1/common.ts b/frontend/src/types/proto/v1/common.ts
index dc89e980f6..0f0956371d 100644
--- a/frontend/src/types/proto/v1/common.ts
+++ b/frontend/src/types/proto/v1/common.ts
@@ -56,6 +56,7 @@ export enum Engine {
MSSQL = 11,
REDSHIFT = 12,
MARIADB = 13,
+ OCEANBASE = 14,
UNRECOGNIZED = -1,
}
@@ -103,6 +104,9 @@ export function engineFromJSON(object: any): Engine {
case 13:
case "MARIADB":
return Engine.MARIADB;
+ case 14:
+ case "OCEANBASE":
+ return Engine.OCEANBASE;
case -1:
case "UNRECOGNIZED":
default:
@@ -140,6 +144,8 @@ export function engineToJSON(object: Engine): string {
return "REDSHIFT";
case Engine.MARIADB:
return "MARIADB";
+ case Engine.OCEANBASE:
+ return "OCEANBASE";
case Engine.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
diff --git a/frontend/src/utils/instance.ts b/frontend/src/utils/instance.ts
index 7cdc951e52..5e40fd66f0 100644
--- a/frontend/src/utils/instance.ts
+++ b/frontend/src/utils/instance.ts
@@ -12,6 +12,7 @@ export const supportedEngineList = () => {
const engines: EngineType[] = [
"MYSQL",
"POSTGRES",
+ "OCEANBASE",
"TIDB",
"SNOWFLAKE",
"CLICKHOUSE",
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 6c04a80e54..fb2a72a770 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -668,6 +668,7 @@ BackupPlanSchedule is the backup plan schedule.
| MSSQL | 11 | |
| REDSHIFT | 12 | |
| MARIADB | 13 | |
+| OCEANBASE | 14 | |
diff --git a/proto/generated-go/v1/common.pb.go b/proto/generated-go/v1/common.pb.go
index 33233fa407..0f2372bdec 100644
--- a/proto/generated-go/v1/common.pb.go
+++ b/proto/generated-go/v1/common.pb.go
@@ -86,6 +86,7 @@ const (
Engine_MSSQL Engine = 11
Engine_REDSHIFT Engine = 12
Engine_MARIADB Engine = 13
+ Engine_OCEANBASE Engine = 14
)
// Enum value maps for Engine.
@@ -105,6 +106,7 @@ var (
11: "MSSQL",
12: "REDSHIFT",
13: "MARIADB",
+ 14: "OCEANBASE",
}
Engine_value = map[string]int32{
"ENGINE_UNSPECIFIED": 0,
@@ -121,6 +123,7 @@ var (
"MSSQL": 11,
"REDSHIFT": 12,
"MARIADB": 13,
+ "OCEANBASE": 14,
}
)
@@ -159,7 +162,7 @@ var file_v1_common_proto_rawDesc = []byte{
0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45,
0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a,
0x0a, 0x06, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45,
- 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x02, 0x2a, 0xc5, 0x01, 0x0a, 0x06, 0x45, 0x6e, 0x67, 0x69,
+ 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x02, 0x2a, 0xd4, 0x01, 0x0a, 0x06, 0x45, 0x6e, 0x67, 0x69,
0x6e, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x4e, 0x47, 0x49, 0x4e, 0x45, 0x5f, 0x55, 0x4e, 0x53,
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4c,
0x49, 0x43, 0x4b, 0x48, 0x4f, 0x55, 0x53, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x59,
@@ -171,9 +174,10 @@ var file_v1_common_proto_rawDesc = []byte{
0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x52, 0x41, 0x43, 0x4c, 0x45, 0x10, 0x09, 0x12, 0x0b, 0x0a, 0x07,
0x53, 0x50, 0x41, 0x4e, 0x4e, 0x45, 0x52, 0x10, 0x0a, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x53, 0x53,
0x51, 0x4c, 0x10, 0x0b, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x44, 0x53, 0x48, 0x49, 0x46, 0x54,
- 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x41, 0x52, 0x49, 0x41, 0x44, 0x42, 0x10, 0x0d, 0x42,
- 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f,
- 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x41, 0x52, 0x49, 0x41, 0x44, 0x42, 0x10, 0x0d, 0x12,
+ 0x0d, 0x0a, 0x09, 0x4f, 0x43, 0x45, 0x41, 0x4e, 0x42, 0x41, 0x53, 0x45, 0x10, 0x0e, 0x42, 0x11,
+ 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76,
+ 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/proto/v1/common.proto b/proto/v1/common.proto
index 47a1eb976c..27b46db448 100644
--- a/proto/v1/common.proto
+++ b/proto/v1/common.proto
@@ -25,4 +25,5 @@ enum Engine {
MSSQL = 11;
REDSHIFT = 12;
MARIADB = 13;
+ OCEANBASE = 14;
}