initializelocalnode(p_comment integer, p_local_node_id text)

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

# 8.70. initializelocalnode(p_comment integer, p_local_node_id text)

Function Properties

Language: PLPGSQL

Return Type: integer

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

    declare
    	v_old_node_id		int4;
    	v_first_log_no		int4;
    	v_event_seq			int8;
    begin
    	-- ----
    	-- 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 storeNode_int (p_local_node_id, p_comment);

    	if (pg_catalog.current_setting('max_identifier_length')::integer - pg_catalog.length('schemadoc')) < 5 then
    		raise notice 'Slony-I: Cluster name length [%] versus system max_identifier_length [%] ', pg_catalog.length('schemadoc'), pg_catalog.current_setting('max_identifier_length');
    		raise notice 'leaves narrow/no room for some Slony-I-generated objects (such as indexes).';
    		raise notice 'You may run into problems later!';
    	end if;

    	--
    	-- Put the apply trigger onto sl_log_1 and sl_log_2
    	--
    	create trigger apply_trigger
    		before INSERT on sl_log_1
    		for each row execute procedure logApply('_schemadoc');
    	alter table sl_log_1
    	  enable replica trigger apply_trigger;
    	create trigger apply_trigger
    		before INSERT on sl_log_2
    		for each row execute procedure logApply('_schemadoc');
    	alter table sl_log_2
    			enable replica trigger apply_trigger;

    	return p_local_node_id;
    end;

Prev | Home | Next
generate_sync_event(p_interval interval) | Up | is_node_reachable(receiver_node_id integer, origin_node_id integer)