From: Tom Lane <tgl@sss.pgh.pa.us>
To: lalbin@scharp.org
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15316: pg_restore failes to load data that is constrainted by a functional check constraints
Date: Tue, 07 Aug 2018 22:53:49 -0400
Message-ID: <13061.1533696829@sss.pgh.pa.us> (raw)
In-Reply-To: <153368669319.1297.12136690880705121335@wrigleys.postgresql.org>
References: <153368669319.1297.12136690880705121335@wrigleys.postgresql.org>
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> I have found an edge case where pg_dump and pg_restore fails to restore
> databases with check constraints that points to data in another table that
> is restored after the table containing the check constraint.
This is an unsupported case.[1] In general, table CHECK constraints are
only allowed to concern themselves with the data in the particular row
that they're checking. While we can't actually stop you from cheating by
hiding the subquery in a function, we're not going to consider it a bug
that such a setup doesn't work reliably.
I'd suggest rethinking your data representation so that you can make the
tables' relationship into a regular foreign key constraint. Those, the
system understands well enough to maintain in a dump/reload context.
regards, tom lane
[1] Specifically, we disclaim support for SQL feature F671, "Subqueries
in CHECK constraints".
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, lalbin@scharp.org
Subject: Re: BUG #15316: pg_restore failes to load data that is constrainted by a functional check constraints
In-Reply-To: <13061.1533696829@sss.pgh.pa.us>
References: <153368669319.1297.12136690880705121335@wrigleys.postgresql.org> <13061.1533696829@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox