You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zhuzhenting (via GitHub)" <gi...@apache.org> on 2023/02/06 14:46:52 UTC
[GitHub] [shardingsphere] zhuzhenting opened a new issue, #24032: COUNT sql. StringIndexOutOfBoundsException at AbstractSQLBuilder.java:64
zhuzhenting opened a new issue, #24032:
URL: https://github.com/apache/shardingsphere/issues/24032
## Bug Report
### version
use encryption in my project, and the maven dependency:
```xml
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.3.1</version>
</dependency>
```
### Expected behavior
when I remove the encryption configuration, the sql works fine.
``` sql
SELECT COUNT(*) FROM (SELECT DISTINCT (u.id), u.username, uc.card, u.sex, uc.grade_id, uc.grade_name, u.phone, u.email, uc.created AS createTime, u.country_calling_code AS countryCallingCode, u.nick_name, u.user_type AS accountType, a.tel AS attentionPhone, a.country_calling_code AS attentionCountryCallingCode, a.email AS attentionEmail, a.typeId AS attentionTypeId, uc.app_id AS appId, uo.utm AS origin, uo.level1, uo.level2, uo.level3, ut.tag_id FROM users u LEFT JOIN user_cards uc ON u.id = uc.uid LEFT JOIN attention a ON u.id = a.uid AND a.num = 1 LEFT JOIN user_origin uo ON u.id = uo.user_id LEFT JOIN user_tag ut ON u.id = ut.user_id AND ut.school_code = ? WHERE uc.areaCode = ? AND uc.created >= ? AND uc.created <= ?) TOTAL
```
### Actual behavior
it throws an exception:
```java
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -5
at java.lang.String.substring(String.java:1967)
at org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.getConjunctionText(AbstractSQLBuilder.java:64)
at org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.toSQL(AbstractSQLBuilder.java:47)
at org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.addSQLRewriteUnits(RouteSQLRewriteEngine.java:96)
at org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.rewrite(RouteSQLRewriteEngine.java:72)
at org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.rewrite(SQLRewriteEntry.java:73)
at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:59)
at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:47)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:471)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:364)
```
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
this is my tables configuration:
``` yml
tables:
users:
columns:
phone:
logicColumn: phone
plainColumn: phone
cipherColumn: phone_cipher
encryptorName: aes_encryptor
attention:
columns:
tel:
logicColumn: tel
plainColumn: tel
cipherColumn: tel_cipher
encryptorName: aes_encryptor
email:
logicColumn: email
plainColumn: email
cipherColumn: email_cipher
encryptorName: aes_encryptor
recipient:
columns:
tel:
logicColumn: tel
plainColumn: tel
cipherColumn: tel_cipher
encryptorName: aes_encryptor
```
### 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