Constraint name for named NOT NULL constraints is ignored

Поиск
Список
Период
Сортировка
От Csaba Nagy
Тема Constraint name for named NOT NULL constraints is ignored
Дата
Msg-id 1202212210.29220.21.camel@PCD12478
обсуждение исходный текст
Ответы Re: Constraint name for named NOT NULL constraints is ignored
Список pgsql-general
While upgrading our schema between application versions, we also had a
few constraint changes. Some of those changes were dropping NOT NULL
constraints on some columns. Our schema had a few such NOT NULL
constraints, which were created using the named variant of the column
constraint clause (something like '... col_name col_type CONSTRAINT
nn_col_name NOT NULL ...'). This syntax is happily accepted by postgres.
So our schema change script was expecting that simply dropping those
named constraints will drop the NOT NULL constraint on the relevant
columns, but the constraint is just simply not there at all, so trying
to drop it gives an error.

From the description of the pg_constraint table
http://www.postgresql.org/docs/8.2/static/catalog-pg-constraint.html
is clear that it does not hold NOT NULL constraints, which go to the
pg_attribute table, but then maybe an error should be raised if somebody
tries to create a named NOT NULL constraint ? Ignoring integral parts of
the SQL syntax feels somewhat mySQL-ish. Or at least mention this
behavior on the CREATE TABLE page (I couldn't find it if it's there):
http://www.postgresql.org/docs/8.2/static/sql-createtable.html

Cheers,
Csaba.



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

Предыдущее
От: Csaba Nagy
Дата:
Сообщение: Renaming a constraint
Следующее
От: peter pilsl
Дата:
Сообщение: 8.3.-build fails due parse error in VERSION script