root/sql/sprocs/noit.update_mns_via_self.sql

Revision 4ff346a7dcd198c02bb08809ffc8fe5cf6f613d9, 0.8 kB (checked in by Denish Patel <denish@omniti.com>, 5 years ago)

Added noit.update_mns_via_self

  • Property mode set to 100644
Line 
1 -- formerly stratcon.trig_update_tsvector_from_metric_summary
2 CREATE OR REPLACE FUNCTION noit.update_mns_via_self()
3   RETURNS trigger AS
4 $BODY$
5 DECLARE
6  BEGIN
7  IF TG_OP != 'INSERT' THEN
8    IF (NEW.metric_name <> OLD.metric_name) THEN
9            UPDATE noit.metric_name_summary SET ts_search_all=stratcon.metric_name_summary_tsvector(NEW.sid,NEW.metric_name,NEW.metric_type)
10              where sid=NEW.sid and metric_name=NEW.metric_name and metric_type = NEW.metric_type;
11    END IF;   
12  ELSE
13     UPDATE noit.metric_name_summary SET ts_search_all=stratcon.metric_name_summary_tsvector(NEW.sid,NEW.metric_name,NEW.metric_type)
14             where sid=NEW.sid and metric_name=NEW.metric_name and metric_type = NEW.metric_type;
15  END IF; 
16    RETURN NEW;
17 END
18 $BODY$
19   LANGUAGE 'plpgsql'  SECURITY DEFINER;
20
21 GRANT EXECUTE ON FUNCTION noit.update_mns_via_self() TO stratcon;
Note: See TracBrowser for help on using the browser.