Christopher B. Browne's Home Page
cbbrowne@acm.org

1.56. droptrigger_int( integer, name )

Function Properties

PLPGSQLinteger
dropTrigger_int (trig_tabid, trig_tgname) Processes DROP_TRIGGER event to make sure that trigger trig_tgname on replicated table trig_tabid IS disabled.
    declare
    	p_trig_tabid		alias for $1;
    	p_trig_tgname		alias for $2;
    	v_tab_altered		boolean;
    begin
    	-- ----
    	-- Grab the central configuration lock
    	-- ----
    	lock table sl_config_lock;
    
    	-- ----
    	-- Get the current table status (altered or not)
    	-- ----
    	select tab_altered into v_tab_altered
    			from sl_table where tab_id = p_trig_tabid;
    	if not found then
    		-- ----
    		-- Not found is no hard error here, because that might
    		-- mean that we are not subscribed to that set
    		-- ----
    		return 0;
    	end if;
    
    	-- ----
    	-- If the table is modified for replication, restore the original state
    	-- ----
    	if v_tab_altered then
    		perform alterTableRestore(p_trig_tabid);
    	end if;
    
    	-- ----
    	-- Remove the entry from sl_trigger
    	-- ----
    	delete from sl_trigger
    			where trig_tabid = p_trig_tabid
    			  and trig_tgname = p_trig_tgname;
    
    	-- ----
    	-- Put the table back into replicated state if it was
    	-- ----
    	if v_tab_altered then
    		perform alterTableForReplication(p_trig_tabid);
    	end if;
    
    	return p_trig_tabid;
    end;

Google

If this was useful, let others know by an Affero rating

Contact me at cbbrowne@acm.org