Open FakeKotaro opened 1 year ago
@FakeKotaro Thank you for your feedback, I will investigate this issue.
@FakeKotaro Thank you for your feedback, I will investigate this issue. @strongduanmu Have you solved this problem? I saw a bugfix (25033) in 20096. I overwrote the file in fix to the local and this error still occurred. I used postgrea https://github.com/apache/shardingsphere/pull/25033 databaseType:postgrea version: 5.3.2 config:
rules: # 加密策略 - !ENCRYPT encryptors: enc-aes-c: type: AES-C props: aes-c-key-value: ${shardingsphere.encrypt.commons.ept-zqsb.aes-c-key-value} enc-sha256: type: ${shardingsphere.encrypt.commons.enc-sha256} tables: t_person0: columns: person_name: encryptorName: enc-aes-c cipherColumn: person_name_plain assistedQueryColumn: person_name_query assistedQueryEncryptorName: enc-sha256 plainColumn: person_name
sql:
SELECT COUNT(1) FROM (SELECT DISTINCT person_name personName, gender FROM t_person0 WHERE personName IS NOT NULL) TOTAL
error:### Error querying database. Cause: java.sql.SQLException: Unknown exception: String index out of range: -22 ### The error may exist in com/thunisoft/ept/zqsb/mapper/Person0Mapper.java (best guess) ### The error may involve com.thunisoft.ept.zqsb.mapper.Person0Mapper.findPageAsDistinct-Inline ### The error occurred while setting parameters ### SQL: SELECT COUNT(1) FROM (SELECT DISTINCT person_name personName, gender FROM t_person0 WHERE personName IS NOT NULL) TOTAL ### Cause: java.sql.SQLException: Unknown exception: String index out of range: -22 ; uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown exception: String index out of range: -22; nested exception is java.sql.SQLException: Unknown exception: String index out of range: -22]
Override:
After testing, it is not related to count (1)
If you are using ShardingSphere with Mybatis PageHelper, you can try to write a count SQL for your original SQL.
Consider the original SQL function called query
, write a query_COUNT
for it, Mybatis PageHelper will use query_COUNT
to count total rows.
This approach will solve the String index out of range
Exception.
Bug Report
Which version of ShardingSphere did you use?
5.3.1
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
My SQL:
My Encryption Config:
Then it throws an exception:
The expected actual SQL show be:
It's worth noting that this issue has been mentioned before in version 5.1.2, but it has never been fixed #20096