Re: dblink does not resolve DNS, but works with IP - Mailing list pgsql-general

From Adrian Klaver
Subject Re: dblink does not resolve DNS, but works with IP
Date
Msg-id 51930E50.7080105@gmail.com
Whole thread Raw
In response to dblink does not resolve DNS, but works with IP  (Mike Christensen <mike@kitchenpc.com>)
Responses Re: dblink does not resolve DNS, but works with IP
List pgsql-general
On 05/14/2013 09:17 PM, Mike Christensen wrote:
> If I have this:
>
> CREATE OR REPLACE VIEW Link.Foo AS
>    select * from dblink(
>      'hostaddr=123.123.123.123 dbname=KitchenPC user=Website
> password=secret',
>      'select * from Foo') as ...
>
> Then it works.  However, if I do:
>
> CREATE OR REPLACE VIEW Link.Foo AS
>    select * from dblink(
>      'hostaddr=db.domain.com <http://db.domain.com> dbname=KitchenPC
> user=Website password=secret',
>      'select * from Foo') as ...
>
> Then I get:
>
> ERROR:  could not establish connection
> DETAIL:  could not translate host name "db.domain.com
> <http://db.domain.com>" to address: Unknown host
>
> However, from a command prompt I can ping db.domain.com
> <http://db.domain.com> and get 123.123.123.123.
>
> Does dblink just not support DNS resolution?  I really don't want to
> hard code IP addresses in my scripts.  Thanks!

See below for explanation of hostaddr and host. Short version, you are
looking for host:

http://www.postgresql.org/docs/9.2/interactive/libpq-connect.html#LIBPQ-PARAMKEYWORDS


--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: How to convert numbers into words in postgresql
Next
From: Mike Christensen
Date:
Subject: Re: dblink does not resolve DNS, but works with IP