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
71 changes: 37 additions & 34 deletions internal/dms/pkg/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ func ParseDBType(s string) (DBType, error) {
return DBTypeHive, nil
case "DM":
return DBTypeDM, nil
case "GaussDB for MySQL":
case "GaussDB":
return DBTypeGaussDB, nil
case "GaussDB for MySQL":
return DBTypeGaussDBForMySQL, nil
case "HANA":
return DBTypeHANA, nil
case "PolarDB For MySQL":
Expand All @@ -263,42 +265,43 @@ func ParseDBType(s string) (DBType, error) {
}

const (
DBTypeMySQL DBType = "MySQL"
DBTypePostgreSQL DBType = "PostgreSQL"
DBTypeTiDB DBType = "TiDB"
DBTypeSQLServer DBType = "SQL Server"
DBTypeOracle DBType = "Oracle"
DBTypeDB2 DBType = "DB2"
DBTypeOceanBaseMySQL DBType = "OceanBase For MySQL"
DBTypeTDSQLForInnoDB DBType = "TDSQL For InnoDB"
DBTypeGoldenDB DBType = "GoldenDB"
DBTypeTBase DBType = "TBase"
DBTypeHive DBType = "Hive"
DBTypeDM DBType = "达梦(DM)"
DBTypeGaussDB DBType = "GaussDB / openGauss"
DBTypeHANA DBType = "HANA"
DBTypePolarDBForMySQL DBType = "PolarDB For MySQL"
DBTypeOceanBaseOracle DBType = "OceanBase For Oracle"
DBTypeMySQL DBType = "MySQL"
DBTypePostgreSQL DBType = "PostgreSQL"
DBTypeTiDB DBType = "TiDB"
DBTypeSQLServer DBType = "SQL Server"
DBTypeOracle DBType = "Oracle"
DBTypeDB2 DBType = "DB2"
DBTypeOceanBaseMySQL DBType = "OceanBase For MySQL"
DBTypeTDSQLForInnoDB DBType = "TDSQL For InnoDB"
DBTypeGoldenDB DBType = "GoldenDB"
DBTypeTBase DBType = "TBase"
DBTypeHive DBType = "Hive"
DBTypeDM DBType = "达梦(DM)"
DBTypeGaussDB DBType = "GaussDB"
DBTypeGaussDBForMySQL DBType = "GaussDB for MySQL"
DBTypeHANA DBType = "HANA"
DBTypePolarDBForMySQL DBType = "PolarDB For MySQL"
DBTypeOceanBaseOracle DBType = "OceanBase For Oracle"
)

var supportedDataExportDBTypes = map[DBType]struct{}{
DBTypeMySQL: {},
DBTypePostgreSQL: {},
DBTypeOracle: {},
DBTypeSQLServer: {},
DBTypeOceanBaseMySQL: {},
DBTypeHive: {},
DBTypeDM: {},
// 新增数据源 (Issue #593)
DBTypeTiDB: {},
DBTypeTDSQLForInnoDB: {},
DBTypeGoldenDB: {},
DBTypeTBase: {},
DBTypeGaussDB: {},
DBTypeDB2: {},
DBTypeHANA: {},
DBTypePolarDBForMySQL: {},
DBTypeOceanBaseOracle: {},
DBTypeMySQL: {},
DBTypePostgreSQL: {},
DBTypeOracle: {},
DBTypeSQLServer: {},
DBTypeOceanBaseMySQL: {},
DBTypeHive: {},
DBTypeDM: {},
DBTypeTiDB: {},
DBTypeTDSQLForInnoDB: {},
DBTypeGoldenDB: {},
DBTypeTBase: {},
DBTypeGaussDB: {},
DBTypeGaussDBForMySQL: {},
DBTypeDB2: {},
DBTypeHANA: {},
DBTypePolarDBForMySQL: {},
DBTypeOceanBaseOracle: {},
}

func CheckDBTypeIfDataExportSupported(dbtype string) bool {
Expand Down
10 changes: 7 additions & 3 deletions internal/dms/pkg/constant/const_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ func TestCheckDBTypeIfDataExportSupported_NewTypes(t *testing.T) {
"TDSQL For InnoDB": true,
"GoldenDB": true,
"TBase": true,
"GaussDB for MySQL": true, // GaussDB/openGauss: ParseDBType 的输入值是 "GaussDB for MySQL"
// Issue #2868: GaussDB (PostgreSQL 协议) 与 GaussDB for MySQL (MySQL 协议) 是两个独立产品
"GaussDB": true, // PostgreSQL 协议 GaussDB / openGauss, 走 opengauss-connector-go-pq 驱动
"GaussDB for MySQL": true, // 华为云 GaussDB(for MySQL), 走 MySQL 驱动
"DB2": true,
"HANA": true,
"PolarDB For MySQL": true,
Expand Down Expand Up @@ -55,7 +57,7 @@ func TestParseDBType_PolarDB(t *testing.T) {
}{
"valid PolarDB For MySQL": {
input: "PolarDB For MySQL",
wantDBType: DBTypePolarDBMySQL,
wantDBType: DBTypePolarDBForMySQL,
wantErr: false,
},
"invalid lowercase polardb": {
Expand Down Expand Up @@ -119,7 +121,9 @@ func TestParseDBType(t *testing.T) {
"TBase": {input: "TBase", expected: DBTypeTBase},
"Hive": {input: "Hive", expected: DBTypeHive},
"DM": {input: "DM", expected: DBTypeDM},
"GaussDB for MySQL": {input: "GaussDB for MySQL", expected: DBTypeGaussDB},
// Issue #2868: 拆分 GaussDB / GaussDB for MySQL 为两个独立产品
"GaussDB": {input: "GaussDB", expected: DBTypeGaussDB},
"GaussDB for MySQL": {input: "GaussDB for MySQL", expected: DBTypeGaussDBForMySQL},
"HANA": {input: "HANA", expected: DBTypeHANA},
// PolarDB-MySQL 新增 (Issue #826)
"PolarDB For MySQL": {input: "PolarDB For MySQL", expected: DBTypePolarDBForMySQL},
Expand Down