Re: drop table if exists <VIEW_NAME>;

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: drop table if exists <VIEW_NAME>;
Date: 2012-09-19 12:39:16
Message-ID: 5059BCF4.9000908@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/19/2012 07:54 PM, Marc Mamin wrote:
> hello,
>
> I've found a small logical issue while writing a migration script:
>
> create table vtest (foo int);
>
> create view vtest_v as select * from vtest;
>
> drop table if exists vtest_v;
>
> ERROR: "vtest_v" is not a table
>
> drop view if exists vtest;
>
> ERROR: "vtest" is not a view
>
> this may be seen as a nice hint, but in my own opinion
>
> DROP ... IF EXISTS should not throw an error for objects that do not exist.

... but they do exist. There is another object with that name. It isn't
clear if the script author's intention is to DROP the object despite the
type mismatch, or to ignore it because it's not the type of object they
specified to drop.

When something is ambiguous or unclear, PostgreSQL will tend to report
an error for safety.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2012-09-19 13:03:22 Re: RFE: Column aliases in WHERE clauses
Previous Message Craig Ringer 2012-09-19 12:36:18 Re: RFE: Column aliases in WHERE clauses