Re: [GENERAL] CHECK for 2 FKs to be non equal

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: [GENERAL] CHECK for 2 FKs to be non equal
Дата
Msg-id CA+bJJby+Rk-L1SD1Jy-fYkzK7_PtVqy6PUP-0C8WcSy261rN+w@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] CHECK for 2 FKs to be non equal  (Alexander Farber <alexander.farber@gmail.com>)
Список pgsql-general
Alexander:

On Sat, Mar 11, 2017 at 10:41 AM, Alexander Farber
<alexander.farber@gmail.com> wrote:
>          uid integer NOT NULL REFERENCES words_users(uid) CHECK (uid <>
> author) ON DELETE CASCADE,

Maybe a stupid question, but have you tried "refereces.. on delete .. check"?

I mean, the manual for create table says:

>>>

 column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]

...And a little down


where column_constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL |
  NULL |
  CHECK ( expression ) [ NO INHERIT ] |
  DEFAULT default_expr |
  UNIQUE index_parameters |
  PRIMARY KEY index_parameters |
  REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL |
MATCH SIMPLE ]
    [ ON DELETE action ] [ ON UPDATE action ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
<<<<

So ON DELETE is an optional part of a reference constraint, not a
constraint per se, and it is being parsed as "references..." ( correct
constraint) + "check..." (correct constraint) + "On delete.." (WTF is
this ), on delete after references should be parsed as a single big
constraint.

> What am I doing wrong please?

Not RTFM ? ( if I'm right, or not understanding it )

Francisco Olarte.


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

Предыдущее
От: Alexander Farber
Дата:
Сообщение: [GENERAL] CHECK for 2 FKs to be non equal
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: [GENERAL] CHECK for 2 FKs to be non equal