X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 29D6B11F61EE for ; Thu, 27 Apr 2006 13:26:13 -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 66934-09 for ; Thu, 27 Apr 2006 13:26:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp1.pcisys.net (smtp1.pcisys.net [216.229.32.113]) by postgresql.org (Postfix) with ESMTP id 67D2311F60E3 for ; Thu, 27 Apr 2006 13:26:01 -0300 (ADT) Received: from [192.168.0.101] (dsl-206-53-28-122.cos.pcisys.net [206.53.28.122]) by smtp1.pcisys.net (8.13.6/8.13.6) with ESMTP id k3RGQ0jC000454 for ; Thu, 27 Apr 2006 10:26:00 -0600 (MDT) User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Thu, 27 Apr 2006 10:25:57 -0600 Subject: Re: PQhost() Returns NULL on Connection From: Keary Suska To: Postgres-Interfaces Message-ID: In-Reply-To: <609.1146095978@sss.pgh.pa.us> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/30 X-Sequence-Number: 6121 on 4/26/06 5:59 PM, tgl@sss.pgh.pa.us purportedly said: >> Why would PQhost() return NULL on a valid connection? > > One reason why would be if you'd selected the server by hostaddr rather > than host. Returning a host name in this case would require a DNS > lookup, and since the entire point of the hostaddr feature is to avoid > DNS lookups, I don't think that's a particularly great idea. > > These functions are really defined as "give me back the connection > options that were specified", anyway, not "peek inside to see what > values are actually in use". So a NULL for an unspecified option > seems reasonable to me. I wasn't sure, because the behavior is not consistent. For instance, PQport() will return a value regardless of the connection type and parameters passed to connect. Also, there doesn't appear to be a way to retrieve hostaddr even if specified, so I thought maybe the PQhost() was more generic. E.g. the lib could return an address if specified and not have to do a wasteful DNS lookup. Considering that the connection status functions exist to retrieve parameter values, it would at least be good to have access to all of them, and not just a selection of them. Best, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business"