You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "JINWANDALAOHU250 (via GitHub)" <gi...@apache.org> on 2024/08/01 08:09:26 UTC

[I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

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

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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "JINWANDALAOHU250 (via GitHub)" <gi...@apache.org>.
JINWANDALAOHU250 commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-2264325690

   In the description of the official documentation, `ShardingSphere-JDBC` supports SQL Server and supports pagination query. I'm not asking you to make enhancements, I'm trying to explain what already exists (possibly). If you don't fix any SQL like `SELECT ... FROM	... WHERE ... ORDER BY ... DESC OFFSET ... ROWS FETCH NEXT ... ROWS ONLY`, the problem will arise. So I would like to ask you to confirm this situation and fix the bug as much as possible if there is indeed such a problem.


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "JINWANDALAOHU250 (via GitHub)" <gi...@apache.org>.
JINWANDALAOHU250 commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-2264326608

   
   > No plan to enhance with SQLServer for now, does any one want to do it?
   
   In the description of the official documentation, ShardingSphere-JDBC supports SQL Server and supports pagination query. I'm not asking you to make enhancements, I'm trying to explain what already exists (possibly). If you don't fix any SQL like SELECT ... FROM	... WHERE ... ORDER BY ... DESC OFFSET ... ROWS FETCH NEXT ... ROWS ONLY, the problem will arise. So I would like to ask you to confirm this situation and fix the bug as much as possible if there is indeed such a problem.


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "ClaireLytt (via GitHub)" <gi...@apache.org>.
ClaireLytt commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-4003975310

   I tested on the latest version, the problem is now fixed. This issue can be closed.


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-2264466918

   I cannot suggest without investigate.
   Please try.


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-2262957760

   No plan to enhance with SQLServer for now, does any one want to do it?


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed issue #32354: problem in SQLServerStatementSQLVisitor.class
URL: https://github.com/apache/shardingsphere/issues/32354


-- 
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


Re: [I] problem in SQLServerStatementSQLVisitor.class [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #32354:
URL: https://github.com/apache/shardingsphere/issues/32354#issuecomment-4004067955

   @ClaireLytt Thank you for your feedback, I will close this issue.


-- 
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