ssz-plus opened a new issue, #19242: URL: https://github.com/apache/shardingsphere/issues/19242
## Bug Report Hello, We found a problem with cross-database queries. When our sql statement involves a data table located in a different database, an error is reported:  Regarding the database version we use and the SQL executed as follows: ### Mysql version 5.7.18 ### Which version of ShardingSphere did you use? 5.1.1 and 5.1.2 ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy? ShardingSphere-JDBC ### Expected behavior We hope to support cross-database join queries. ### Actual behavior Unfortunately, it reported an error: [Error preparing statement. Cause: java.lang.IllegalStateException: Can not support multiple different database.] ### Our database table distribution: <img width="210" alt="image" src="https://user-images.githubusercontent.com/109347245/179199111-44a5fe8e-ba56-4211-bd5e-571da6beed2e.png"> ### Our query statement: Preparing: select t02.id, t02.system_id from test_02.t_wr_readonly t02 LEFT JOIN test_03.t_dic_metrics t03_metrics ON t02.id = t03_metrics.id where t02.id = 1; Caused by: java.lang.IllegalStateException: Can not support multiple different database. at com.google.common.base.Preconditions.checkState(Preconditions.java:508) ~[guava-29.0-jre.jar:?] at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.getDatabaseName(TablesContext.java:297) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.getSchema(SelectStatementContext.java:132) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(SelectStatementContext.java:111) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:146) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:129) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:114) ~[shardingsphere-infra-binder-5.1.1.jar:5.1.1] at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:181) ~[shardingsphere-jdbc-core-5.1.1.jar:5.1.1] at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:149) ~[shardingsphere-jdbc-core-5.1.1.jar:5.1.1] at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:80) ~[shardingsphere-jdbc-core-5.1.1.jar:5.1.1] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
