Slony-I 2.2.10 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
8.52. dropnode(p_no_ids integer[])
Function Properties
Language: PLPGSQL
Return Type: bigint
generate DROP_NODE event to drop node node_id from replicationdeclare v_node_row record; v_idx integer; begin -- ---- -- Grab the central configuration lock -- ---- lock table sl_config_lock; -- ---- -- Check that this got called on a different node -- ---- if getLocalNodeId('_schemadoc') = ANY (p_no_ids) then raise exception 'Slony-I: DROP_NODE cannot initiate on the dropped node'; end if; -- -- if any of the deleted nodes are receivers we drop the sl_subscribe line -- delete from sl_subscribe where sub_receiver = ANY (p_no_ids); v_idx:=1; LOOP EXIT WHEN v_idx>array_upper(p_no_ids,1) ; select * into v_node_row from sl_node where no_id = p_no_ids[v_idx] for update; if not found then raise exception 'Slony-I: unknown node ID % %', p_no_ids[v_idx],v_idx; end if; -- ---- -- Make sure we do not break other nodes subscriptions with this -- ---- if exists (select true from sl_subscribe where sub_provider = p_no_ids[v_idx]) then raise exception 'Slony-I: Node % is still configured as a data provider', p_no_ids[v_idx]; end if; -- ---- -- Make sure no set originates there any more -- ---- if exists (select true from sl_set where set_origin = p_no_ids[v_idx]) then raise exception 'Slony-I: Node % is still origin of one or more sets', p_no_ids[v_idx]; end if; -- ---- -- Call the internal drop functionality and generate the event -- ---- perform dropNode_int(p_no_ids[v_idx]); v_idx:=v_idx+1; END LOOP; return createEvent('_schemadoc', 'DROP_NODE', array_to_string(p_no_ids,',')); end;