Re: BUG #13804: pg_restore returns unexpected error

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: pgdude(at)pgdude(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13804: pg_restore returns unexpected error
Date: 2015-12-08 00:33:47
Message-ID: CAMkU=1xE4ojB693J4PCxhQvB4Aua7vbT7M3M6OhLPTc5QZjiMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Dec 7, 2015 at 4:06 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
>
>
> On Tue, Dec 8, 2015 at 1:35 AM, <pgdude(at)pgdude(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message amutu 2015-12-08 03:54:44 BUG #13805: plpgsql execute using expression evaluate wrong
Previous Message Michael Paquier 2015-12-08 00:06:12 Re: BUG #13804: pg_restore returns unexpected error