pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PQftype() and Oid
3+ messages / 2 participants
[nested] [flat]

* PQftype() and Oid
@ 2006-08-04 14:38  Andro <andromede@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Andro @ 2006-08-04 14:38 UTC (permalink / raw)
  To: pgsql-interfaces

Hi,

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?

Thanks

Charles

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PQftype() and Oid
@ 2006-08-05 07:14  Volkan YAZICI <yazicivo@ttnet.net.tr>
  parent: Andro <andromede@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Volkan YAZICI @ 2006-08-05 07:14 UTC (permalink / raw)
  To: Andro <andromede@gmail.com>; +Cc: 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.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PQftype() and Oid
@ 2006-08-07 07:34  Andro <andromede@gmail.com>
  parent: Volkan YAZICI <yazicivo@ttnet.net.tr>
  0 siblings, 0 replies; 3+ messages in thread

From: Andro @ 2006-08-07 07:34 UTC (permalink / raw)
  To: pgsql-interfaces

While I agree this is a reliable way of matching, this has a
significant impact on performance to make an extra query on each field
that I want the type of ! And this makes this approach definitly not
the one to implement IMO.

Best,

Charles

On 8/5/06, Volkan YAZICI <yazicivo@ttnet.net.tr> wrote:
> 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.
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-08-07 07:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-04 14:38 PQftype() and Oid Andro <andromede@gmail.com>
2006-08-05 07:14 ` Volkan YAZICI <yazicivo@ttnet.net.tr>
2006-08-07 07:34   ` Andro <andromede@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox