diff --git a/internal/dms/pkg/constant/const.go b/internal/dms/pkg/constant/const.go index f39fe9a9..18741600 100644 --- a/internal/dms/pkg/constant/const.go +++ b/internal/dms/pkg/constant/const.go @@ -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": @@ -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 { diff --git a/internal/dms/pkg/constant/const_test.go b/internal/dms/pkg/constant/const_test.go index cd871b98..71c14a9b 100644 --- a/internal/dms/pkg/constant/const_test.go +++ b/internal/dms/pkg/constant/const_test.go @@ -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, @@ -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": { @@ -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},