dropnode_int(p_no_id integer)

8.59. dropnode_int(p_no_id integer)

Function Properties

Language: PLPGSQL

Return Type: integer

internal function to process DROP_NODE event to drop node node_id from replication

declare
	v_tab_row		record;
begin
	-- ----
	-- If the dropped node is a remote node, clean the configuration
	-- from all traces for it.
	-- ----
	if p_no_id <> getLocalNodeId('_schemadoc') then
		delete from sl_subscribe
				where sub_receiver = p_no_id;
		delete from sl_listen
				where li_origin = p_no_id
					or li_provider = p_no_id
					or li_receiver = p_no_id;
		delete from sl_path
				where pa_server = p_no_id
					or pa_client = p_no_id;
		delete from sl_confirm
				where con_origin = p_no_id
					or con_received = p_no_id;
		delete from sl_event
				where ev_origin = p_no_id;
		delete from sl_node
				where no_id = p_no_id;

		return p_no_id;
	end if;

	-- ----
	-- This is us ... deactivate the node for now, the daemon
	-- will call uninstallNode() in a separate transaction.
	-- ----
	update sl_node
			set no_active = false
			where no_id = p_no_id;

	-- Rewrite sl_listen table
	perform RebuildListenEntries();

	return p_no_id;
end;