X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 26AAF9FB1EA for ; Mon, 7 Aug 2006 04:34:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 41336-10 for ; Mon, 7 Aug 2006 04:34:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.179]) by postgresql.org (Postfix) with ESMTP id C00579FB1C0 for ; Mon, 7 Aug 2006 04:34:35 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id n25so461627pyg for ; Mon, 07 Aug 2006 00:34:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HhUS5SOXxPMzsLkdC7U/nk79K6M2uGW6vCDLmkPMjImtd/MIQCGg+OWGwoFdKBB4dEqiN+xRSyxLj15QpdpfWQb844lkqZbt8FuIpBBabe2UO2wXSZmAeRIF0lq/k4RyPO4+ZqG3OYCeNH7VELZd+MEAFsrOgtkL9YUD3T8sZDo= Received: by 10.35.110.13 with SMTP id n13mr11638193pym; Mon, 07 Aug 2006 00:34:34 -0700 (PDT) Received: by 10.35.115.8 with HTTP; Mon, 7 Aug 2006 00:34:34 -0700 (PDT) Message-ID: Date: Mon, 7 Aug 2006 09:34:34 +0200 From: Andro To: pgsql-interfaces@postgresql.org Subject: Re: PQftype() and Oid In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20060805071426.GA1404@alamut.tdm.local> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.424 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/15 X-Sequence-Number: 6229 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 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. >