Re: COPY documentation with regard to references constraints

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: COPY documentation with regard to references constraints
Date: 2024-10-31 12:15:34
Message-ID: CAFCRh-9dwBkb73x+ckFCn-SDy=n8Fpg3XcGfFAT+MWOm+jp-Tw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 31, 2024 at 1:04 PM Bruno Wolff III <bruno(at)wolff(dot)to> wrote:
> I was unable to find any documentation clarifying if using COPY to load a
> table with rows referencing others rows in the same table, whether I
> had to worry about ordering of the input.
> What I found (in 17) is that even if the references constraint wasn't
> set as deferrable, I could have rows for children before their parents
> in the COPY data and things still worked.

AFAIK, DEFERRABLE is for temporary violations crossing statement boundaries,
to postpone the enforcement of FKs at COMMIT time of the transaction.

While a single COPY is just one statement, so whether a temporary violation
for self-referential FKs would occur would be implementation-dependent,
and thus "neither logical" nor predictable.

Applies to other statement types too.

But of course, more authoritative answers will come I'm sure. --DD

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2024-10-31 12:20:02 Re: COPY documentation with regard to references constraints
Previous Message Bruno Wolff III 2024-10-31 11:38:32 COPY documentation with regard to references constraints