On Mon, Dec 7, 2015 at 4:06 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
>
>
> On Tue, Dec 8, 2015 at 1:35 AM, <pgdude@pgdude.com> wrote:
>>
>> pg_restore returns 1 return code indicating failure when it tries to
>> create
>> the public schema using PG 9.4.5
>>
>> Here is my command:
>> pg_restore -h host2 -p 5432 -d postgres -C -c --if-exists -Fd -j 6 -v
>> /path
>> to my dumps/mydump
>>
>> Same error using format: -Fc
>
>
> 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.
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