Search code examples
postgresqltriggerslogical-replication

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


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.


Solution

  • 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.