-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Shardingsphere Version: 5.5.1
springboot version:3.3.0
I'm using mysql before, and I configure the sharding like this:
mode:
type: Standalone
repository:
type: JDBC
dataSources:
brs:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl: jdbc:mysql://localhost:3306/abc
username: root
password: 12345678
it works
while when I change to postgres, as you know, postgres have database and schema, the table is under the schema, not database
I change the config like this:
mode:
type: Standalone
repository:
type: JDBC
dataSources:
brs:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.postgresql.Driver
jdbcUrl: jdbc:postgresql://localhost:5432/abc?currentSchema=def
username: postgres
password: 12345678
The table are all under the schema named def, while when I start up the application, I get error:
Caused by: org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException: Table or view 'XXX' does not exist.
at org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.lambda$checkTableExists$3(SimpleTableSegmentBinder.java:130)
at org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
at org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.checkTableExists(SimpleTableSegmentBinder.java:127)
at org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.bind(SimpleTableSegmentBinder.java:84)
at org.apache.shardingsphere.infra.binder.engine.segment.from.TableSegmentBinder.bind(TableSegmentBinder.java:57)
at org.apache.shardingsphere.infra.binder.engine.statement.dml.SelectStatementBinder.lambda$bind$0(SelectStatementBinder.java:54)
I'm sure the table exists, and when I debug this error, I find it in SimpleTableSegmentBinder.class
private static void checkTableExists(SQLStatementBinderContext binderContext, String databaseName, String schemaName, String tableName) {
if (!"dual".equalsIgnoreCase(tableName)) {
if (!SystemSchemaManager.isSystemTable(schemaName, tableName)) {
if (!binderContext.getExternalTableBinderContexts().containsKey(tableName)) {
ShardingSpherePreconditions.checkState(binderContext.getMetaData().containsDatabase(databaseName) && binderContext.getMetaData().getDatabase(databaseName).containsSchema(schemaName) && binderContext.getMetaData().getDatabase(databaseName).getSchema(schemaName).containsTable(tableName), () -> new TableNotFoundException(tableName));
}
}
}
}
I find the schemaName is public, which is the default schema of postgres, so it seems the config:
jdbc:postgresql://localhost:5432/abc?currentSchema=def
currentSchema does not work, why?Does shardingsphere only supports default schema?