Re: PQftype() and Oid

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: Andro <andromede(at)gmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQftype() and Oid
Date: 2006-08-05 07:14:26
Message-ID: 20060805071426.GA1404@alamut.tdm.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Aug 04 04:38, Andro wrote:
> Oids are in pg_type catalog (server side) and src/include/catalog/pg_type.h
> (hard-wired).
>
> But what should we compare the Oid returned by PQftype() with?
> Let's say I want to check if column 1 is a VARCHAR, do I have to
>
> if (PQftype(res,1) == 1043)
> ...;
>
> ?
> Isn't there a kind of enum which we could rely on to find out types? What if
> Oids change in pg_type.h?

You can make another query on pg_type to learn OID of a specific type.
And then compare it with the returned one from PQftype(main_query_res).

Furthermore, I think this is the only reliable way of accomplising this
task. (IIRC, PHP PostgreSQL API does same too.) Otherwise, when you use
hard-wired headers (e.g. by including pg_type.h) what will you do when
related server has a custom type that isn't get shippied with the
PostgreSQL headers you included.

Regards.

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message osxdeveloper 2006-08-05 20:43:35 getting the correct column size....
Previous Message Andro 2006-08-04 14:38:20 PQftype() and Oid