Re: patch: ALTER TABLE IF EXISTS

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: ALTER TABLE IF EXISTS
Date: 2012-01-03 19:49:12
Message-ID: CAFj8pRDNZQkn_MzJ7uuU5BWkFNk3GCdD9Uv1=QhxQWUk6eZcYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

2012/1/3 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Tue, Jan 3, 2012 at 10:38 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>> Hello
>>
>> 2012/1/3 Robert Haas <robertmhaas(at)gmail(dot)com>:
>>> On Mon, Jan 2, 2012 at 12:01 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>>>> here is updated patch
>>>
>>> I think the comments in parse_utilcmd.c probably need a bit of adjustment.
>>
>> I don't see it - there is only one comment and it is adjusted with
>> "if" statement.
>>
>> please, show it
>
> Well, basically, the comment preceding the part you altered say "the
> lock level requested here", but "here" is getting spread out quite a
> bit more with this code change.  Maybe that doesn't matter.
>
> However, on further examination, this is a pretty awkward way to write
> the code.  Why not something like this:
>
> rel = relation_openrv_extended(stmt->relation, lockmode, stmt->missing_ok);
> if (rel == NULL)
> {
>    ereport(...);
>    return NIL;
> }
>
> Maybe the intent of sticking heap_openrv_extended() into the upper
> branch of the if statement is to try to bounce relations that aren't
> tables, but that's not actually what that function does (e.g. a
> foreign table will slip through).  And I think if we're going to have
> IF EXISTS support for ALTER TABLE at all, we ought to have it for the
> whole family of related statements: ALTER VIEW, ALTER SEQUENCE, ALTER
> FOREIGN TABLE, etc., not just ALTER TABLE itself.
>

jup, we can continue in enhancing step by step.

I change a patch and now ALTER TABLE, ALTER INDEX, ALTER SEQUENCE and
ALTER VIEW has IF EXISTS clause

Regards

Pavel

> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company

Attachment Content-Type Size
alter_table_if_exists_02.patch text/x-patch 38.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Harris 2012-01-03 20:05:33 Re: spinlocks on powerpc
Previous Message Tom Lane 2012-01-03 19:22:28 Re: ALTER TABLE lock strength reduction patch is unsafe