Re: Potential bug in ALTER TABLE?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Potential bug in ALTER TABLE?
Дата
Msg-id 23541.1062685145@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Potential bug in ALTER TABLE?  (Jeroen Ruigrok/asmodai <asmodai@wxs.nl>)
Список pgsql-hackers
Jeroen Ruigrok/asmodai <asmodai@wxs.nl> writes:
> 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.

The ALTER ADD CONSTRAINT form creates a table constraint, ie, one that's
not attached to any particular column.  If you write the constraint in
the CREATE TABLE as a table constraint, then you get the same result as
with ALTER ADD CONSTRAINT.

regression=# create table blah (name TEXT, CHECK (name IN ('blah', 'bleh')));
CREATE TABLE
regression=# \d blah   Table "public.blah"Column | Type | Modifiers
--------+------+-----------name   | text |
Check constraints:   "$1" CHECK ((name = 'blah'::text) OR (name = 'bleh'::text))


If you don't like the automatically generated name, assign your own...

regression=# ALTER TABLE blah ADD CONSTRAINT fooey CHECK (name IN ('blah', 'bleh'));
ALTER TABLE
regression=# \d blah   Table "public.blah"Column | Type | Modifiers
--------+------+-----------name   | text |
Check constraints:   "$1" CHECK ((name = 'blah'::text) OR (name = 'bleh'::text))   "fooey" CHECK ((name = 'blah'::text)
OR(name = 'bleh'::text))
 

        regards, tom lane


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

Предыдущее
От: Jeroen Ruigrok/asmodai
Дата:
Сообщение: Potential bug in ALTER TABLE?
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Potential bug in ALTER TABLE?