Wrong LIMIT rewrite while GROUP BY and ORDER BY on different items
See original GitHub issueBug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
3.1.0
Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-JDBC
Expected behavior
limit 0, 10
Actual behavior
SQL: select max(sid) as sid, max(sendTime) as sendTime, objectId, sum(0) as unreadCount from TEST where memberId = ? and status != -1 group by objectId order by sendTime desc limit ?, ?
SQL-BindValue: 52146792, 0, 2147483647
Reason analyze (If you can)
logic error:
io.shardingsphere.core.routing.router.sharding.ParsingSQLRouter#processLimit

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Run it with PreparedStatement:
select max(sid) as sid, max(sendTime) as sendTime, objectId, sum(0) as unreadCount from TEST where memberId = ? and status != -1 group by objectId order by sendTime desc limit ?, ?
Example codes for reproduce this issue (such as a github link).
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
MySQL wrong results with GROUP BY and ORDER BY
One major problem with your query is that it uses a MySQL extension to group by that MySQL explicitly warns against. The extension...
Read more >Using Group By and Order By in the Same Query - Navicat
Both GROUP BY and ORDER BY are clauses (or statements) that serve similar functions; that is to sort query results. However, each of...
Read more >GROUP BY after ORDER BY/LIMIT/OFFSEt?
` To be clear, I expect a list of ids, the list should have at maximum 5 entries, and no duplicates (a duplicate...
Read more >How To Use GROUP BY and ORDER BY in SQL - DigitalOcean
A DISTINCT clause removes any duplicates in a result set by returning the unique values in the column, and it can only be...
Read more >How to Use GROUP BY, HAVING, and ORDER BY SQL Clauses
This query first orders the sales by INVOICE_NO. Then for each different InvoiceNo, the query orders the sales by SaleDate. This probably won't ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

so, will there be no hotfix for 3.x? @terrymanu
I also had this issue in 【4.1.1】
Bug Report
For English only, other languages will not accept.
Before report a bug, make sure you have:
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.
Please answer these questions before submitting your issue. Thanks!
Which version of ShardingSphere did you use?
4.1.1
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
I want to return 10 pieces of data in the SQL result
Actual behavior
The rewritten SQL queries 2147483647 pieces of data
Reason analyze (If you can)
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
ShardingSphere-SQL LOG detail
Example codes for reproduce this issue (such as a github link).