Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c/driver/postgresql: Timezone Support #867

Closed
WillAyd opened this issue Jun 30, 2023 · 1 comment · Fixed by #868
Closed

c/driver/postgresql: Timezone Support #867

WillAyd opened this issue Jun 30, 2023 · 1 comment · Fixed by #868

Comments

@WillAyd
Copy link
Contributor

WillAyd commented Jun 30, 2023

Stepping through the postgres source AFAICT the binary protocol expects that TIMESTAMP WITH TIME ZONE records are sent as int64 values, but that int64 value is supposed to represent a local not and not UTC (as it stored natively in arrow):

https://github.com/postgres/postgres/blob/e251e780bfe62168d0edfec459ebdc66b991753f/src/backend/utils/adt/timestamp.c#L1885

Guessing we need to build out some way to localize those values to the server time before passing via the protocol.

@WillAyd
Copy link
Contributor Author

WillAyd commented Jun 30, 2023

I didn't see anything in libpq-fe.h to help with this, but there may be something in another header. Alternately we could try setting the connection timezone to UTC as documented at the end of this section; not sure if there are other reasons for the client to be aware of local time when transmitting data like this:

https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-TIMEZONES

@lidavidm lidavidm changed the title Postgres Timezone Support c/driver/postgresql: Timezone Support Jul 3, 2023
@lidavidm lidavidm added this to the ADBC Libraries 0.6.0 milestone Jul 3, 2023
lidavidm added a commit that referenced this issue Jul 10, 2023
closes #867 

The lifecycle of setting the session time zone in this isn't great. I
think should be handled during connect somehow? But not sure if postgres
even supports that reading things like:

https://stackoverflow.com/a/11779621/621736

I think there is also something awry with the release callback for
timezone schemas; needs further investigation

---------

Co-authored-by: David Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants