h2database / h2database/h2database
TO_TIMESTAMP in Postgresql dialect differs from definition
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 1.3k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Description
I have written a nice query in Postgresql that converts a number of seconds into a timestamp with timezone, for example something like this:
SELECT TO_TIMESTAMP(1284352323);
This should result in a value of 2010-09-13 04:32:03+00.
Unfortunately the definition within the Postgresql Dialect, here h2/src/main/org/h2/mode/FunctionsPostgreSQL.java, expects 2 parameters, and will convert the (optional) first using the format specified in the second parameter to parse it.
I can't find any documentation on the Postgresql site, where the TO_TIMESTAMP function ever worked that way. Do enlighten me if I have missed that.
This is what I can find on https://www.postgresql.org/docs/14/functions-datetime.html:
to_timestamp ( double precision ) → timestamp with time zone
Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to timestamp with time zone
to_timestamp(1284352323) → 2010-09-13 04:32:03+00
Should I look at making a PR for this change?
Cheers,
Bas de Wit
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect h2/src/main/org/h2/mode/FunctionsPostgreSQL.java and the TO_TIMESTAMP handling first. Verify the PostgreSQL one-argument Unix-epoch behavior with the query shown; done means the dialect accepts that form and returns the documented timestamp-with-time-zone result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100