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

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: What have I done!?!?!? :-)
Дата
Msg-id 70c17f9b-1e6e-5dc2-ec1b-a60f9000026c@wi3ck.info
обсуждение исходный текст
Ответ на What have I done!?!?!? :-)  (Perry Smith <pedz@easesoftware.com>)
Ответы Re: What have I done!?!?!? :-)  (Nikolay Samokhvalov <samokhvalov@gmail.com>)
Список pgsql-general
On 4/6/22 18:25, Perry Smith wrote:
> Rather than explain how I got here, I’ll just explain the state I’m in.
> ...
> 
> 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.
> 
> I’m wondering if the disabled constraints are still disabled somehow. 
>   If so, how would I check for that and how would I turn them back on? 
>   Or am I way off in the weeds?

That depends on how exactly Active Record does this disabling of 
constraints. There is a GUC in PostgreSQL 'session_replication_role'. 
Setting that to value 'replica' will do precisely that as a side effect. 
Its primary purpose is for logical replication systems (like Londiste, 
Slony and logical decoding based ones) to disable user triggers and 
referential integrity actions (like on delete cascade) as well as 
integrity checking under the assumption that those actions have been 
performed on the origin database and will be replicated as well or are 
unnecessary.

Note that changing that setting requires PostgreSQL superuser privilege. 
Precisely because of the danger of getting your database into an 
inconsistent state.

So **IF** Active Record is using that feature, then it can dump any 
amount of garbage into your PostgreSQL database and PostgreSQL will 
happily accept it with zero integrity checking.


Best Regards, Jan



В списке pgsql-general по дате отправления:

Предыдущее
От: Andrus
Дата:
Сообщение: How to get updated order data
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Resources on modeling ordered hierachies?