generate_sync_event(interval)

Slony-I 2.0.4 Documentation
Prev | Fast Backward | Chapter 1. Schema schemadoc | Fast Forward | Next

# 1.68. generate_sync_event(interval)

Function Properties

Language: PLPGSQL

Return Type: integer

Generate a sync event if there has not been one in the requested interval, and this is a provider node.

    declare
    	p_interval     alias for $1;
    	v_node_row     record;

    BEGIN
    	select 1 into v_node_row from sl_event
           	  where ev_type = 'SYNC' and ev_origin = getLocalNodeId('_schemadoc')
              and ev_timestamp > now() - p_interval limit 1;
    	if not found then
    		-- If there has been no SYNC in the last interval, then push one
    		perform createEvent('_schemadoc', 'SYNC', NULL)
                                             from sl_node n where no_id = getLocalNodeId('_schemadoc')
    			and exists (select 1 from sl_set where set_origin = no_id);
    		return 1;
    	else
    		return 0;
    	end if;
    end;

Prev | Home | Next
forwardconfirm(integer, integer, bigint, timestamp without time zone) | Up | getlocalnodeid(name)