pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedBinary encoding of TIMESTAMP WITH TIME ZONE
3+ messages / 3 participants
[nested] [flat]
* Binary encoding of TIMESTAMP WITH TIME ZONE
@ 2020-06-05 00:24 Joe Abbate <jma@freedomcircle.com>
2020-06-05 00:32 ` Re: Binary encoding of TIMESTAMP WITH TIME ZONE Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Joe Abbate @ 2020-06-05 00:24 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
I'm dealing with an issue where a query uses 'today'::date to select one
of a number of rows depending on the day modulo the number of rows. The
intent is that different information will be shown starting after
midnight local time. The query runs as expected in psql and using psycopg2.
However, when using the same query using the Rust adapter the transition
to a new row started showing up after midgnight GMT. I opened an issue
on Github (https://github.com/sfackler/rust-postgres/issues/608 ) and
the maintainer claimed the Rust adapter *had* to initialize timezone to
UTC in order to properly convert "to and from time datatypes". I
pointed out that the timezone offset is available in psql and psycopg2,
but then he replied the binary encoding of timestamptz does *not*
include the timezone offset.
He pointed me to the function timestamptz_send() which per the comments
"converts timestamptz to binary format". I found that the TimestampTz
used in the function is a typedef for an int64, but since I'm not
familiar with the code, I can't tell if timezone offset is embedded in
there or not.
I'm hoping someone reading this can confirm (or deny) the above (or do I
need to ask the -hackers list?).
Regards,
Joe
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Binary encoding of TIMESTAMP WITH TIME ZONE
2020-06-05 00:24 Binary encoding of TIMESTAMP WITH TIME ZONE Joe Abbate <jma@freedomcircle.com>
@ 2020-06-05 00:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-05 15:30 ` Re: Binary encoding of TIMESTAMP WITH TIME ZONE Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2020-06-05 00:32 UTC (permalink / raw)
To: Joe Abbate <jma@freedomcircle.com>; +Cc: pgsql-general@lists.postgresql.org
Joe Abbate <jma@freedomcircle.com> writes:
> However, when using the same query using the Rust adapter the transition
> to a new row started showing up after midgnight GMT. I opened an issue
> on Github (https://github.com/sfackler/rust-postgres/issues/608 ) and
> the maintainer claimed the Rust adapter *had* to initialize timezone to
> UTC in order to properly convert "to and from time datatypes". I
> pointed out that the timezone offset is available in psql and psycopg2,
> but then he replied the binary encoding of timestamptz does *not*
> include the timezone offset.
Indeed it does not, just as the on-disk format for it does not. The
representation is effectively always in UTC. If you have some other
timezone setting selected, timestamptz_out rotates to that zone for
display purposes ... but the binary format doesn't.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Binary encoding of TIMESTAMP WITH TIME ZONE
2020-06-05 00:24 Binary encoding of TIMESTAMP WITH TIME ZONE Joe Abbate <jma@freedomcircle.com>
2020-06-05 00:32 ` Re: Binary encoding of TIMESTAMP WITH TIME ZONE Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-06-05 15:30 ` Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 0 replies; 3+ messages in thread
From: Peter J. Holzer @ 2020-06-05 15:30 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2020-06-04 20:32:51 -0400, Tom Lane wrote:
> Joe Abbate <jma@freedomcircle.com> writes:
> > However, when using the same query using the Rust adapter the transition
> > to a new row started showing up after midgnight GMT. I opened an issue
> > on Github (https://github.com/sfackler/rust-postgres/issues/608 ) and
> > the maintainer claimed the Rust adapter *had* to initialize timezone to
> > UTC in order to properly convert "to and from time datatypes". I
> > pointed out that the timezone offset is available in psql and psycopg2,
> > but then he replied the binary encoding of timestamptz does *not*
> > include the timezone offset.
>
> Indeed it does not, just as the on-disk format for it does not. The
> representation is effectively always in UTC. If you have some other
> timezone setting selected, timestamptz_out rotates to that zone for
> display purposes ... but the binary format doesn't.
However, the explanation still sounds off. I'm not familiar with Rust,
but I wouild expect the Rust time type to be based on Unix time_t or
some variant of it (maybe milliseconds as in Java, or nanoseconds or a
different epoch). That also doesn't include a timezone, so conversion
should be straightforward and not require any timezone to be involved.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-06-05 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 00:24 Binary encoding of TIMESTAMP WITH TIME ZONE Joe Abbate <jma@freedomcircle.com>
2020-06-05 00:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-05 15:30 ` Peter J. Holzer <hjp-pgsql@hjp.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox