Changeset f0400f824c10ceac576427c5023429506384cd8a
- Timestamp:
- 10/20/09 21:27:53
(4 years ago)
- Author:
- Robert Treat <robert@omniti.com>
- git-committer:
- Robert Treat <robert@omniti.com> 1256074073 +0000
- git-parent:
[b4c0bb19ecdfe7283237a73c2e71a43d343e4210]
- git-author:
- Robert Treat <robert@omniti.com> 1256074073 +0000
- Message:
trigger function updates for metric name summary management
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rae19db0 |
rf0400f8 |
|
| 1 | 1 | -- formerly stratcon.trig_update_tsvector_from_check_tags() |
|---|
| 2 | 2 | |
|---|
| 3 | | CREATE OR REPLACE FUNCTION noit.update_mns_via_check_tag() |
|---|
| 4 | | RETURNS trigger AS |
|---|
| | 3 | set search_path = noit, pg_catalog; |
|---|
| | 4 | |
|---|
| | 5 | CREATE OR REPLACE FUNCTION update_mns_via_check_tag() |
|---|
| | 6 | RETURNS trigger AS |
|---|
| 5 | 7 | $BODY$ |
|---|
| 6 | | DECLARE |
|---|
| 7 | 8 | BEGIN |
|---|
| 8 | | UPDATE noit.metric_name_summary SET fts_data=stratcon.metric_name_summary_tsvector(NEW.sid,metric_name,metric_type) |
|---|
| 9 | | where sid=NEW.sid; |
|---|
| 10 | | RETURN NEW; |
|---|
| | 9 | UPDATE metric_name_summary SET fts_data=stratcon.metric_name_summary_compile_fts_data(NEW.sid,metric_name,metric_type) WHERE sid=NEW.sid; |
|---|
| | 10 | RETURN NEW; |
|---|
| 11 | 11 | END |
|---|
| 12 | 12 | $BODY$ |
|---|
| 13 | | LANGUAGE 'plpgsql' SECURITY DEFINER; |
|---|
| | 13 | LANGUAGE 'plpgsql' |
|---|
| | 14 | SECURITY DEFINER; |
|---|
| 14 | 15 | |
|---|
| 15 | | GRANT EXECUTE ON FUNCTION noit.update_mns_via_check_tag() TO stratcon; |
|---|
| rae19db0 |
rf0400f8 |
|
| 1 | 1 | -- formerly stratcon.trig_update_tsvector_from_metric_tags |
|---|
| 2 | 2 | |
|---|
| 3 | | CREATE OR REPLACE FUNCTION noit.update_mns_via_metric_tag() |
|---|
| 4 | | RETURNS trigger AS |
|---|
| | 3 | set search_path = noit, pg_catalog; |
|---|
| | 4 | |
|---|
| | 5 | CREATE OR REPLACE FUNCTION update_mns_via_metric_tag() |
|---|
| | 6 | RETURNS trigger AS |
|---|
| 5 | 7 | $BODY$ |
|---|
| 6 | | DECLARE |
|---|
| 7 | 8 | BEGIN |
|---|
| 8 | | UPDATE noit.metric_name_summary SET fts_data=stratcon.metric_name_summary_tsvector(NEW.sid,NEW.metric_name,metric_type) |
|---|
| 9 | | where sid=NEW.sid and metric_name=NEW.metric_name; |
|---|
| | 9 | UPDATE metric_name_summary SET fts_data=stratcon.metric_name_summary_compile_fts_data(NEW.sid,NEW.metric_name,metric_type) |
|---|
| | 10 | WHERE sid=NEW.sid AND metric_name=NEW.metric_name; |
|---|
| 10 | 11 | RETURN NEW; |
|---|
| 11 | 12 | END |
|---|
| 12 | 13 | $BODY$ |
|---|
| 13 | | LANGUAGE 'plpgsql' SECURITY DEFINER; |
|---|
| | 14 | LANGUAGE 'plpgsql' |
|---|
| | 15 | SECURITY DEFINER; |
|---|
| 14 | 16 | |
|---|
| 15 | | GRANT EXECUTE ON FUNCTION noit.update_mns_via_metric_tag() TO stratcon; |
|---|
| rae19db0 |
rf0400f8 |
|
| 1 | | -- formerly stratcon.trig_update_tsvector_from_metric_summary |
|---|
| 2 | | CREATE OR REPLACE FUNCTION noit.update_mns_via_self() |
|---|
| 3 | | RETURNS trigger AS |
|---|
| | 1 | -- formerly stratcon.trig_update_tsvector_from_metric_summary |
|---|
| | 2 | |
|---|
| | 3 | set search_path = noit, pg_catalog; |
|---|
| | 4 | |
|---|
| | 5 | CREATE OR REPLACE FUNCTION update_mns_via_self() |
|---|
| | 6 | RETURNS trigger AS |
|---|
| 4 | 7 | $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 fts_data=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 fts_data=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; |
|---|
| | 8 | BEGIN |
|---|
| | 9 | IF TG_OP = 'UPDATE' THEN |
|---|
| | 10 | IF NEW.metric_name <> OLD.metric_name THEN |
|---|
| | 11 | RETURN NEW; |
|---|
| | 12 | END IF; |
|---|
| | 13 | END IF; |
|---|
| | 14 | |
|---|
| | 15 | NEW.fts_data = stratcon.metric_name_summary_compile_fts_data(NEW.sid, NEW.metric_name, NEW.metric_type); |
|---|
| | 16 | |
|---|
| | 17 | RETURN new; |
|---|
| 17 | 18 | END |
|---|
| 18 | 19 | $BODY$ |
|---|
| 19 | | LANGUAGE 'plpgsql' SECURITY DEFINER; |
|---|
| | 20 | LANGUAGE 'plpgsql' |
|---|
| | 21 | SECURITY DEFINER; |
|---|
| 20 | 22 | |
|---|
| 21 | | GRANT EXECUTE ON FUNCTION noit.update_mns_via_self() TO stratcon; |
|---|