ddlscript_prepare_int(p_only_on_node integer, p_set_id integer)

8.47. ddlscript_prepare_int(p_only_on_node integer, p_set_id integer)

Function Properties

Language: PLPGSQL

Return Type: integer

ddlScript_prepare_int (set_id, only_on_node) Do preparatory work for a DDL script, restoring triggers/rules to original state.

	v_set_origin		int4;
	v_no_id				int4;
	v_row				record;
	-- ----
	-- Check that we either are the set origin or a current
	-- subscriber of the set.
	-- ----
	v_no_id := getLocalNodeId('_schemadoc');
	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 v_set_origin <> v_no_id
			and not exists (select 1 from sl_subscribe
						where sub_set = p_set_id
						and sub_receiver = v_no_id)
		return 0;
	end if;

	-- ----
	-- If execution on only one node is requested, check that
	-- we are that node.
	-- ----
	if p_only_on_node > 0 and p_only_on_node <> v_no_id then
		return 0;
	end if;

	return p_set_id;