Two constraints with the same name not always allowed
От | André Hänsel |
---|---|
Тема | Two constraints with the same name not always allowed |
Дата | |
Msg-id | 0c1001d4428f$0942b430$1bc81c90$@webkr.de обсуждение исходный текст |
Ответы |
Re: Two constraints with the same name not always allowed
|
Список | pgsql-bugs |
Hi list, calling this a bug might be pedantic, but I noticed this inconsistency: Case 1: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT foo UNIQUE(c); ALTER TABLE t ADD CONSTRAINT foo CHECK(c > 1); -> ERROR: constraint "foo" for relation "t" already exists Case 2: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT foo CHECK(c > 1); ALTER TABLE t ADD CONSTRAINT foo UNIQUE(c); -> Creates two constraints, both called "foo". Case 3: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT t_c_check UNIQUE(c); -- add the UNIQUE with the same name that the following CHECK will automatically choose ALTER TABLE t ADD CHECK(c > 1); -> Creates the UNIQUE constraint as "t_c_check" and the CHECK as "t_c_check1" Case 4: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT t_c_key CHECK(c > 1); ALTER TABLE t ADD UNIQUE(c); -> Creates two constraints, both called "t_c_key". In cases where two constraints with the same name are created, an "ALTER TABLE t DROP CONSTRAINT ..." drops the UNIQUE first. Issuing the ALTER TABLE a second time then drops the CHECK. Regards, André
В списке pgsql-bugs по дате отправления: