storelisten_int(p_li_receiver integer, p_li_provider integer, p_li_origin integer)

Slony-I 2.2.10 Documentation
Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next

# 8.119. storelisten_int(p_li_receiver integer, p_li_provider integer, p_li_origin integer)

Function Properties

Language: PLPGSQL

Return Type: integer

FUNCTION storeListen_int (li_origin, li_provider, li_receiver) Process STORE_LISTEN event, indicating that receiver node li_receiver listens to node li_provider in order to get messages coming from node li_origin.

    declare
    	v_exists		int4;
    begin
    	-- ----
    	-- Grab the central configuration lock
    	-- ----
    	lock table sl_config_lock;

    	select 1 into v_exists
    			from sl_listen
    			where li_origin = p_li_origin
    			and li_provider = p_li_provider
    			and li_receiver = p_li_receiver;
    	if not found then
    		-- ----
    		-- In case we receive STORE_LISTEN 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_li_origin) then
    			perform storeNode_int (p_li_origin, '<event pending>');
    		end if;
    		if not exists (select 1 from sl_node
    						where no_id = p_li_provider) then
    			perform storeNode_int (p_li_provider, '<event pending>');
    		end if;
    		if not exists (select 1 from sl_node
    						where no_id = p_li_receiver) then
    			perform storeNode_int (p_li_receiver, '<event pending>');
    		end if;

    		insert into sl_listen
    				(li_origin, li_provider, li_receiver) values
    				(p_li_origin, p_li_provider, p_li_receiver);
    	end if;

    	return 0;
    end;

Prev | Home | Next
storelisten(p_receiver integer, p_provider integer, p_origin integer) | Up | storenode(p_no_comment integer, p_no_id text)