joooohnli commented on issue #2062: Wrong LIMIT rewrite while GROUP BY and 
ORDER BY on different items
URL: 
https://github.com/apache/incubator-shardingsphere/issues/2062#issuecomment-475128566
 
 
   @tuohai666 
   Here is the example code
   ```
               connection = dataSource.getConnection();
               PreparedStatement preparedStatement = 
connection.prepareStatement("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 ?, ?");
               preparedStatement.setInt(1, 123);
               preparedStatement.setInt(2, 0);
               preparedStatement.setInt(3, 10);
               ResultSet resultSet = preparedStatement.executeQuery();
   ```
   And TEST is just a single table in defaultDataSource. (in fact this issue 
also occurs to sharding table)
   
   The log comes from my jdbc monitor, it shows the real sql that jdbc sends to 
physical db.
   
   If you think the log is not convincing. I can show you the debug info:
   io.shardingsphere.core.parsing.parser.context.limit.Limit#rewrite
   
![image](https://user-images.githubusercontent.com/1615053/54736859-1f3b8100-4be8-11e9-94eb-b514748f5274.png)
   
   
   Actually you could have reproduced this bug according to the **Steps to 
reproduce the behavior**.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to