Re: pg_restore to a port where nobody is listening?

From: Daniel Westermann <daniel(dot)westermann(at)dbi-services(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: pg_restore to a port where nobody is listening?
Date: 2016-12-21 19:29:20
Message-ID: 973128336.4477760.1482348560823.JavaMail.zimbra@dbi-services.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> postgres(at)pgbox:/home/postgres/ [PG961] pg_restore -h localhost -p 5439 -F d -C -j 2 /var/tmp/exp/
>>
>> This runs fine but where does it connect to? Nothing is listening on port 5439.

>Given the lack of a -d switch, I'd expect it not to try to connect
>anywhere, just emit the restore script on stdout. At least, that's
>what happens for me. It's weird that you don't see any printout.

>(To be clear: it's -d that triggers a connection attempt in pg_restore.
>Without that, -h and -p are just noise.)

Ok, that makes sense. I got the output on screen, as mentioned.

What I would have expected is at least a hint or warning that host and port are ignored if you do not specify the "-d" switch. Giving port and host clearly indicates that I want to connect to what I provided, doesn't it? psql uses the os username as default database, pg_restore doesn't?

postgres(at)pgbox:/home/postgres/ [PG961] unset PGDATABASE
postgres(at)pgbox:/home/postgres/ [] psql
psql (9.6.1)
Type "help" for help.

(postgres(at)[local]:5439) [postgres] >

Providing "-d" gives a meaningful message at least:

postgres(at)pgbox:/home/postgres/ [PG961] pg_restore -h localhost -p ===6666 -d postgres -F d -C /var/tmp/exp/
pg_restore: [archiver (db)] connection to database "postgres" failed: invalid port number: "===6666"

Maybe it is only me, but this is not consistent behavior, is it?

Regards
Daniel

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2016-12-21 19:46:56 Re: Postgres 9.6 Streaming Replication on Solaris 10
Previous Message Tom DalPozzo 2016-12-21 18:06:16 Re: error updating a tuple after promoting a standby