You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "Y-sir (via GitHub)" <gi...@apache.org> on 2025/03/12 08:58:38 UTC

[I] In the opengauss database, when using limit ?, ?, the parameter parsing order is wrong [shardingsphere]

Y-sir opened a new issue, #34961:
URL: https://github.com/apache/shardingsphere/issues/34961

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   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?
   5.5.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   ![Image](https://github.com/user-attachments/assets/fd34ec11-16ab-4ac4-b1f9-d11f5900899b)
   
   ### Actual behavior
   
   ![Image](https://github.com/user-attachments/assets/eaa5c849-3b2f-456d-8649-d945387d2c48)
   
   ### Reason analyze (If you can)
   
   Printing in the log, it is found that the parameters after limit are caused by the order problem
   <!-- Failed to upload "image.png" -->
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   1、 `CREATE TABLE employees (
       id SERIAL PRIMARY KEY,
       name VARCHAR(50) NOT NULL,
       age INT CHECK (age > 18),
       department VARCHAR(50),
       salary DECIMAL(10,2)
   );`
   
   2、 `INSERT INTO opengauss.employees
   (id, "name", age, department, salary)
   VALUES(1, '张三', 28, '研发', 12000.50);
   INSERT INTO opengauss.employees
   (id, "name", age, department, salary)
   VALUES(2, '李四', 29, '市场', 10800.00);
   INSERT INTO opengauss.employees
   (id, "name", age, department, salary)
   VALUES(3, '王五', 30, '销售', 12000.50);
   INSERT INTO opengauss.employees
   (id, "name", age, department, salary)
   VALUES(4, '赵六', 31, '经理', 20215.25);`
   
   3、 `            String sql = "SELECT * FROM employees order by id limit ? , ?;";
               PreparedStatement psmt = conn.prepareStatement(sql);
               psmt.setInt(1,2);
               psmt.setInt(2,1);`
   
   ### 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] In the opengauss database, when using limit ?, ?, the parameter parsing order is wrong [shardingsphere]

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

   已按维护者认可的方向提交新 PR。
   
   **根因**:`OpenGaussStatementVisitor#createLimitSegmentWhenRowCountOrOffsetAbsent` 对 `LIMIT offset, row-count` 先访问 row-count、后访问 offset;而参数下标按访问顺序赋值(`visitParameterMarker` 返回当时的 `parameterMarkerSegments.size()`),导致词法第 1 个 `?`(offset) 取到 index 1、第 2 个 `?`(row-count) 取到 index 0,下标反转。
   
   **修复**:先访问 offset、再访问 row-count,使下标与词法顺序一致(与 `DorisStatementVisitor` 一致)。仅交换两行访问顺序,`LimitSegment` 构造不变。已补回归测试并通过 Spotless/Checkstyle/PMD/SpotBugs。
   
   鸣谢 @daguimu 在 #38647 的前期诊断。


-- 
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] In the opengauss database, when using limit ?, ?, the parameter parsing order is wrong [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #34961: In the opengauss database, when using limit ?, ?, the parameter parsing order is wrong
URL: https://github.com/apache/shardingsphere/issues/34961


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