root/sql/sprocs/noit.update_check_currently.sql

Revision 635ff12b1629be1d08ee18e49f204c9921a0a939, 1.0 kB (checked in by Robert Treat <robert@omniti.com>, 5 years ago)

fix up check_archive trigger function

  • Property mode set to 100644
Line 
1 SET search_path = noit, pg_catalog;
2
3 CREATE OR REPLACE FUNCTION update_check_currently()
4 RETURNS trigger
5 AS $$
6 DECLARE
7     v_remote_address INET;
8     v_target TEXT;
9     v_module TEXT;
10     v_name TEXT;
11 BEGIN
12
13 IF TG_OP = 'INSERT' THEN
14     SELECT remote_address, target, module, name FROM check_currently WHERE sid = NEW.sid AND id=NEW.id
15         INTO v_remote_address,v_target,v_module,v_name;
16
17     IF v_remote_address IS DISTINCT FROM NEW.remote_address OR v_target IS DISTINCT FROM NEW.target OR v_name IS DISTINCT FROM NEW.name THEN
18         DELETE from check_currently WHERE sid = NEW.sid AND id=NEW.id;
19        
20         INSERT INTO check_currently (sid,remote_address,whence,id,target,module,name)
21             VALUES (NEW.sid,NEW.remote_address,NEW.whence,NEW.id,NEW.target,NEW.module,NEW.name);
22     END IF;
23 ELSE
24         RAISE EXCEPTION 'Trigger for update_check_currently called in incorrect context!';
25 END IF;
26
27     RETURN NULL;
28
29 END
30 $$
31 LANGUAGE plpgsql
32 SECURITY DEFINER
33 ;
34
Note: See TracBrowser for help on using the browser.