Re: [GENERAL] CHECK for 2 FKs to be non equal - Mailing list pgsql-general

From Francisco Olarte
Subject Re: [GENERAL] CHECK for 2 FKs to be non equal
Date
Msg-id CA+bJJby+Rk-L1SD1Jy-fYkzK7_PtVqy6PUP-0C8WcSy261rN+w@mail.gmail.com
Whole thread Raw
In response to [GENERAL] CHECK for 2 FKs to be non equal  (Alexander Farber <alexander.farber@gmail.com>)
List 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 by date:

Previous
From: Alexander Farber
Date:
Subject: [GENERAL] CHECK for 2 FKs to be non equal
Next
From: Alban Hertroys
Date:
Subject: Re: [GENERAL] CHECK for 2 FKs to be non equal