JINWANDALAOHU250 opened a new issue, #32354:
URL: https://github.com/apache/shardingsphere/issues/32354

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   ```xml
    <dependency>
     <groupId>org.apache.shardingsphere</groupId>
     <artifactId>shardingsphere-jdbc-core</artifactId>
     <version>5.3.2</version>
   </dependency>
   ```
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   `ShardingSphere-JDBC`
   ### Expected behavior
   execute sql like 
   ```sql
   SELECT
        * 
   FROM
        message_mst 
   WHERE
        readed = 0 
   ORDER BY
        msg.create_dt DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY
   ```
   
   then parse to
   ```sql
   Actual SQL: slave :::
   SELECT
        * 
   FROM
        message_mst 
   WHERE
        readed = 0 
   ORDER BY
        msg.create_dt DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY
   
   ::: [10, 5]
   ```
   ### Actual behavior
   ```log
   ### Cause: java.sql.SQLException: Unknown exception: Index: 2, Size: 2
   ; uncategorized SQLException for SQL []; SQL state [HY000]; error code 
[30000]; Unknown exception: Index: 2, Size: 2; nested exception is 
java.sql.SQLException: Unknown exception: Index: 2, Size: 2
   ```
   ### Reason analyze (If you can)
   In class `SQLServerStatementSQLVisitor.class#visitOrderBy` ,offset 
paramIndex and rowcount paramIndex not right, caused `PaginationContext` get 
param in List<Object> params out of bounds. 
   ```java
   // SQLServerStatementSQLVisitor
   ... line 788
                   // param index is 'parameterMarkerSegments.size() - 1'
                   offset = new 
ParameterMarkerLimitValueSegment(ctx.expr(0).start.getStartIndex(), 
ctx.expr(0).stop.getStopIndex(), parameterMarkerSegments.size());
   ...
   ...
                   // param index is 'parameterMarkerSegments.size() - 1'
                   rowcount = new 
ParameterMarkerLimitValueSegment(ctx.expr(1).start.getStartIndex(), 
ctx.expr(1).stop.getStopIndex(), parameterMarkerSegments.size());
   ...
   
   // PaginationContext
   ...line 56
   // getParameterIndex() caused Unknown exception: Index: 2, Size: 2
   Object obj = null == params || params.isEmpty() ? 0L : 
params.get(((ParameterMarkerPaginationValueSegment) 
paginationValueSegment).getParameterIndex());
   ...
   ```
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   SpringBoot + Mybatis + Similar to the `sql` mentioned above
   ### 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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to