1.69. initializelocalnode( integer, text )

Function Properties

Language: PLPGSQL

Return Type: integer

no_id - Node ID # no_comment - Human-oriented comment Initializes the new node, no_id

declare
	p_local_node_id		alias for $1;
	p_comment			alias for $2;
	v_old_node_id		int4;
	v_first_log_no		int4;
	v_event_seq			int8;
begin
	-- ----
	-- Grab the central configuration lock
	-- ----
	lock table sl_config_lock;

	-- ----
	-- Make sure this node is uninitialized or got reset
	-- ----
	select last_value::int4 into v_old_node_id from sl_local_node_id;
	if v_old_node_id != -1 then
		raise exception 'Slony-I: This node is already initialized';
	end if;

	-- ----
	-- Set sl_local_node_id to the requested value and add our
	-- own system to sl_node.
	-- ----
	perform setval('sl_local_node_id', p_local_node_id);
	perform setval('sl_rowid_seq', 
			p_local_node_id::int8 * '1000000000000000'::int8);
	perform storeNode_int (p_local_node_id, p_comment, false);
	
	return p_local_node_id;
end;