apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.94k stars 6.74k forks source link

Column index out of range #32732

Closed Great11111 closed 2 months ago

Great11111 commented 2 months ago

sharding-jdbc version 5.2.1 sql:select b.* from (select distinct(uid) form tableA) a innier join tableB b on a.uid =b.uid

exception: Column index out of range.; nested exception is java.sql.SQLException: Column index out of range. detail: Caused by: java.sql.SQLException: Column index out of range. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) at com.mysql.cj.jdbc.result.ResultSetMetaData.getField(ResultSetMetaData.java:223) at com.mysql.cj.jdbc.result.ResultSetMetaData.getColumnLabel(ResultSetMetaData.java:181) at org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSetMetaData.getColumnLabel(ShardingSphereResultSetMetaData.java:106) at org.apache.ibatis.executor.resultset.ResultSetWrapper.(ResultSetWrapper.java:60) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getFirstResultSet(DefaultResultSetHandler.java:251) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:188) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) at com.sun.proxy.$Proxy587.query(Unknown Source) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy586.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)

strongduanmu commented 2 months ago

Can you try the latest version? I think this bug has been solved by new sql binder module.

Great11111 commented 2 months ago

i user shardingsphere-jdbc-core-spring-boot-starter :

org.apache.shardingsphere shardingsphere-jdbc-core-spring-boot-starter 5.2.1

This is the latest version. If I use the shardingsphere-jdbc-core last version, do I need to modify other configurations or do they affect my other templates

strongduanmu commented 2 months ago

Of course, you could refer the latest document to upgrade.

Great11111 commented 2 months ago

Thanks, if I don't upgrade, is there any way to solve it

Great11111 commented 2 months ago

Thanks, if I don't upgrade, is there any way to solve it

strongduanmu commented 2 months ago

There is no way to solve this problem without upgrading, unless you synchronize the master code to a lower version yourself, but considering the huge difference, this is almost impossible to accomplish.

Great11111 commented 2 months ago

Thanks, if I don't upgrade, is there any way to solve it

strongduanmu commented 2 months ago

Since this issus has been fixed, I will close it now.