Re: Bug of ALTER TABLE DROP CONSTRAINT
От | Nikhil Sontakke |
---|---|
Тема | Re: Bug of ALTER TABLE DROP CONSTRAINT |
Дата | |
Msg-id | a301bfd90904020524q25197c22o2e69a87cb0f1180@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Bug of ALTER TABLE DROP CONSTRAINT (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: Bug of ALTER TABLE DROP CONSTRAINT
|
Список | pgsql-hackers |
Hi,
Yeah it will be a matter of finding the affected column entries and invoking the removal of the not null entry from their corresponding pg_attribute rows.
Yeah and it is documented already. Although it is not obvious immediately that a not-null attribute gets tagged onto the involved columns separately for primary, unique-not-null types of constraints.
Regards,
Nikhils
--
http://www.enterprisedb.com
> Considering the following sequence:Making a column into the primary key forces the column to NOT NULL.
> create table t(a int primary key);
> alter table t drop constraint t_pkey;
> insert into t values(null);
> ERROR: null value in column "a" violates not-null constraint
>
> My question is, why "null" is not allowed to be inserted after primary key
> constraint has been dropped.
You'll need to DROP NOT NULL separately.
It's probably possible to beat on the code hard enough to fix this,
Yeah it will be a matter of finding the affected column entries and invoking the removal of the not null entry from their corresponding pg_attribute rows.
but I'm not really sure there's much point, since the situation is
rare and the workaround is easy.
Yeah and it is documented already. Although it is not obvious immediately that a not-null attribute gets tagged onto the involved columns separately for primary, unique-not-null types of constraints.
Nikhils
--
http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: