Re: Binary encoding of timetz type - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Binary encoding of timetz type
Date
Msg-id CAHyXU0yVpyThLFHUqNbZ4eMbPfw1+ubgW5P=ocfPm7=iX8Bz7g@mail.gmail.com
Whole thread Raw
Responses Re: Binary encoding of timetz type  (Kenneth Marshall <ktm@rice.edu>)
List pgsql-general
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
fieldhas 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'::timetzis 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



pgsql-general by date:

Previous
From: "Saha, Sushanta K"
Date:
Subject: Re: [E] Re: CSV From Oracle with timestamp column getting errors
Next
From: Kenneth Marshall
Date:
Subject: Re: Binary encoding of timetz type