fengyc opened a new issue #14552:
URL: https://github.com/apache/shardingsphere/issues/14552
## Bug Report
### Which version of ShardingSphere did you use?
5.0.0
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
SQL:
```
insert into circle_post (id, uid, anonymous, content, loc, audit, likes,
replies, create_at)
values (?, ?, ?, ?, st_geomfromtext(?, 4326), ?, 0, 0, now())
```
Prarameters:
```
0, 0, false, '', 'POINT (0 0)', 'PASS'
```
There are 6 parameters, but after sql rewrite, only 5 parameters are
recognized, and got an exception:
```
SQL: insert into circle_post (id, uid, anonymous, content, loc, audit,
likes, replies, create_at) values (?, ?, ?, ?, st_geomfromtext(?,
4326), ?, 0, 0, now())
Cause: java.sql.SQLException: No value specified for parameter 6
```
### Actual behavior
ShardingSphere should got 6 parameters, not 5.
### Reason analyze (If you can)
This is an insert statement, when I dig deeper into the code, I think there
is a bug in sql parsing in
`org/apache/shardingsphere/infra/binder/segment/insert/values/InsertValueContext.java`
.
```
public InsertValueContext(final Collection<ExpressionSegment> assignments,
final List<Object> parameters, final int parametersOffset) {
valueExpressions = getValueExpressions(assignments);
parameterMarkerExpressions =
ExpressionExtractUtil.getParameterMarkerExpressions(assignments);
parameterCount = parameterMarkerExpressions.size();
this.parameters = getParameters(parameters, parametersOffset);
}
```
The `valeExpressions` could only get 5 parameters.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
See the sql and parameters above.
### Example codes for reproduce this issue (such as a github link).
See the sql and parameters above.
--
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]