Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result list return wrong size when there's limit sub clause for single routing #1759

Closed
caedmonz opened this issue Jan 15, 2019 · 1 comment
Assignees

Comments

@caedmonz
Copy link

Bug Report

Which version of ShardingSphere did you use?

3.1.0.M1

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

Expected behavior

The SQL is single routed to t_order0;
origin data:
order_id: 1, status: 1
order_id: 1, status: 2
order_id: 1, status: 3
order_id: 1, status: 4

SELECT * FROM t_order WHERE user_id = 0 LIMIT ?, ?;
My programe set two params as 1,2 with PreparedStatement

expexted:
order_id: 1, status: 2
order_id: 1, status: 3

Actual behavior

order_id: 1, status: 1
order_id: 1, status: 2
order_id: 1, status: 3

Reason analyze (If you can)

ParsingSQLRouter will override limit and offset even if the SQL is single routed. However, DQLMergeEngine will not merge result when queryResult size is just one.
100% compatible(MySQL only, other database dialect is doing) . Thus, there should not have any override operation when single routed.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

String sql = "SELECT id, order_id, status FROM t_order where order_id = 1 limit ?,?";
DataSource dataSource = ShardingDataSource.makeShardingDataSource();
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(sql);

preparedStatement.setInt(1, 1);
preparedStatement.setInt(2, 2);
ResultSet resultSet = preparedStatement.executeQuery();

Example codes for reproduce this issue (such as a github link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants