Re: pg_dump restore error

Lists: pgsql-hackers
From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_dump restore error
Date: 2012-10-14 14:47:40
Message-ID: 507AD08C.5020603@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

Restoring a backup generated with pg_dump/pg_dumpall in plain text
format and the --clean option will report errors if the backup is loaded
in an other or empty database. I mean that the backup file contains all
SQL order to drop the database's objects before recreating them, so if
you load this backup into a new database it will throw errors on each
DROP call complaining that the objects doesn't exists.

This is not very important because everything goes fine but these error
reports can be easily prevented with the addition of IF EXISTS clauses
and this will probably be less confusing. I've attached a patch adding
those IF EXISTS on each DROP and ALTER statements.

Best regards,

--
Gilles Darold
http://dalibo.com - http://dalibo.org

Attachment Content-Type Size
pg_dump-drop_if_exists-patch.diff text/x-patch 13.0 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_dump restore error
Date: 2012-10-14 16:50:44
Message-ID: 26917.1350233444@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gilles Darold <gilles(dot)darold(at)dalibo(dot)com> writes:
> Restoring a backup generated with pg_dump/pg_dumpall in plain text
> format and the --clean option will report errors if the backup is loaded
> in an other or empty database.

This is intentional. What you propose amounts to a fundamental change
in the semantics of --clean, and I don't think that it's really much
of an improvement.

regards, tom lane


From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_dump restore error
Date: 2012-10-14 22:17:46
Message-ID: 507B3A0A.6060201@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Le 14/10/2012 18:50, Tom Lane a écrit :
> Gilles Darold <gilles(dot)darold(at)dalibo(dot)com> writes:
>> Restoring a backup generated with pg_dump/pg_dumpall in plain text
>> format and the --clean option will report errors if the backup is loaded
>> in an other or empty database.
> This is intentional. What you propose amounts to a fundamental change
> in the semantics of --clean, and I don't think that it's really much
> of an improvement.

I'm agree that this is not an improvement, I used to work with it
because I know it's harmless error messages. The request comes from a
client that claims that replaying his backup on a new server was always
producing those errors.

I was just thinking that cleaning if exists was also harmless, but it is
probably better to have error reported in most of the cases.

Regards,

--
Gilles Darold
Administrateur de bases de données
http://dalibo.com - http://dalibo.org