droppath(p_pa_client integer, p_pa_server integer)

8.54. droppath(p_pa_client integer, p_pa_server integer)

Function Properties

Language: PLPGSQL

Return Type: bigint

Generate DROP_PATH event to drop path from pa_server to pa_client

declare
	v_row			record;
begin
	-- ----
	-- Grab the central configuration lock
	-- ----
	lock table sl_config_lock;

	-- ----
	-- There should be no existing subscriptions. Auto unsubscribing
	-- is considered too dangerous. 
	-- ----
	for v_row in select sub_set, sub_provider, sub_receiver
			from sl_subscribe
			where sub_provider = p_pa_server
			and sub_receiver = p_pa_client
	loop
		raise exception 
			'Slony-I: Path cannot be dropped, subscription of set % needs it',
			v_row.sub_set;
	end loop;

	-- ----
	-- Drop all sl_listen entries that depend on this path
	-- ----
	for v_row in select li_origin, li_provider, li_receiver
			from sl_listen
			where li_provider = p_pa_server
			and li_receiver = p_pa_client
	loop
		perform dropListen(
				v_row.li_origin, v_row.li_provider, v_row.li_receiver);
	end loop;

	-- ----
	-- Now drop the path and create the event
	-- ----
	perform dropPath_int(p_pa_server, p_pa_client);

	-- Rewrite sl_listen table
	perform RebuildListenEntries();

	return  createEvent ('_schemadoc', 'DROP_PATH',
			p_pa_server::text, p_pa_client::text);
end;