You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "FlyingZC (via GitHub)" <gi...@apache.org> on 2025/12/09 03:14:46 UTC
[I] Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException [shardingsphere]
FlyingZC opened a new issue, #37307:
URL: https://github.com/apache/shardingsphere/issues/37307
## Bug Report
Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException
### Which version of ShardingSphere did you use?
Master.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
SQL executes normally.
### Actual behavior
```
[INFO ] 2025-12-09 11:09:37.262 [main] org.apache.shardingsphere.sql - Actual SQL: encrypt ::: create table test_table(id int, name varchar2(255), level1 int)
Exception in thread "main" java.sql.SQLException: Unknown exception.
More details: java.lang.NumberFormatException: For input string: "5214|1521|5152|1616|218|8226"
at org.apache.shardingsphere.infra.exception.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:81)
at org.apache.shardingsphere.database.exception.core.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:68)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeQuery(ShardingSpherePreparedStatement.java:196)
at com.sphereex.dbplusengine.test.JdbcMain.main(JdbcMain.java:42)
Caused by: java.lang.NumberFormatException: For input string: "5214|1521|5152|1616|218|8226"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Long.parseLong(Long.java:692)
at java.base/java.lang.Long.parseLong(Long.java:817)
at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext.getValue(PaginationContext.java:65)
at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext.<init>(PaginationContext.java:52)
at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine.RowNumberPaginationContextEngine.createPaginationWithRowNumber(RowNumberPaginationContextEngine.java:159)
at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine.RowNumberPaginationContextEngine.createPaginationContext(RowNumberPaginationContextEngine.java:68)
at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine.PaginationContextEngine.createPaginationContext(PaginationContextEngine.java:69)
at org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementBindingContext.<init>(SelectStatementBindingContext.java:53)
at org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext.bindParameters(SelectStatementContext.java:395)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createQueryContext(ShardingSpherePreparedStatement.java:280)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeQuery(ShardingSpherePreparedStatement.java:180)
... 1 more
```
### Reason analyze (If you can)
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
```java
public class JdbcMain{
public static final String SHARDING_SPHERE_DRIVER = "org.apache.shardingsphere.driver.ShardingSphereDriver";
public static final String SPHEREEX_DRIVER = "com.sphereex.dbplusengine.driver.SphereExDriver";
public static void main(String[] args) throws Exception {
Connection conn = getConnectionss();
try {
executeWithLog(conn, "drop table test_table");
} catch (SQLException e) {
}
try {
executeWithLog(conn, "create table test_table(id int, name varchar2(255), level1 int)");
} catch (SQLException e) {
throw new RuntimeException(e);
}
String sql = "SELECT \n" +
" *\n" +
"FROM \n" +
" test_table\n" +
"WHERE \n" +
" name IN (\n" +
" SELECT \n" +
" REGEXP_SUBSTR('5214|1521|5152|1616|218|8226', '[^|]+', 1, level1) \n" +
" FROM \n" +
" dual \n" +
" CONNECT BY \n" +
" REGEXP_SUBSTR(?, 1, level1) IS NOT NULL\n" +
" ) \n" +
" AND ROWNUM <= ?";
PreparedStatement psmt = conn.prepareStatement(sql);
psmt.setObject(1, "5214|1521|5152|1616|218|8226");
psmt.setObject(2, 10);
ResultSet resultSet = psmt.executeQuery();
printQueryResultSet(resultSet);
}
private static Connection getConnectionss() throws Exception {
if (false) {
return getConnection("oracle.jdbc.OracleDriver", "jdbc:oracle:thin:@localhost:11521:xe", "system", "oracle");
}
return getShardingSphereConnection("/rules.yaml");
}
public static Connection getShardingSphereConnection(String path) throws Exception {
String jdbcUrl = "jdbc:shardingsphere:absolutepath:" + path;
return SQLUtil.getConnection(SHARDING_SPHERE_DRIVER, jdbcUrl, "root", "root");
}
```
rules.yaml
```yaml
databaseName: encrypt
dataSources:
encrypt:
url: jdbc:oracle:thin:@localhost:11521:xe
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
username: system
password: oracle
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SINGLE
tables:
- "*.*"
props:
sql-show: true
```
### 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] Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException [shardingsphere]
Posted by "ClaireLytt (via GitHub)" <gi...@apache.org>.
ClaireLytt commented on issue #37307:
URL: https://github.com/apache/shardingsphere/issues/37307#issuecomment-3839274436
Hi, I'm intersted in this issue. please assign this issue to me. Thank you.
--
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] Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed issue #37307: Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException
URL: https://github.com/apache/shardingsphere/issues/37307
--
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] Oracle SQL parser fails to extract REGEXP_SUBSTR parameters correctly, causing NumberFormatException [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #37307:
URL: https://github.com/apache/shardingsphere/issues/37307#issuecomment-3857366562
Fixed by [#37924](https://github.com/apache/shardingsphere/pull/37924)
--
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