With PostgreSQL, I can set up a publication and subscription between two databases and the subscription will duplicate the contents for the published table.

What I found interesting is that the subscription table appears to permit INSERT because you need to CREATE it as you normally work.

I want to make a bidirectional subscription from database A and B such that table T has records "owned" by either A or B and only changes make by the owner are recorded.

For example,


Then due to the replication, both databases have this record. But due to the pub/sub "ownership", only the following operations actually have an effect.

DELETE FROM A.T WHERE value = 'rowA';
DELETE FROM B.T WHERE value = 'rowB';

The operations,

DELETE FROM B.T WHERE value = 'rowA';
DELETE FROM A.T WHERE value = 'rowB';

don't have an effect because the ownership is off.

Is this possible?

originally posted in StackOverflow, but moving it here

| improve this question | | | | |
  • 1
    You cannot have multi-master replication with PostgreSQL logical replication. – Laurenz Albe Jun 18 '19 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.