Re: BUG #13804: pg_restore returns unexpected error

From: "michael(at)sqlexec(dot)com" <michael(at)sqlexec(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, 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-11 21:52:56
Message-ID: 566B45B8.4080702@sqlexec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)janes(at)gmail(dot)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(dot)paquier(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2015-12-11 21:54:45 Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type
Previous Message Alvaro Herrera 2015-12-11 21:49:10 Re: BUG #13809: Reassign owned throws error