Re: Getting oid with libpq

From: jtv(at)xs4all(dot)nl
To: "Johan C(dot) de Koning" <johan(dot)de(dot)koning(at)geodan(dot)nl>
Cc: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, jtv(at)xs4all(dot)nl, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Getting oid with libpq
Date: 2005-08-13 06:20:02
Message-ID: 22138.203.170.164.130.1123914002.squirrel@203.170.164.130
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message William ZHANG 2005-08-13 13:10:46 Re: [BUGS] BUG #1815: ECPGdebug causes crash on Windows XP
Previous Message Bruce Momjian 2005-08-13 02:44:19 Re: [BUGS] BUG #1815: ECPGdebug causes crash on Windows XP