ddlscript_complete(p_nodes text)

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

# 8.42. ddlscript_complete(p_nodes text)

Function Properties

Language: PLPGSQL

Return Type: bigint

ddlScript_complete(set_id, script, only_on_node) After script has run on origin, this fixes up relnames and log trigger arguments and inserts the "fire ddlScript_complete_int() log row into sl_log_script.

    declare
    	c_local_node	integer;
    	c_found_origin	boolean;
    	c_node			text;
    	c_cmdargs		text[];
    begin
    	c_local_node := getLocalNodeId('_schemadoc');

    	c_cmdargs = '{}'::text[];
    	if p_nodes is not null then
    		c_found_origin := 'f';
    		-- p_nodes list needs to consist o a list of nodes that exist
    		-- and that include the current node ID
    		for c_node in select trim(node) from
    				pg_catalog.regexp_split_to_table(p_nodes, ',') as node loop
    			if not exists
    					(select 1 from sl_node
    					where no_id = (c_node::integer)) then
    				raise exception 'ddlcapture(%,%) - node % does not exist!',
    					p_statement, p_nodes, c_node;
    		   end if;

    		   if c_local_node = (c_node::integer) then
    		   	  c_found_origin := 't';
    		   end if;

    		   c_cmdargs = array_append(c_cmdargs, c_node);
    	   end loop;

    		if not c_found_origin then
    			raise exception
    				'ddlScript_complete(%) - origin node % not included in ONLY ON list!',
    				p_nodes, c_local_node;
           end if;
        end if;

    	perform ddlScript_complete_int();

    	insert into sl_log_script
    			(log_origin, log_txid, log_actionseq, log_cmdtype, log_cmdargs)
    		values
    			(c_local_node, pg_catalog.txid_current(),
    			nextval('sl_action_seq'), 's', c_cmdargs);

    	return currval('sl_action_seq');
    end;

Prev | Home | Next
ddlcapture(p_nodes text, p_statement text) | Up | ddlscript_complete_int()