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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>, PostgreSQL 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-11-24 19:28:14
Message-ID: CAFj8pRBg8i6HP6Uv_sPOihzS7Xy6DdgfFOnbLThys46v3gtgFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

2013/11/21 Peter Eisentraut <peter_e(at)gmx(dot)net>

> On 11/21/13, 2:35 AM, Pavel Stehule wrote:
> > I am feeling, so almost all people prefer
> >
> > DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ];
> >
> > Can we live with it?
>
> Fine with me.
>
> I think it helps if you consider IF EXISTS an attribute of the command,
> not an attribute of the command parameters.
>
> Now we should be aware that this sort of sets a precedent for ALTER
> TABLE IF EXISTS ... DROP ANYTHING ... and similar composite commands.
>
> If might be worth checking other SQL databases. We stole the IF EXISTS
> from somewhere, I believe.
>
>
I did some searching:

So DROP TRIGGER IF EXISTS is supported by

SQL anywhere, MySQL

Doesn't support:

MS SQL server (conditional drops is by T-SQL IF EXISTS() statement),
Oracle, DB2,

But significant difference between PostgreSQL and other databases is
requirement to specify table in DROP statement. So in SQL anywhere or in
MySQL DROP TRIGGER IF EXISTS is fully fault tolerant, there are not
possibility to specify table.

Note: DROP TRIGGER ON tablename is PostgreSQL feature - no other databases
(without PostgreSQL forks) uses this syntax - so we don't need thinking
what is in (or what will be) in ANSI standard (or what other databases
does). In this moment syntax of DROP TRIGGER is non standard. So if we can
adopt design (idea) in SQL anywhere or MySQL, then DROP TRIGGER IF EXISTS
should be enough. In our implementation there are two conditions, but we
should not to check if target table exists (from statement purpose).

So now, +1 for using "DROP TRIGGER IF EXISTS name ON tablename" without
requirement for tablename

Regards

Pavel

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephen Frost 2013-11-25 02:53:29 Re: BUG #8611: ECPG: unclosed comment "/*"
Previous Message rob 2013-11-24 16:49:05 BUG #8628: md5 security hole

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Ramsey 2013-11-24 21:02:51 Re: Traffic jams in fn_extra
Previous Message Jeff Davis 2013-11-24 19:04:26 session_preload_libraries not in sample config?