Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Tomas Vondra <tv(at)fuzzy(dot)cz>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Date: 2013-11-10 21:28:27
Message-ID: 3210.1384118907@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

[ catching up on old email ]

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2013-10-15 00:23:15 +0200, Tomas Vondra wrote:
>> On 2013-10-10 12:54:23 -0400, Andrew Dunstan wrote:
>>> This thread seems to have gone cold, but I'm inclined to agree with
>>> Pavel. If the table doesn't exist, neither does the trigger, and
>>> the whole point of the 'IF EXISTS' variants is to provide the
>>> ability to issue DROP commands that don't fail if their target is
>>> missing.

>> -1, this seems to likely to just hide typos.

> Because there simply is no reason to issue a DROP TRIGGER IF EXISTS if
> you don't need the contents of the table. In that case you can just
> issue a DROP TABLE IF EXISTS and start anew.

I think this is nonsense. It's only one step removed from "why do you
need IF EXISTS at all, you should know whether the object is there".
The entire point of this syntax is to not need to do detailed analysis
about whether the object is there.

The pg_dump --clean use-case is sufficient refutation for that, IMO.
You're suggesting that pg_dump should make a special case out of what it
emits for "cleaning" a trigger; which we could do I guess, but it would be
ugly and fragile. For instance, the special case would probably soon grow
some warts for partial-dump scenarios. Anyway, pg_dump is not the only tool
that might wish to use DROP IF EXISTS.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-11-10 21:54:50 Re: BUG #8531: systemtap probe mark(checkpoint__done) error when i read the parameters
Previous Message rathodsa 2013-11-09 19:30:48 BUG #8585: 32 bit ODBC driver is not working with Excel 2010 w/PowerPivot

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-11-10 21:39:21 Re: [COMMITTERS] pgsql: Replace duplicate_oids with Perl implementation
Previous Message Peter Geoghegan 2013-11-10 21:16:24 Re: [COMMITTERS] pgsql: Replace duplicate_oids with Perl implementation