Slony-I 2.0.8 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 6. Schema schemadoc | Fast Forward | Next |
6.129. unlockset(integer)
Function Properties
Language: PLPGSQL
Return Type: integer
Remove the special trigger from all tables of a set that disables access to it.declare p_set_id alias for $1; v_local_node_id int4; v_set_row record; v_tab_row record; begin -- ---- -- Grab the central configuration lock -- ---- lock table sl_config_lock; -- ---- -- Check that the set exists and that we are the origin -- and that it is not already locked. -- ---- v_local_node_id := getLocalNodeId('_schemadoc'); select * into v_set_row from sl_set where set_id = p_set_id for update; if not found then raise exception 'Slony-I: set % not found', p_set_id; end if; if v_set_row.set_origin <> v_local_node_id then raise exception 'Slony-I: set % does not originate on local node', p_set_id; end if; if v_set_row.set_locked isnull then raise exception 'Slony-I: set % is not locked', p_set_id; end if; -- ---- -- Drop the lockedSet trigger from all tables in the set. -- ---- for v_tab_row in select T.tab_id, slon_quote_brute(PGN.nspname) || '.' || slon_quote_brute(PGC.relname) as tab_fqname from sl_table T, "pg_catalog".pg_class PGC, "pg_catalog".pg_namespace PGN where T.tab_set = p_set_id and T.tab_reloid = PGC.oid and PGC.relnamespace = PGN.oid order by tab_id loop execute 'drop trigger "_schemadoc_lockedset" ' || 'on ' || v_tab_row.tab_fqname; end loop; -- ---- -- Clear out the set_locked field -- ---- update sl_set set set_locked = NULL where set_id = p_set_id; return p_set_id; end;