Re: BUG #13804: pg_restore returns unexpected error - Mailing list pgsql-bugs

From michael@sqlexec.com
Subject Re: BUG #13804: pg_restore returns unexpected error
Date
Msg-id 566B45B8.4080702@sqlexec.com
Whole thread Raw
In response to Re: BUG #13804: pg_restore returns unexpected error  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-bugs
Example Test Case:

psql
create database aaa;
\c aaa
create table t1(akey int);
insert into t1 VALUES(1);
\q

-- example generates exit code 1 for pg_restore when creating public schema
pg_dump    -d aaa      -p 6432 -C -c --if-exists -Fc -v -w -f  ./db.dump
pg_restore -d postgres -p 6432 -C -c --if-exists -Fc -v        ./db.dump

-- generate listing
pg_restore -C -c --if-exists -Fc -v -l db.dump > db.list

-- generate output commands (no db provided)
pg_restore -C -c --if-exists -Fc -v -L db.list db.dump

-- execute using the list: generates same exit code 1 when attempting to
create public schema
pg_restore -C -c --if-exists -Fc -v -L db.list db.dump -d postgres

> Jeff Janes <mailto:jeff.janes@gmail.com>
> Monday, December 7, 2015 7:33 PM
> On Mon, Dec 7, 2015 at 4:06 PM, Michael Paquier
>
>
> createdb foobar
> pgbench -i foobar
> pg_dump foobar -Fc > dump.dmp
> dropdb foobar
> pg_restore -C -c --if-exists -d postgres dump.dmp
>
> The above yields this message:
> ========
>
> ERROR: schema "public" already exists
> STATEMENT: CREATE SCHEMA public;
>
>
>
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 5; 2615 2200 SCHEMA
> public jjanes
> pg_restore: [archiver (db)] could not execute query: ERROR: schema
> "public" already exists
> Command was: CREATE SCHEMA public;
>
>
> =======
>
> Since both -C and -c are specified, it should know that it is starting
> out with a freshly created database which has a public schema by
> default. So either it should not attempt to create the public schema
> a second time, or it should silently discard the (expected) error
> message, or conditionally drop the schema before recreating it.
>
> The error message does not indicate an actual problem, and can be
> ignored. But since the point of -c and --if-exists seems to be to
> suppress just that kind of ignorable error message, it does seem like
> a bug that it fails to do so.
>
> Cheers,
>
> Jeff
> Michael Paquier <mailto:michael.paquier@gmail.com>
> Monday, December 7, 2015 7:06 PM
>
>
>
> If you think this is a bug, could you send a test case? There is not
> enough information regarding what you expect of pg_restore and what it
> is currently doing.
> --
> Michael

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #13809: Reassign owned throws error
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type