pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedBinary encoding of timetz type
4+ messages / 4 participants
[nested] [flat]
* Binary encoding of timetz type
@ 2021-03-16 18:30 Ruslan <ruslan@walkmind.com>
2021-03-16 19:00 ` Re: Binary encoding of timetz type Tom Lane <tgl@sss.pgh.pa.us>
2021-03-23 01:11 ` Re: Binary encoding of timetz type Merlin Moncure <mmoncure@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Ruslan @ 2021-03-16 18:30 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi folks,
Apologies if it's the wrong place to ask. I have a question for postgres
developers.
I wrote parser for COPY binary encoding. Everything is great but one thing
worries me. It seems like the time offset field has reversed digit sign.
I'm referring to this function
https://github.com/postgres/postgres/blob/REL_13_STABLE/src/backend/utils/adt/date.c#L2150-L2159
COPY response for value *'13:37:00-0300'::timetz* gives me binary
0x0000000b69d1d70000002a30. And value *'13:37:00+0300'::timetz* is encoded
as 0x0000000b69d1d700ffffd5d0.
0xffffd5d0 is -10800 for signed integer and 0x00002a30 is 10800.
I reverse the sign in my code but feeling that I'm missing something is
nagging me. Please advise.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Binary encoding of timetz type
2021-03-16 18:30 Binary encoding of timetz type Ruslan <ruslan@walkmind.com>
@ 2021-03-16 19:00 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lane @ 2021-03-16 19:00 UTC (permalink / raw)
To: Ruslan <ruslan@d19i00d0skgddi.cloudfront.net>; +Cc: pgsql-general@lists.postgresql.org
Ruslan <ruslan@d19i00d0skgddi.cloudfront.net> writes:
> I wrote parser for COPY binary encoding. Everything is great but one thing
> worries me. It seems like the time offset field has reversed digit sign.
> I'm referring to this function
> https://github.com/postgres/postgres/blob/REL_13_STABLE/src/backend/utils/adt/date.c#L2150-L2159
Reversed compared to what? The code you quote is clearly sending the
internal representation as-is.
There's a lot of confusion in the world about whether positive timezone
offsets correspond to being east or west of Greenwich (not helped any
by the fact that there are relevant standards using both interpretations).
I think that our internal form uses positive-is-west, a/k/a POSIX rules,
but I'm too lazy to go check right now.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Binary encoding of timetz type
2021-03-16 18:30 Binary encoding of timetz type Ruslan <ruslan@walkmind.com>
@ 2021-03-23 01:11 ` Merlin Moncure <mmoncure@gmail.com>
2021-03-23 01:27 ` Re: Binary encoding of timetz type Kenneth Marshall <ktm@rice.edu>
1 sibling, 1 reply; 4+ messages in thread
From: Merlin Moncure @ 2021-03-23 01:11 UTC (permalink / raw)
To: Ruslan <ruslan@walkmind.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Tue, Mar 16, 2021 at 1:31 PM Ruslan <ruslan@walkmind.com> wrote:
>
> Hi folks,
>
> Apologies if it's the wrong place to ask. I have a question for postgres developers.
>
> I wrote parser for COPY binary encoding. Everything is great but one thing worries me. It seems like the time offset field has reversed digit sign. I'm referring to this function
>
> https://github.com/postgres/postgres/blob/REL_13_STABLE/src/backend/utils/adt/date.c#L2150-L2159
>
> COPY response for value '13:37:00-0300'::timetz gives me binary 0x0000000b69d1d70000002a30. And value '13:37:00+0300'::timetz is encoded as 0x0000000b69d1d700ffffd5d0.
>
> 0xffffd5d0 is -10800 for signed integer and 0x00002a30 is 10800.
>
> I reverse the sign in my code but feeling that I'm missing something is nagging me. Please advise.
Check out libpqtypes -- it has client side send/receive functions for
binary format you can crib from.
https://github.com/pgagarinov/libpqtypes/blob/master/source/src/datetime.c
merlin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Binary encoding of timetz type
2021-03-16 18:30 Binary encoding of timetz type Ruslan <ruslan@walkmind.com>
2021-03-23 01:11 ` Re: Binary encoding of timetz type Merlin Moncure <mmoncure@gmail.com>
@ 2021-03-23 01:27 ` Kenneth Marshall <ktm@rice.edu>
0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Marshall @ 2021-03-23 01:27 UTC (permalink / raw)
To: Merlin Moncure <mmoncure@gmail.com>; +Cc: Ruslan <ruslan@walkmind.com>; pgsql-general <pgsql-general@lists.postgresql.org>
On Mon, Mar 22, 2021 at 08:11:55PM -0500, Merlin Moncure wrote:
> Check out libpqtypes -- it has client side send/receive functions for
> binary format you can crib from.
>
> https://github.com/pgagarinov/libpqtypes/blob/master/source/src/datetime.c
>
> merlin
Hi,
I just wanted to +1 the libpqtypes. An excellent piece of work.
Regards,
Ken
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-03-23 01:27 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 18:30 Binary encoding of timetz type Ruslan <ruslan@walkmind.com>
2021-03-16 19:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-03-23 01:11 ` Merlin Moncure <mmoncure@gmail.com>
2021-03-23 01:27 ` Kenneth Marshall <ktm@rice.edu>
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