Re: [GENERAL] PG 9.1 - FK + Check constraint - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] PG 9.1 - FK + Check constraint
Date
Msg-id CAKFQuwanmBOH27hc3KKo7LUDWXwjSumYX2+5EFAOZdnVofa_Qg@mail.gmail.com
Whole thread Raw
In response to [GENERAL] PG 9.1 - FK + Check constraint  (Patrick B <patrickbakerbr@gmail.com>)
List pgsql-general
On Tue, Jul 18, 2017 at 6:56 PM, Patrick B <patrickbakerbr@gmail.com> wrote:

Another solution would be to create an IMMUTABLE functiondoing the check and use that in a CHECK constraint [1].

Why do you need an FK constraint?  Why can you not use a data modification trigger?

Placing the subquery within a mis-defined immutable function so PostgreSQL is oblivious to it doesn't do anything to overcome the fact that the system is not designed to have check constraints with subqueries.  You are likely to get burned - commonly during backup restoration but there is no guarantees as to why might happen.

David J.



pgsql-general by date:

Previous
From: Patrick B
Date:
Subject: [GENERAL] PG 9.1 - FK + Check constraint
Next
From: armand pirvu
Date:
Subject: [GENERAL] hash join performance question