Re: Re: [BUGS] BUG #7515: DROP TABLE IF EXISTS fails if schema does not exist

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: james(at)illusorystudios(dot)com, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [BUGS] BUG #7515: DROP TABLE IF EXISTS fails if schema does not exist
Date: 2013-01-25 13:11:43
Message-ID: CAFj8pRBfdFhgp2z=TJUV4_+17b5btbpmiU_FZp3iRkVZzRiy7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

2013/1/25 Bruce Momjian <bruce(at)momjian(dot)us>:
> On Sun, Sep 2, 2012 at 05:40:54PM +0000, james(at)illusorystudios(dot)com wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference: 7515
>> Logged by: James Bellinger
>> Email address: james(at)illusorystudios(dot)com
>> PostgreSQL version: 9.1.5
>> Operating system: Ubuntu Linux 12.04 Server
>> Description:
>>
>> If the table being referenced has a schema in its name, and the schema does
>> not exist, DROP TABLE IF EXISTS will have an ERROR instead of a NOTICE.
>>
>> So for instance,
>> DROP TABLE IF EXISTS bar;
>> This is a NOTICE if bar does not exist.
>>
>> DROP TABLE IF EXISTS foo.bar;
>> This is an ERROR if foo does not exist, even though that implies bar does
>> not exist which means it should be a NOTICE.
>>
>> Saw this because it was making a drop/recreate transaction fail on me, after
>> I changed some code to use a schema.
>
> I looked at this bug report from September. The problem is that
> LookupExplicitNamespace() doesn't have a missing_ok parameter, even
> though get_namespace_oid(), which it calls, does. By adding a
> missing_ok parameter and passing it cleanly, I fixed the problem:
>
> test=> DROP TABLE IF EXISTS foo.bar;
> NOTICE: table "bar" does not exist, skipping
> DROP TABLE
>
> Patch attached.
>

+1

Pavel

> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2013-01-25 13:20:25 Re: cache lookup failed from empty plpythonu function
Previous Message Magnus Hagander 2013-01-25 08:49:42 Re: BUG #7809: Running pg_dump on slave w/ streaming replication fails if there are unlogged tables

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-01-25 13:22:40 Re: [BUGS] BUG #7515: DROP TABLE IF EXISTS fails if schema does not exist
Previous Message Pavel Stehule 2013-01-25 13:10:07 Re: proposal: fix corner use case of variadic fuctions usage