Re: What have I done!?!?!? :-)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Perry Smith <pedz(at)easesoftware(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: What have I done!?!?!? :-)
Date: 2022-04-06 22:41:12
Message-ID: CAKFQuwY15ik_cjGZMzd_uuiiVYjQUCOedkjQFRJ3xRcm276ptw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, April 6, 2022, Perry Smith <pedz(at)easesoftware(dot)com> wrote:

>
> I’m using Active Record with the psql adapter. It has a
> disable_referential_integrity which takes a block of code. When the
> block of code exists, the constraints are put back. At least, that is what
> I thought.
>

Constraints basically are only ever evaluated when DML (insert, update,
delete) commands commit and ensure the rows affected by those commands are
valid at that moment in time. If you manage to insert invalid data,
because you say disabled validation, it will not be checked again. Even an
“update” doesn’t re-check the existing record, it effectively deletes it,
and then checks its replacement.

So, yes, the constraints were probably “put back”, but it was too late, the
invalid data was already saved.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Bisnett 2022-04-06 22:45:28 Re: Per-Table vacuum_freeze_min_age
Previous Message Adrian Klaver 2022-04-06 22:31:21 Re: Per-Table vacuum_freeze_min_age