From: Christopher Browne Date: Tue, 26 Jul 2016 20:05:51 +0000 (-0400) Subject: Bug 341 - suppress log trigger/deny when running in 'local' mode X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=752a7735ac2796b97dc02ee4cd545cd0485dac1b;p=slony1-engine.git Bug 341 - suppress log trigger/deny when running in 'local' mode --- diff --git a/src/backend/slony1_funcs.sql b/src/backend/slony1_funcs.sql index 378b4c72..a47e89d2 100644 --- a/src/backend/slony1_funcs.sql +++ b/src/backend/slony1_funcs.sql @@ -6409,12 +6409,20 @@ comment on function @NAMESPACE@.slon_node_health_check() is 'called when slon st create or replace function @NAMESPACE@.log_truncate () returns trigger as $$ declare + r_role text; c_nspname text; c_relname text; c_log integer; c_node integer; c_tabid integer; begin + -- Ignore this call if session_replication_role = 'local' + select into r_role setting + from pg_catalog.pg_settings where name = 'session_replication_role'; + if r_role = 'local' then + return NULL; + end if; + c_tabid := tg_argv[0]; c_node := @NAMESPACE@.getLocalNodeId('_@CLUSTERNAME@'); select tab_nspname, tab_relname into c_nspname, c_relname @@ -6451,7 +6459,16 @@ is 'trigger function run when a replicated table receives a TRUNCATE request'; create or replace function @NAMESPACE@.deny_truncate () returns trigger as $$ + declare + r_role text; begin + -- Ignore this call if session_replication_role = 'local' + select into r_role setting + from pg_catalog.pg_settings where name = 'session_replication_role'; + if r_role = 'local' then + return NULL; + end if; + raise exception 'truncation of replicated table forbidden on subscriber node'; end $$ language plpgsql;