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

# 8.92. repair_log_triggers(only_locked boolean)

Function Properties

Language: PLPGSQL

Return Type: integer

repair the log triggers as required. If only_locked is true then only tables that are already exclusively locked by the current transaction are repaired. Otherwise all replicated tables with outdated trigger arguments are recreated.

    declare
    	retval integer;
    	table_row record;
    begin
    	retval=0;
    	for table_row in
    		select  tab_nspname,tab_relname,
    				tab_idxname, tab_id, mode,
    				determineAttKindUnique(tab_nspname||
    					'.'||tab_relname,tab_idxname) as attkind
    		from
    				sl_table
    				left join
    				pg_locks on (relation=tab_reloid and pid=pg_backend_pid()
    				and mode='AccessExclusiveLock')
    				,pg_trigger
    		where tab_reloid=tgrelid and
    		determineAttKindUnique(tab_nspname||'.'
    						||tab_relname,tab_idxname)
    			!=(decode_tgargs(tgargs))[2]
    			and tgname =  '_schemadoc'
    			|| '_logtrigger'
    		LOOP
    				if (only_locked=false) or table_row.mode='AccessExclusiveLock' then
    					 perform recreate_log_trigger
    					 		 (table_row.tab_nspname||'.'||table_row.tab_relname,
    							 table_row.tab_id,table_row.attkind);
    					retval=retval+1;
    				else
    					 raise notice '%.% has an invalid configuration on the log trigger. This was not corrected because only_lock is true and the table is not locked.',
    					 table_row.tab_nspname,table_row.tab_relname;

    				end if;
    		end loop;
    	return retval;
    end

Prev | Home | Next
registry_set_timestamp(p_value text, p_key timestamp with time zone) | Up | replicate_partition(p_comment integer, p_idxname text, p_tabname text, p_nspname text, p_tab_id text)