Re: Getting oid with libpq - Mailing list pgsql-interfaces

From jtv@xs4all.nl
Subject Re: Getting oid with libpq
Date
Msg-id 22138.203.170.164.130.1123914002.squirrel@203.170.164.130
Whole thread Raw
In response to Re: Getting oid with libpq  ("Johan C. de Koning" <johan.de.koning@geodan.nl>)
List pgsql-interfaces
> I tried to use atol but i get always 0 as result. Is this because I use a
> binary cursor to select the data (there are some PostGIS datatypes inside
> my resultset which are binary data).

That changes everything.

With a binary cursor you get all data in a binary format which "I'm sure
is documented somewhere."  I believe in the case of oids it's a 32-bit
integer in network (big-endian) byte order.  If that is indeed the case,
you should be able to read the oid as "ntohl(*(uint32_t
*)PQgetValue(...))".

On a side note, I don't think you actually need a binary cursor to
transfer binary data (apart from the fact that it's likely to improve
performance).


Jeroen




pgsql-interfaces by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [BUGS] BUG #1815: ECPGdebug causes crash on Windows XP
Next
From: Michael Fuhr
Date:
Subject: Re: [HACKERS] ECPG ignores SAVEPOINT if first statement of a transaction