libpq -- reading a timestamp with time zone using binary format

Started by Whit Armstrongabout 17 years ago3 messagesgeneral
Jump to latest
#1Whit Armstrong
armstrong.whit@gmail.com

how does one determine whether libpq is sending an int64 or a double?

I see all of the #ifdefs in the source:

#ifdef HAVE_INT64_TIMESTAMP
static int64 time2t(const int hour, const int min, const int sec,
const fsec_t fsec);
#else
static double time2t(const int hour, const int min, const int sec,
const fsec_t fsec);
#endif

but it is still unclear (at least to me) how to determine as the
client whether the server has been compiled with the
HAVE_INT64_TIMESTAMP flag.

since both int64 and double use 8 bytes of storage on x86_64, you
can't determine the type using PQfsize.

Any suggestions would be appreciated.

-Whit

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Whit Armstrong (#1)
Re: libpq -- reading a timestamp with time zone using binary format

Whit Armstrong <armstrong.whit@gmail.com> writes:

but it is still unclear (at least to me) how to determine as the
client whether the server has been compiled with the
HAVE_INT64_TIMESTAMP flag.

You look at the integer_datetimes parameter. You could execute a
SQL "SHOW" command, but in a libpq client it's sufficient to use
PQparameterStatus(), because this value is sent automatically
during connection startup.

regards, tom lane

#3Whit Armstrong
armstrong.whit@gmail.com
In reply to: Tom Lane (#2)
Re: libpq -- reading a timestamp with time zone using binary format

Thanks, Tom.

That's just what I needed.

-Whit

Show quoted text

On Mon, Mar 23, 2009 at 7:15 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Whit Armstrong <armstrong.whit@gmail.com> writes:

but it is still unclear (at least to me) how to determine as the
client whether the server has been compiled with the
HAVE_INT64_TIMESTAMP flag.

You look at the integer_datetimes parameter.  You could execute a
SQL "SHOW" command, but in a libpq client it's sufficient to use
PQparameterStatus(), because this value is sent automatically
during connection startup.

                       regards, tom lane