X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id C59FD9FB2CD for ; Sat, 5 Aug 2006 04:16:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 51697-10 for ; Sat, 5 Aug 2006 07:16:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fep06.ttnet.net.tr (mail.ttnet.net.tr [212.175.13.129]) by postgresql.org (Postfix) with ESMTP id E36D59FA5E9 for ; Sat, 5 Aug 2006 04:16:27 -0300 (ADT) Received: from by AVGW-I-7.ttnet.net.tr via smtp id 7245_4ee75364_2452_11db_9abe_001143376e77; Sat, 05 Aug 2006 10:16:27 +0300 Received: from alamut ([212.174.26.173]) by fep06.ttnet.net.tr with ESMTP id <20060805071624.QIYN28414.fep06.ttnet.net.tr@alamut>; Sat, 5 Aug 2006 10:16:24 +0300 Date: Sat, 5 Aug 2006 10:14:26 +0300 From: Volkan YAZICI To: Andro Cc: pgsql-interfaces@postgresql.org Subject: Re: PQftype() and Oid Message-ID: <20060805071426.GA1404@alamut.tdm.local> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200608/12 X-Sequence-Number: 6226 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.