Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a7VdI-0007c0-GL for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Dec 2015 21:53:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a7VdI-0006NB-2y for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Dec 2015 21:53:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a7Vcf-0005Kd-CZ for pgsql-bugs@postgresql.org; Fri, 11 Dec 2015 21:53:05 +0000 Received: from mout.perfora.net ([74.208.4.196]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84) (envelope-from ) id 1a7Vcc-0000Cz-0W for pgsql-bugs@postgresql.org; Fri, 11 Dec 2015 21:53:04 +0000 Received: from [192.168.1.122] ([68.98.130.52]) by mrelay.perfora.net (mreueus001) with ESMTPSA (Nemesis) id 0LmdF7-1ag1IB0gK3-00a39o; Fri, 11 Dec 2015 22:52:56 +0100 Message-ID: <566B45B8.4080702@sqlexec.com> Date: Fri, 11 Dec 2015 16:52:56 -0500 From: "michael@sqlexec.com" User-Agent: Postbox 4.0.8 (Windows/20151105) MIME-Version: 1.0 To: Jeff Janes CC: Michael Paquier , pgdude@pgdude.com, PostgreSQL mailing lists Subject: Re: BUG #13804: pg_restore returns unexpected error References: <20151207163520.2628.95990@wrigleys.postgresql.org> In-Reply-To: Content-Type: multipart/alternative; boundary="------------070402060703000105010009" X-Provags-ID: V03:K0:bRcvcJOblb6K+WDKkrDJgKfvPFOb8embEjgWhzMT60dPRM0VS7A +zXMMAd1O1IszrTVH8qZMBUQSjTN8Ey2eP9Lhu5xPxYRcfmfACBRo3jhoan85To5t+jsP8O O4FI1f7iUHVB37qk/uFLQw32ak94BKP2pRawNXQJ4WEU32jwH0rqC70btV3XxrV+8sn0T0z J4uQItakMbaDg/XQ7UTNA== X-UI-Out-Filterresults: notjunk:1;V01:K0:DBwav2gWN7Y=:FNc8IC2fnkEKwJaj6jIF/7 hVrU1y3onv6DsurDqokqL8KwH18kkTfx2zDXf5wKRaDtLFtu6t/EgGoCx9EPia7gXK90Kw9yq aqisnJtumyq6qzNL5thFU/Oi9Tlfk4xk7hQ5Wrr8INKN35pwrw2FQiiqIs6LmCW9lOYycl8qE Oc2KOTPqhr+GpBfjZ/BKFrnQ5V9G0hEnEOVZmg3d/TmPGbinWmuQDuVGMMLj9PizeoQCCUuvB LSJbaRz0euF+lcerjKHf1awlLWnuHQf+Hc5CynKhBpnPjcCyj52NxE6rsAG44FLdch5nzw2BZ D+NKYI271EljZlkXZQXV7t+pJhoK3WwWYtu/3H3hs+Tzutac5GXvytBuE2CWCgpRWnT9Yge/v djuG/gPVlXg9pl9RaD/x6DZ+aZS0TN8tPyVcZpv1tldYsAS5yn2fLsO2Ge5KX2Xi+RhQ9Wlmi 3+5UImo2ax8nhWZi0xcPkfJYjBl2NRX1Umi2xcjnrn2WJ1oUYUTzvA2X0qRrWzzkkAfG9dS7/ 3UEWdPt8jWEAwo7lE8qydY7pSrdO3iVcul1o8ej1wugbvUyu/0BL4b+5Tm1cqfE1DbjYnuNf3 w4d9/wjo+NUuOXkL+if9qslgu8DLf2+9WrFgT1Uk945wmJjZRHWTMJtsRy/GBr5Q84U8LcLJN Re0R4WhlwZS1yMaJj+zV7WdyfjFFRsFKmH8z3n7eWCxFXlFVon7y/ZTeEJ7DBlImuAru9Bf3o N55BErn4QHPv8ek1 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------070402060703000105010009 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > 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 > 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 --------------070402060703000105010009 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
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

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
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

--------------070402060703000105010009--