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

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Satoshi Nagayasu <snaga(at)uptime(dot)jp>, Josh Kupershmidt <schmiddy(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Dave Rolsky <autarch(at)urth(dot)org>, pgsql-hackers <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-10-14 22:00:51
Message-ID: 20131014220051.GF25013@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2013-10-14 17:59:25 -0400, Andrew Dunstan wrote:
>
> On 10/14/2013 05:44 PM, Andres Freund wrote:
> >On 2013-10-10 12:54:23 -0400, Andrew Dunstan wrote:
> >>On 09/19/2013 06:12 PM, Pavel Stehule wrote:
> >>>
> >>>2013/9/16 Satoshi Nagayasu <snaga(at)uptime(dot)jp <mailto:snaga(at)uptime(dot)jp>>
> >>>
> >>>
> >>
> >>> I'm looking at this patch, and I have a question here.
> >>>
> >>> Should "DROP TRIGGER IF EXISTS" ignore error for non-existing trigger
> >>> and non-existing table? Or just only for non-existing trigger?
> >>>
> >>>
> >>>My opinion is so, both variants should be ignored - it should be fully
> >>>fault tolerant in this use case.
> >>>
> >>>
> >>
> >>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.
> >
>
>
> So if I say
>
> DROP TRIGGER IF EXISTS foo ON bar;
>
> you're ok with succeeding if foo is a typo, but not if bar is?

Yes.

Normally you won't do DROP TRIGGER if you don't need the table in the
first place, in that case you can just DROP TABLE.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2013-10-14 22:23:15 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Previous Message Andrew Dunstan 2013-10-14 21:59:25 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2013-10-14 22:04:10 Re: Improving avg performance for numeric
Previous Message Andrew Dunstan 2013-10-14 21:59:25 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist