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; |