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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]