Slony-I 2.1.4 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
8.25. altertableconfiguretriggers(p_tab_id integer)
Function Properties
Language: PLPGSQL
Return Type: integer
alterTableConfigureTriggers (tab_id) Set the enable/disable configuration for the replication triggers according to the origin of the set.declare v_no_id int4; v_tab_row record; v_tab_fqname text; v_n int4; begin -- ---- -- Grab the central configuration lock -- ---- lock table sl_config_lock; -- ---- -- Get our local node ID -- ---- v_no_id := getLocalNodeId('_schemadoc'); -- ---- -- Get the sl_table row and the current tables origin. -- ---- select T.tab_reloid, T.tab_set, S.set_origin, PGX.indexrelid, slon_quote_brute(PGN.nspname) || '.' || slon_quote_brute(PGC.relname) as tab_fqname into v_tab_row from sl_table T, sl_set S, "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN, "pg_catalog".pg_index PGX, "pg_catalog".pg_class PGXC where T.tab_id = p_tab_id and T.tab_set = S.set_id and T.tab_reloid = PGC.oid and PGC.relnamespace = PGN.oid and PGX.indrelid = T.tab_reloid and PGX.indexrelid = PGXC.oid and PGXC.relname = T.tab_idxname for update; if not found then raise exception 'Slony-I: alterTableConfigureTriggers(): Table with id % not found', p_tab_id; end if; v_tab_fqname = v_tab_row.tab_fqname; -- ---- -- Configuration depends on the origin of the table -- ---- if v_tab_row.set_origin = v_no_id then -- ---- -- On the origin the log trigger is configured like a default -- user trigger and the deny access trigger is disabled. -- ---- execute 'alter table ' || v_tab_fqname || ' enable trigger "_schemadoc_logtrigger"'; execute 'alter table ' || v_tab_fqname || ' disable trigger "_schemadoc_denyaccess"'; perform alterTableConfigureTruncateTrigger(v_tab_fqname, 'enable', 'disable'); else -- ---- -- On a replica the log trigger is disabled and the -- deny access trigger fires in origin session role. -- ---- execute 'alter table ' || v_tab_fqname || ' disable trigger "_schemadoc_logtrigger"'; execute 'alter table ' || v_tab_fqname || ' enable trigger "_schemadoc_denyaccess"'; perform alterTableConfigureTruncateTrigger(v_tab_fqname, 'disable', 'enable'); end if; return p_tab_id; end;