Re: alter enum add value if not exists - Mailing list pgsql-hackers

From Tom Lane
Subject Re: alter enum add value if not exists
Date
Msg-id 17187.1348180445@sss.pgh.pa.us
Whole thread Raw
In response to Re: alter enum add value if not exists  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: alter enum add value if not exists  (Andrew Dunstan <andrew@dunslane.net>)
Re: alter enum add value if not exists  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> On 08/23/2012 07:39 AM, Magnus Hagander wrote:
>> It doesn't break, of course ,since it's protected by the unique index.
>> But aren't you at risk of getting the very error message you're trying
>> to avoid?

> Yeah, looking further this was probably a thinko on my part. Thanks for 
> noticing. I've moved the test down so it's done right after the lock is 
> acquired. Revised patch attached.

This patch looks sane as far as it goes.  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.

However, it would be reasonable to do that mop-up as a separate
commit.  If you prefer, commit what you've got and then I'll see
about the other thing.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Assigning NULL to a record variable
Next
From: Nozomi Anzai
Date:
Subject: Re: 64-bit API for large object