Re: alter enum add value if not exists

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alter enum add value if not exists
Date: 2012-09-22 23:20:22
Message-ID: 505E47B6.7020106@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 09/22/2012 07:05 PM, Tom Lane wrote:
> I wrote:
>> ... It strikes me though that if
>> we're going to invent an opt_if_not_exists production in the grammar,
>> there are a lot of other places where it should be used too, for
>> consistency if nothing else.
> BTW, I tried to do this and realized that it doesn't work, because IF
> is not a reserved word. The only way that opt_if_not_exists isn't
> ambiguous is if it must appear before something that's not an
> identifier, which is to say it works in ALTER TYPE ADD VALUE ... Sconst
> and nowhere else. Otherwise you have to spell it out with duplicate
> productions so that bison doesn't have to make a shift/reduce decision
> till it's seen the whole phrase.
>
> If we're ever forced to make IF reserved for other reasons, we could
> clean up a lot of both IF EXISTS and IF NOT EXISTS productions.
>
> There are other ways we could refactor the productions involved to
> reduce duplication; for instance I think that we could make it work for
> CREATE TABLE IF NOT EXISTS by defining a nonterminal that expands to
> either "qualified_name" or "IF NOT EXISTS qualified_name". But that
> seems ugly enough to not be much of an improvement, not least because
> the nonterminal would need to return two separate pieces of info,
> and that's not terribly easy in bison.
>
>

:-(

I remember running into this when I did the DINE stuff. I was actually
pleasantly surprised that it worked with the enum command.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2012-09-22 23:45:24 Re: pg_reorg in core?
Previous Message Tom Lane 2012-09-22 23:05:59 Re: alter enum add value if not exists