You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "TeslaCN (via GitHub)" <gi...@apache.org> on 2023/01/28 07:50:56 UTC
[GitHub] [shardingsphere] TeslaCN opened a new issue, #23774: Error occurred when inserting time value with microseconds into ShardingSphere-Proxy PostgreSQL
TeslaCN opened a new issue, #23774:
URL: https://github.com/apache/shardingsphere/issues/23774
## Bug Report
### Which version of ShardingSphere did you use?
master - 70c02a332868c971e34a326995bb8f9a100d5f35
This may affect all versions <= 5.3.1.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy PostgreSQL
### Expected behavior
Insert succeeded.
### Actual behavior
Client log:
```
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: Error at index 2 in: "19.65948"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:166)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:134)
```
Proxy log:
```
[ERROR] 2023-01-28 15:40:32.955 [Connection-2-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.NumberFormatException: Error at index 2 in: "32.949965"
at java.base/java.lang.NumberFormatException.forCharSequence(NumberFormatException.java:83)
at java.base/java.lang.Integer.parseInt(Integer.java:751)
at java.sql/java.sql.Time.valueOf(Time.java:107)
at org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket.getTextParameters(PostgreSQLComBindPacket.java:130)
at org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket.getTextParameters(PostgreSQLComBindPacket.java:99)
at org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket.readParameters(PostgreSQLComBindPacket.java:80)
at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.bind.PostgreSQLComBindExecutor.execute(PostgreSQLComBindExecutor.java:51)
at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended.PostgreSQLAggregatedCommandExecutor.execute(PostgreSQLAggregatedCommandExecutor.java:41)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:110)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
```
### Example codes for reproduce this issue (such as a github link).
```java
try (Statement statement = connection.createStatement()) {
statement.executeUpdate("drop table if exists datetime_pg");
statement.executeUpdate("create table datetime_pg (val_time time not null)");
}
try (PreparedStatement preparedStatement = connection.prepareStatement("insert into datetime_pg values (?)")) {
preparedStatement.setObject(1, LocalTime.now());
preparedStatement.executeUpdate();
}
```
--
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
[GitHub] [shardingsphere] TeslaCN commented on issue #23774: Error occurred when inserting time value with microseconds into ShardingSphere-Proxy PostgreSQL
Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #23774:
URL: https://github.com/apache/shardingsphere/issues/23774#issuecomment-1407325314
Set `prepareThreshold=2` in JDBC URL
```
try (PreparedStatement preparedStatement = connection.prepareStatement("insert into datetime_pg values (?)")) {
preparedStatement.setObject(1, new Time(System.currentTimeMillis()));
// preparedStatement.setTime(1, new Time(System.currentTimeMillis())); // Same as above
preparedStatement.executeUpdate(); // Succeeded
preparedStatement.executeUpdate(); // Failed
}
```
--
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
[GitHub] [shardingsphere] strongduanmu closed issue #23774: Error occurred when inserting time value with microseconds into ShardingSphere-Proxy PostgreSQL
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed issue #23774: Error occurred when inserting time value with microseconds into ShardingSphere-Proxy PostgreSQL
URL: https://github.com/apache/shardingsphere/issues/23774
--
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