--
-- search_observer__enqueue/2
--
create or replace function search_observer__enqueue(
p_object_id integer,
p_event character varying
) returns int4 as $$
DECLARE
BEGIN
--
-- We see cases, where the object to be removed from the observer
-- queue does not exist anymore. Probably, this is due to some
-- race condition.
--
if p_event = 'DELETE' then
IF NOT EXISTS (select 1 from acs_objects where object_id = p_object_id) then
return 0;
end if;
end if;
insert into search_observer_queue (
object_id,
event
) values (
p_object_id,
p_event
);
return 0;
END;
$$ language plpgsql;