diff options
| author | Christopher Browne | 2016-07-26 20:05:51 +0000 |
|---|---|---|
| committer | Christopher Browne | 2016-07-26 20:05:51 +0000 |
| commit | 752a7735ac2796b97dc02ee4cd545cd0485dac1b (patch) | |
| tree | 02fdb90626c86320eeae91cffd6398bf0cd5d9b0 | |
| parent | a7d98dba1dd6bf1790f638fc1986ad409a26319f (diff) | |
Bug 341 - suppress log trigger/deny when running in 'local' mode
| -rw-r--r-- | src/backend/slony1_funcs.sql | 17 |
1 files changed, 17 insertions, 0 deletions
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; |
