Binary encoding of timetz type

From: Ruslan <ruslan(at)walkmind(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Binary encoding of timetz type
Date: 2021-03-16 18:30:39
Message-ID: CAKPDVBptHtCQ3E7odM-NdAbV+E1eob=sV+s4632HahyPk700mQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2021-03-16 18:31:34 Re: Postgres crashes at memcopy() after upgrade to PG 13.
Previous Message Andrew Anderson 2021-03-16 18:25:16 Re: WAL-files is not removing authomaticaly