Re: Potential bug in ALTER TABLE?

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: Potential bug in ALTER TABLE?
Дата
Msg-id 3F574B25.9090704@dunslane.net
обсуждение исходный текст
Ответ на Potential bug in ALTER TABLE?  (Jeroen Ruigrok/asmodai <asmodai@wxs.nl>)
Список pgsql-hackers
Jeroen Ruigrok/asmodai wrote:

>Hi,
>
>just want to verify first with you guys before dumping it on the bugs
>list.  Most likely I am just being silly here or something.
>
>Take this:
>
>create table blah (name TEXT CHECK (name IN ('blah', 'bleh')));
>test=# \d blah
>    Table "public.blah"
> Column | Type | Modifiers 
>--------+------+-----------
> name   | text | 
>Check constraints: "blah_name" ((name = 'blah'::text) OR (name = 'bleh'::text))
>
>As we would expect PostgreSQL to do.  The constraint has an
>automatically assigned name.
>
>Now, to continue:
>
>ALTER TABLE blah DROP CONSTRAINT blah_name;
>ALTER TABLE blah ADD CHECK (name IN ('blah', 'bleh'));
>test=# \d blah
>    Table "public.blah"
> Column | Type | Modifiers 
>--------+------+-----------
> name   | text | 
>Check constraints: "$1" ((name = 'blah'::text) OR (name = 'bleh'::text))
>
>And this time around PostgreSQL doesn't assign an automatic name.
>Well, it depends on what you call a name, but $1, $2, and so on isn't
>quite descriptive.  Is this an oversight or am I missing some subtle
>thing here?
>
>  
>
You can name it yourself:
 ALTER TABLE blah ADD CONSTRAINT blurfl CHECK (name IN ('blah', 'bleh'));

I do this a lot.

I agree the autogenerated names are less than pretty.

cheers

andrew




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Potential bug in ALTER TABLE?
Следующее
От: "Paulo Scardine"
Дата:
Сообщение: Seqscan in MAX(index_column)