-
Notifications
You must be signed in to change notification settings - Fork 351
Description
What happened
Update/Insert Timestamp doesn't work with PostgreSQL SQL syntax.
It throws exception as "org.postgresql.util.PSQLException: ERROR: value is not a timestamp: invalid value provided"
That would be the result of incompatibility between SQL syntax in PostgreSQL and immudb - looks like the driver assumes that casts from string to timestamp are implicit.
What you expected to happen
PostgreSQL should be able to update/insert timestamp in immudb using SQL syntax.
How to reproduce it (as minimally and precisely as possible)
- Create one table in immudb.
CREATE TABLE IF NOT EXISTS users (
username VARCHAR[50],
created_at TIMESTAMP,
PRIMARY KEY (username)
);
- Try inserting one row using immudb4j (Java SDK : 0.9.0.6) and PostgreSQL (Version : 42.2.25)
import java.sql.Timestamp;
private final String INSERT_QUERY_USERS = "INSERT INTO USERS (username,created_at) VALUES (?,?)";
String urlForConnection = "jdbc:postgresql://"+url+":"+port+"/"+databaseName+"?sslmode=allow&preferQueryMode=simple";
var connection = DriverManager.getConnection(urlForConnection,"immudb", "immudb");
var client = connection .getClient();
PreparedStatement pstmt = client.prepareStatement(INSERT_QUERY_USERS);
pstmt.setString(1,"TestUserName");
pstmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
pstmt.execute();
Environment
# run immudb 1.2.2 and copy/paste the output here
./immudb -d
immudb 2022/03/18 09:56:25 INFO: SQL Engine ready for database 'defaultdb' {replica = false}
immudb 2022/03/18 09:56:25 INFO: pgsl server is running at port 5432
immudb 2022/03/18 09:56:25 INFO: Webconsole enabled: 0.0.0.0:8080
immudb 2022/03/18 09:56:25 INFO: Web API server enabled on 0.0.0.0:8080/api (http)
You can now use immuadmin and immuclient CLIs to login with the immudb superadmin user and start using immudb.
immudb has been started with PID 211
shashwat32@Eternal007:~$ immudb 2022/03/18 10:23:15 ERROR: unable to write error on wire: write tcp 172.19.66.153:5432->172.19.64.1:53826: write: broken pipe
immudb 2022/03/18 10:23:15 ERROR: unable to complete error handling: write tcp 172.19.66.153:5432->172.19.64.1:53826: write: broken pipe
immudb 2022/03/18 10:23:15 WARNING: connection is closed
immudb 2022/03/18 10:28:46 INFO: 1 transaction/s to be indexed at 'data/defaultdb'
immudb 2022/03/18 10:34:31 ERROR: unable to write error on wire: write tcp 172.19.66.153:5432->172.19.64.1:54138: write: broken pipe
immudb 2022/03/18 10:34:31 ERROR: unable to complete error handling: write tcp 172.19.66.153:5432->172.19.64.1:54138: write: broken pipe
immudb 2022/03/18 10:34:31 WARNING: connection is closed
Additional info (any other context about the problem)
Tried with all kinds of Timestamps but it doesn't work.