## 1.42. dropnode( integer )

Function Properties
Language: PLPGSQL
Return Type: bigint

generate DROP_NODE event to drop node node_id from replication

    declare
    	p_no_id			alias for $1;
    	v_node_row		record;
    begin
    	-- ----
    	-- Grab the central configuration lock
    	-- ----
    	lock table sl_config_lock;

    	-- ----
    	-- Check that this got called on a different node
    	-- ----
    	if p_no_id = getLocalNodeId('_schemadoc') then
    		raise exception 'Slony-I: DROP_NODE cannot initiate on the dropped node';
    	end if;

    	select * into v_node_row from sl_node
    			where no_id = p_no_id
    			for update;
    	if not found then
    		raise exception 'Slony-I: unknown node ID %', p_no_id;
    	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_id)
    	then
    		raise exception 'Slony-I: Node % is still configured as data provider',
    				p_no_id;
    	end if;

    	-- ----
    	-- Make sure no set originates there any more
    	-- ----
    	if exists (select true from sl_set
    			where set_origin = p_no_id)
    	then
    		raise exception 'Slony-I: Node % is still origin of one or more sets',
    				p_no_id;
    	end if;

    	-- ----
    	-- Call the internal drop functionality and generate the event
    	-- ----
    	perform dropNode_int(p_no_id);
    	return  createEvent('_schemadoc', 'DROP_NODE',
    									p_no_id);
    end;