pg_dumpall -h looks up database names locally. - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject pg_dumpall -h looks up database names locally.
Date
Msg-id 200012212030.eBLKU7349466@hub.org
Whole thread Raw
Responses Re: pg_dumpall -h looks up database names locally.  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-bugs
Scott Marlowe (smarlowe@ihs.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
pg_dumpall -h looks up database names locally.

Long Description
pg_dumpall -h should dump all the databases on a remote box, but instead appears to be looking up the names of the
databasesto backup locally, then running the backup of the databases with the same name on the remote host.  If both
thelocal and remote machines have the same named databases, then pg_dumpall -h will work. 

If the host machine has databases that aren't on the client machine, then those databases will not get backed up, with
noerror message or any kind. 

If the client machine has databases that don't exist on the remote host, then pg_dumpall will fail with an error
messagethat the databases that exist on the client do not exist on the remote host. 

Sample Code
host machine has databases named test1 and test2.  Client machine has databases named test1, test2, and test3.

client# >pg_dumpall -h remote_host >file.dmp
Connection to database 'test3' failed.
FATAL 1:  Database "test3" does not exist in the system catalog.

This bug has been confirmed on two different sets of test machines, both built from source files, one set running 7.0.2
andone set running 7.0.3.  They are setup to use "trust" mode authentication (i.e. no authentication at all) and all
otheroperations occurr normally.  pg_dump -h hostname databasename works fine across the network. 

Luckily the fix is VERY easy, since pg_dumpall is a shell script.

All I had to do was add $1 $2 to each psql command like so:

psql -A -q -t template1

becomes

psql $1 $2 -A -q -t template1

And interestingly, since $1 and $2 are normally empty for local dumps, they don't interfere with those either.

No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: postgresql process crashes on select * from cmd_sm (which is a view)
Next
From: Peter Eisentraut
Date:
Subject: Re: pg_dumpall -h looks up database names locally.