Index: openacs-4/packages/search/sql/postgresql/search-packages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-packages-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/search/sql/postgresql/search-packages-create.sql 30 Mar 2013 18:50:29 -0000 1.7 +++ openacs-4/packages/search/sql/postgresql/search-packages-create.sql 3 Sep 2024 15:37:54 -0000 1.8 @@ -1,35 +1,47 @@ -- Search Observer Package -- --- @cvs-id $Id$ +-- @cvs-id $Id$ -- -- procedure search_observer__enqueue/2 -- +select define_function_args('search_observer__enqueue','object_id,event'); + CREATE OR REPLACE FUNCTION search_observer__enqueue( p_object_id integer, p_event varchar ) RETURNS integer 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 + object_id, + event ) values ( p_object_id, - p_event + p_event ); return 0; END; $$ LANGUAGE plpgsql; -select define_function_args('search_observer__enqueue','object_id,event'); - - -- -- procedure search_observer__dequeue/3 -- @@ -41,8 +53,8 @@ DECLARE BEGIN - delete from search_observer_queue - where object_id = p_object_id + delete from search_observer_queue + where object_id = p_object_id and event = p_event and to_char(event_date,'yyyy-mm-dd hh24:mi:ss.us-tz') = to_char(p_event_date,'yyyy-mm-dd hh24:mi:ss.us-tz'); @@ -52,4 +64,3 @@ $$ LANGUAGE plpgsql; select define_function_args('search_observer__dequeue','object_id,event_date,event'); -