You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "gesanri (via GitHub)" <gi...@apache.org> on 2025/07/22 10:02:58 UTC
[I] Does ShardingJDBC supports postgres schema except public? [shardingsphere]
gesanri opened a new issue, #36056:
URL: https://github.com/apache/shardingsphere/issues/36056
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Does ShardingJDBC support postgres schema except public? [shardingsphere]
Posted by "gesanri (via GitHub)" <gi...@apache.org>.
gesanri commented on issue #36056:
URL: https://github.com/apache/shardingsphere/issues/36056#issuecomment-3120998403
ok, I find there's already a PR
https://github.com/apache/shardingsphere/pull/35022
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Does ShardingJDBC support postgres schema except public? [shardingsphere]
Posted by "gesanri (via GitHub)" <gi...@apache.org>.
gesanri closed issue #36056: Does ShardingJDBC support postgres schema except public?
URL: https://github.com/apache/shardingsphere/issues/36056
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Does ShardingJDBC support postgres schema except public? [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #36056:
URL: https://github.com/apache/shardingsphere/issues/36056#issuecomment-3117810302
- I would say the current issue is actually a duplicate of https://github.com/apache/shardingsphere/issues/17204 . shardingsphere does not have a proper handling of `currentSchema` for `pgjdbc`.
- Feel free to open the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Does ShardingJDBC supports postgres schema except public? [shardingsphere]
Posted by "gesanri (via GitHub)" <gi...@apache.org>.
gesanri closed issue #36056: Does ShardingJDBC supports postgres schema except public?
URL: https://github.com/apache/shardingsphere/issues/36056
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org