Are ENABLE REPLICA TRIGGER and ENABLE ALWAYS TRIGGER different in any way in Postgres 12.3?

1.7k Views Asked by At

I'm checking out logical replication in Postges 12.3...and it's awesome. A quick question, is there any difference in behavior between ENABLE REPLICA TRIGGER and ENABLE ALWAYS TRIGGER? I've tried both, in a simple test setup, and they both enable the replica-side trigger to fire.

I couldn't find any extra details in the docs, or with a bit of searching.

If they're synonyms, I'll go with ENABLE REPLICA TRIGGER as it seems like a more specific statement of intent.

Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

See here:

https://www.postgresql.org/docs/current/sql-altertable.html

Simply enabled triggers (the default) will fire when the replication role is “origin” (the default) or “local”. Triggers configured as ENABLE REPLICA will only fire if the session is in “replica” mode, and triggers configured as ENABLE ALWAYS will fire regardless of the current replication role.