summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Browne2016-07-26 20:11:08 +0000
committerChristopher Browne2016-07-26 20:11:08 +0000
commit2bfe9a994175017dadde93aee574a1f44860549a (patch)
tree22cfb263fcbb21ac917d0e9baf63e34f09f6d4fb
parent21f8dce51499830a340deca1f8bc5c7e73353b87 (diff)
Bug 341 - suppress log trigger/deny when running in 'local' modeREL_2_1_STABLE
-rw-r--r--src/backend/slony1_funcs.sql20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/backend/slony1_funcs.sql b/src/backend/slony1_funcs.sql
index 7c46c5f5..b00e9738 100644
--- a/src/backend/slony1_funcs.sql
+++ b/src/backend/slony1_funcs.sql
@@ -5520,13 +5520,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_command text;
c_log integer;
c_node integer;
c_tabid integer;
begin
- c_tabid := tg_argv[0];
- c_node := @NAMESPACE@.getLocalNodeId('_@CLUSTERNAME@');
+ -- 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@');
c_command := 'TRUNCATE TABLE ONLY "' || tab_nspname || '"."' ||
tab_relname || '" CASCADE'
from @NAMESPACE@.sl_table where tab_id = c_tabid;
@@ -5548,7 +5555,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;