Re: BUG #7507: pg_restore silently fails when restoring a db with the --create flag and no user. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #7507: pg_restore silently fails when restoring a db with the --create flag and no user.
Date
Msg-id 7536.1346095868@sss.pgh.pa.us
Whole thread Raw
In response to BUG #7507: pg_restore silently fails when restoring a db with the --create flag and no user.  (iann@fuelforce.com)
List pgsql-bugs
iann@fuelforce.com writes:
> Attempting to restore a db using pg_restore to a new database server using
> the --create and --dbname flags fails silently if the db owner username does
> not exist in the new db or the -O flag is not used.
> Command used:
> pg_restore --create --verbose --dbname=testserver
> /Volumes/USBLINKS1/hostname.testserver.net_postgres_database

It'll fail, yes, because pg_dump by itself doesn't dump CREATE USER
commands (since users are external to any individual database).
However, it hardly seems "silent" to me.  I see complaints like these:

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1851; 1262 116736 DATABASE mydb dbowner
pg_restore: [archiver (db)] could not execute query: ERROR:  role "dbowner" does not exist
    Command was: ALTER DATABASE mydb OWNER TO dbowner;

pg_restore: [archiver (db)] Error from TOC entry 161; 1259 116737 TABLE mytable dbowner
pg_restore: [archiver (db)] could not execute query: ERROR:  role "dbowner" does not exist
    Command was: ALTER TABLE public.mytable OWNER TO dbowner;

WARNING: errors ignored on restore: 2

Possibly you want to use the --exit-on-error option?

            regards, tom lane

pgsql-bugs by date:

Previous
From: iann@fuelforce.com
Date:
Subject: BUG #7507: pg_restore silently fails when restoring a db with the --create flag and no user.
Next
From: Robert Haas
Date:
Subject: Re: Minor inheritance/check bug: Inconsistent behavior