Re: pgsql 8.3 : force FK (and consequently ON DELETE CASCADE) to berun under session_replication_role TO 'replica'

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: pgsql 8.3 : force FK (and consequently ON DELETE CASCADE) to berun under session_replication_role TO 'replica'
Дата
Msg-id f0d2cbbb-ac4f-4dc0-7986-973fd1b311b4@2ndquadrant.com
обсуждение исходный текст
Ответ на pgsql 8.3 : force FK (and consequently ON DELETE CASCADE) to be rununder session_replication_role TO 'replica'  (Achilleas Mantzios <achill@matrix.gatewaynet.com>)
Ответы Re: pgsql 8.3 : force FK (and consequently ON DELETE CASCADE) to berun under session_replication_role TO 'replica'  (Achilleas Mantzios <achill@matrix.gatewaynet.com>)
Список pgsql-admin
On 2019-07-05 12:17, Achilleas Mantzios wrote:
> we run some replication statements code under with session_replication_role TO 'replica' ,
> however this disables FK constraints and consequently some important ON DELETE CASCADE that must be run.
> 
> I tested this and this works :
> psql -qt -c 'SELECT '\''ALTER TABLE mariner ENABLE ALWAYS TRIGGER "'\''|| tgname||'\''";'\'' from pg_trigger where
tgconstrname='\''personal_email_sender_marinerid_fkey'\''and tgisconstraint and 
 
> tgrelid='\''mariner'\''::regclass' | psql -f -
> 
> and then test with:
> BEGIN ;
> set session_replication_role TO 'replica';
> DELETE FROM mariner where id = 23700;
> SELECT * from personal_email_sender where marinerid = 23700;
>   email | marinerid
> -------+-----------
> (0 rows)
> 
> ^^^ and verify that the ON DELETE CASCADE is run.
> 
> So, besides the obvious comment, that one should not mess with system triggers, do you see any potential gotcha with
thisparticular one?
 

I think this is generally OK.

But if you are doing this, you probably have a replication system that
is running under the replica session role.  The question is then whether
that replication system is OK with it.  If you create replication sets
that contain parts of foreign key relationships and not others then you
might run into constraint violations.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: Achilleas Mantzios
Дата:
Сообщение: pgsql 8.3 : force FK (and consequently ON DELETE CASCADE) to be rununder session_replication_role TO 'replica'
Следующее
От: Alexandre hadjinlian guerra
Дата:
Сообщение: are there any expectations about pg indexes having prefix compression?