storepath_int(p_pa_connretry integer, p_pa_conninfo integer, p_pa_client text, p_pa_server integer)

8.133. storepath_int(p_pa_connretry integer, p_pa_conninfo integer, p_pa_client text, p_pa_server integer)

Function Properties

Language: PLPGSQL

Return Type: integer

FUNCTION storePath (pa_server, pa_client, pa_conninfo, pa_connretry) Process the STORE_PATH event indicating that node pa_client can access node pa_server using DSN pa_conninfo

declare
	v_dummy			int4;
begin
	-- ----
	-- Check if the path already exists
	-- ----
	select 1 into v_dummy
			from sl_path
			where pa_server = p_pa_server
			and pa_client = p_pa_client
			for update;
	if found then
		-- ----
		-- Path exists, update pa_conninfo
		-- ----
		update sl_path
				set pa_conninfo = p_pa_conninfo,
					pa_connretry = p_pa_connretry
				where pa_server = p_pa_server
				and pa_client = p_pa_client;
	else
		-- ----
		-- New path
		--
		-- In case we receive STORE_PATH events before we know
		-- about the nodes involved in this, we generate those nodes
		-- as pending.
		-- ----
		if not exists (select 1 from sl_node
						where no_id = p_pa_server) then
			perform storeNode_int (p_pa_server, '<event pending>');
		end if;
		if not exists (select 1 from sl_node
						where no_id = p_pa_client) then
			perform storeNode_int (p_pa_client, '<event pending>');
		end if;
		insert into sl_path
				(pa_server, pa_client, pa_conninfo, pa_connretry) values
				(p_pa_server, p_pa_client, p_pa_conninfo, p_pa_connretry);
	end if;

	-- Rewrite sl_listen table
	perform RebuildListenEntries();

	return 0;
end;