You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/07 05:06:59 UTC
[GitHub] [shardingsphere] strongduanmu opened a new issue #14593: No result return when execute getResultSet method for some sql that handle with JDBCMemoryQueryResult
strongduanmu opened a new issue #14593:
URL: https://github.com/apache/shardingsphere/issues/14593
## Bug Report
### Which version of ShardingSphere did you use?
482bcc58f28af6cdc904eb64e8a4751434e66529
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
Return result when I execute sql `SELECT * FROM t_order WHERE order_id > ? ORDER BY order_id`;
### Actual behavior
No result return.
### Reason analyze (If you can)
When executing sql `SELECT * FROM t_order WHERE order_id>? ORDER BY order_id`, because JDBCMemoryQueryResult is used, the statement can't hold the result set, so the result can't be obtained in the getResultSet method.
```java
@Override
public ResultSet getResultSet() throws SQLException {
if (null != currentResultSet) {
return currentResultSet;
}
if (trafficContext.isMatchTraffic()) {
return executor.getTrafficExecutor().getResultSet();
}
if (executionContext.getRouteContext().isFederated()) {
return executor.getFederationExecutor().getResultSet();
}
if (executionContext.getSqlStatementContext() instanceof SelectStatementContext || executionContext.getSqlStatementContext().getSqlStatement() instanceof DALStatement) {
List<ResultSet> resultSets = getResultSets();
MergedResult mergedResult = mergeQuery(getQueryResults(resultSets));
currentResultSet = new ShardingSphereResultSet(resultSets, mergedResult, this, executionContext);
}
return currentResultSet;
}
private List<ResultSet> getResultSets() throws SQLException {
List<ResultSet> result = new ArrayList<>(statements.size());
for (Statement each : statements) {
result.add(each.getResultSet());
}
return result;
}
```
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Config like this:
```yaml
rules:
- !SHARDING
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: t_order_inline
keyGenerateStrategy:
column: order_id
keyGeneratorName: snowflake
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
standard:
shardingColumn: order_id
shardingAlgorithmName: t_order_item_inline
keyGenerateStrategy:
column: order_item_id
keyGeneratorName: snowflake
bindingTables:
- t_order,t_order_item
defaultDatabaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm-expression: ds_${user_id % 2}
allow-range-query-with-inline-sharding: true
t_order_inline:
type: INLINE
props:
algorithm-expression: t_order_${order_id % 2}
allow-range-query-with-inline-sharding: true
t_order_item_inline:
type: INLINE
props:
algorithm-expression: t_order_item_${order_id % 2}
allow-range-query-with-inline-sharding: true
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 123
```
Execute sql by java code:
```java
public static void main(final String[] args) throws Exception {
DataSource dataSource = getDataSource(registryCenterType, loadConfigFromRegCenter, shardingType);
try {
Connection connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT * FROM t_order WHERE order_id > ? ORDER BY order_id");
statement.setObject(1, 3);
statement.executeQuery();
ResultSet resultSet = statement.getResultSet();
while (resultSet.next()) {
for (int index = 0; index < resultSet.getMetaData().getColumnCount(); index++) {
System.out.print(resultSet.getObject(index + 1) + " ");
}
System.out.println();
}
} finally {
closeDataSource(dataSource);
}
}
```
### Example codes for reproduce this issue (such as a github link).
--
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
[GitHub] [shardingsphere] tristaZero closed issue #14593: No result return when execute getResultSet method for some sql that handle with JDBCMemoryQueryResult
Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #14593:
URL: https://github.com/apache/shardingsphere/issues/14593
--
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
[GitHub] [shardingsphere] tristaZero closed issue #14593: No result return when execute getResultSet method for some sql that handle with JDBCMemoryQueryResult
Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #14593:
URL: https://github.com/apache/shardingsphere/issues/14593
--
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