diff --git a/client b/client index a6acfbe30c..d84fa60873 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit a6acfbe30c4d9694d35d27ce39c940a02f74410f +Subproject commit d84fa6087323062cb2e3a4ba0344f140d121ef15 diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/factory/OBConsoleDataSourceFactory.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/factory/OBConsoleDataSourceFactory.java index 5d62710123..df4ac5e083 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/session/factory/OBConsoleDataSourceFactory.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/session/factory/OBConsoleDataSourceFactory.java @@ -261,22 +261,36 @@ private static String getDbUser(@NonNull ConnectionConfig connectionConfig) { return username; } + public static String getSchema(@NonNull String schema, @NonNull DialectType dialectType) { + switch (dialectType) { + case OB_ORACLE: + case ORACLE: + return "\"" + schema + "\""; + case OB_MYSQL: + case MYSQL: + case ODP_SHARDING_OB_MYSQL: + return schema; + default: + return null; + } + } + public static String getDefaultSchema(@NonNull ConnectionConfig connectionConfig) { String defaultSchema = connectionConfig.getDefaultSchema(); switch (connectionConfig.getDialectType()) { case OB_ORACLE: case ORACLE: if (StringUtils.isNotEmpty(defaultSchema)) { - return "\"" + defaultSchema + "\""; + return getSchema(defaultSchema, connectionConfig.getDialectType()); } - return "\"" + getDbUser(connectionConfig) + "\""; + return getSchema(getDbUser(connectionConfig), connectionConfig.getDialectType()); case OB_MYSQL: case MYSQL: case ODP_SHARDING_OB_MYSQL: if (StringUtils.isNotEmpty(defaultSchema)) { - return defaultSchema; + return getSchema(defaultSchema, connectionConfig.getDialectType()); } - return OdcConstants.MYSQL_DEFAULT_SCHEMA; + return getSchema(OdcConstants.MYSQL_DEFAULT_SCHEMA, connectionConfig.getDialectType()); default: return null; } diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/sqlcheck/SqlCheckService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/sqlcheck/SqlCheckService.java index ac2506740a..0de43322b2 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/sqlcheck/SqlCheckService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/sqlcheck/SqlCheckService.java @@ -101,7 +101,7 @@ public List check(@NotNull Long environmentId, @NonNull String d Environment env = this.environmentService.detail(environmentId); List rules = this.ruleService.list(env.getRulesetId(), QueryRuleMetadataParams.builder().build()); OBConsoleDataSourceFactory factory = new OBConsoleDataSourceFactory(config, true, false); - factory.resetSchema(origin -> databaseName); + factory.resetSchema(origin -> OBConsoleDataSourceFactory.getSchema(databaseName, config.getDialectType())); SqlCheckContext checkContext = new SqlCheckContext((long) sqls.size()); try (SingleConnectionDataSource dataSource = (SingleConnectionDataSource) factory.getDataSource()) { JdbcTemplate jdbc = new JdbcTemplate(dataSource);