session_replication_role 'replica' behavior
От | Manos Tsahakis |
---|---|
Тема | session_replication_role 'replica' behavior |
Дата | |
Msg-id | CABuvXqo+A0Dvn41Qsg3pkq+6-htdRig75X-ui_FiKn1yLofKow@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: session_replication_role `replica` behavior
|
Список | pgsql-general |
Hello all,
In our application we are enabling session_replication_role TO 'replica' in certain situations so that triggers will not fire in a table during DML operations. However, we observed that when setting session_replication_role TO 'replica' referential integrity constraints will not fire on a table either.dynacom=# create table parent (id serial primary key, name text not null);
dynacom=# create table child (id serial primary key, name text not null,pid int NOT NULL REFERENCES parent(id) ON DELETE CASCADE);
dynacom=# insert into parent (name) values ('test 1');
INSERT 0 1
dynacom=# insert into parent (name) values ('test 2');
INSERT 0 1
dynacom=# insert into child (name,pid) values ('test kid2',2);
INSERT 0 1
dynacom=# begin ;
BEGIN
dynacom=# set session_replication_role TO 'replica';
SET
dynacom=# delete from parent where id=2;
DELETE 1
dynacom=# commit ;
COMMIT
dynacom=# select * from child;
id | name | pid
----+-----------+-----
2 | test kid2 | 2
(1 row)
dynacom=# select * from parent;
id | name
----+------
(0 rows)
DELETE 1
dynacom=# commit ;
COMMIT
dynacom=# select * from child;
id | name | pid
----+-----------+-----
2 | test kid2 | 2
(1 row)
dynacom=# select * from parent;
id | name
----+------
(0 rows)
So we are a left, basically, with an inconsistent database.
2. Is there any way to just find the name of the FK constraint trigger and convert it to
ENABLE ALWAYS?
For the above test we used postgresql 9.2, currently we are running postgresql 9.0 in production.
Kind Regards,
manos
В списке pgsql-general по дате отправления: