Re: What have I done!?!?!? :-) - Mailing list pgsql-general

From David G. Johnston
Subject Re: What have I done!?!?!? :-)
Date
Msg-id CAKFQuwY15ik_cjGZMzd_uuiiVYjQUCOedkjQFRJ3xRcm276ptw@mail.gmail.com
Whole thread Raw
In response to What have I done!?!?!? :-)  (Perry Smith <pedz@easesoftware.com>)
List pgsql-general
On Wednesday, April 6, 2022, Perry Smith <pedz@easesoftware.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.


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Per-Table vacuum_freeze_min_age
Next
From: Chris Bisnett
Date:
Subject: Re: Per-Table vacuum_freeze_min_age