apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.88k stars 6.73k forks source link

select xxx limit has bug when using database spliting #33251

Open Mrjyw opened 4 days ago

Mrjyw commented 4 days ago

Bug Report

when I execute sql: select * from user_0003 limit 2,2 Actually the sql statement executed is select * from user_0003 limit 0,4

Which version of ShardingSphere did you use?

5.1.1

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

ShardingSphere-JDBC

Expected behavior

execute sql: select * from user_0003 limit 2,2

Actual behavior

execute select * from user_0003 limit 0,4

Reason analyze (If you can)

I use database spliting and table spliting both. But the sql only use one table and one dataSource which is default-data-source-name.

I debug the source code and find the reason. When sharding check if the routeContext is single routing, sharding checks the metaData not the sql using. So sharding find 5 dataSources, then the routeContext is not single routing.

image

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

use database spliting and table spliting both. But the sql only use one table and one dataSource which is default-data-source-name.

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

terrymanu commented 4 days ago

DefaultDataSource has been removed in the new version. Could you try to the lasted version?

Mrjyw commented 4 days ago

您的邮件我已收到,谢谢。——收信人:吴宇杰

Mrjyw commented 3 days ago

To remove 'DefaultDataSource ', I would need to change a lot of code because a lot of tables are using 'DefaultDataSource '. Is there another solution? o(╥﹏╥)o