You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "GavinHua (via GitHub)" <gi...@apache.org> on 2023/04/20 03:02:41 UTC

[GitHub] [shardingsphere] GavinHua commented on issue #17973: use SQLServer Paging statements can cause some problems(Normal query does not cause problems)

GavinHua commented on issue #17973:
URL: https://github.com/apache/shardingsphere/issues/17973#issuecomment-1515644377

   #23544
   
   https://github.com/apache/shardingsphere/blob/07eb5011a4f4e2a5bda9e1a5667ed753a8329c0f/sql-parser/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/impl/SQLServerStatementSQLVisitor.java#L788-L805
   
   
   ```sql
   select id, name, create_time from dbo.test_sharding order by create_time desc 
   OFFSET #{offset} ROWS FETCH NEXT #{rows} ROWS ONLY
   ```
   
   Taking this SQL as an example, there are two parameters, `offset` and `rows`, which means that `parameterMarkerSegments.size()=2`. 
   
   However, when constructing the ParameterMarkerLimitValueSegment, the index used is `parameterMarkerSegments.size()` instead of `parameterMarkerSegments.size() - 1`. 
   
   I think this is what's causing the exception to be thrown in subsequent executions of `java.lang.IndexOutOfBoundsException: Index: 2, Size: 2`.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org