Christopher B. Browne's Home Page

8.43. ddlscript_prepare(integer, integer)

Function Properties

Prepare for DDL script execution on origin
    	p_set_id			alias for $1;
    	p_only_on_node		alias for $2;
    	v_set_origin		int4;
    	-- ----
    	-- Grab the central configuration lock
    	-- ----
    	lock table sl_config_lock;
    	-- ----
    	-- Check that the set exists and originates here
    	-- ----
    	select set_origin into v_set_origin
    			from sl_set
    			where set_id = p_set_id
    			for update;
    	if not found then
    		raise exception 'Slony-I: set % not found', p_set_id;
    	end if;
    	if p_only_on_node = -1 then
    		if v_set_origin <> getLocalNodeId('_schemadoc') then
    			raise exception 'Slony-I: set % does not originate on local node',
    		end if;
    		-- ----
    		-- Create a SYNC event
    		-- ----
    		perform createEvent('_schemadoc', 'SYNC', NULL);
    		-- If running "ONLY ON NODE", there are two possibilities:
    		-- 1.  Running on origin, where denyaccess() triggers are already shut off
    		-- 2.  Running on replica, where we need the LOCAL role to suppress denyaccess() triggers
    		if (v_set_origin <> getLocalNodeId('_schemadoc')) then
    			execute 'set session_replication_role to local;';
    		end if;
    	end if;
    	return 1;

Contact me at