Fix PostgreSQL-Compatible Timestamp Handling in SQL Engine #453
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves Issue #1149 by fixing the inability to insert or update
TIMESTAMP
values in immudb using PostgreSQL-compatible SQL syntax, which caused errors likeorg.postgresql.util.PSQLException: ERROR: value is not a timestamp
. The issue stemmed from immudb’s SQL engine not handling PostgreSQL timestamp formats (e.g.,YYYY-MM-DD HH:MM:SS
) or implicit casts, unlike PostgreSQL. The fix enhances the SQL engine and JDBC driver integration to support PostgreSQL-compatible timestamp formats,CURRENT_TIMESTAMP
, and epoch milliseconds.Key changes:
pkg/database/sql.go
to parse PostgreSQL timestamp formats (YYYY-MM-DD HH:MM:SS
, ISO 8601, epoch milliseconds) inParseSQLValue
.CURRENT_TIMESTAMP
andNOW()
in SQL statements.pkg/client/jdbc/immudb_driver.go
to handletime.Time
parameters in JDBC, converting toYYYY-MM-DD HH:MM:SS
.pkg/database/sql_test.go
andpkg/client/jdbc/immudb4j_test.go
to verify timestamp insertion and querying.write: broken pipe
errors by ensuring robust parameter handling.What are the main choices made to get to this solution?
YYYY-MM-DD HH:MM:SS
, ISO 8601, epoch) to align with PostgreSQL’s flexibility [].time.Time
to string format in the JDBC driver to ensure compatibility with immudb’s SQL engine [].CURRENT_TIMESTAMP
andNOW()
with formatted timestamps to simplify SQL processing.