From: | thilo(at)riessner(dot)de |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | libpq binary data |
Date: | 2014-10-01 16:26:08 |
Message-ID: | 3808965.tNLrlL6qTR@thilo.site |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hello,
I try to get the epoch value of a date via the
PQexecParams(conn, "SELECT extract(epoch from date + time) as epoch, content
FROM daten .....);
In that database, the timestamp ist stored in the two fields date and time.
I want to get this data in binary form. The
PQfsize(res, 1);
tells me, that the size of the returned data is 8 byte (in contrast to the
standard size of epoch, which is meant to be 4 byte)
I don't manage to get the epoch valule (seconds since 1970) from that returned
value. After ntohll (which I wrote as a wrapper around ntohl for long int, see
below) it is a very huge value (4743709917079142400) but it should be
1412179252 as I get it from the psql interface, when I type in the same
command.
What am I missing or doing wrong?
Thanks for any help in advance
Thilo
unsigned long int ntohll(long int x)
{
if (ntohl(1) == 1)
return x;
else
return (long int) (ntohl((int)((x << 32) >> 32))) << 32 | (long
int)ntohl(((int)(x >> 32)));
}
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Verite | 2014-10-01 19:45:50 | Re: libpq binary data |
Previous Message | frank ernest | 2014-09-15 20:08:53 | Re: segfault in libpq |