[Reconnoiter-devel] [reconnoiter commit] r981 - branches/skeksis/sql/sprocs

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Tue Oct 20 15:47:29 EDT 2009


Author: robert
Date: 2009-10-20 15:47:29 -0400 (Tue, 20 Oct 2009)
New Revision: 981

Modified:
   branches/skeksis/sql/sprocs/stratcon.metric_name_summary_tsvector.sql
Log:
code cleanup, avoid explicit noit paths

Modified: branches/skeksis/sql/sprocs/stratcon.metric_name_summary_tsvector.sql
===================================================================
--- branches/skeksis/sql/sprocs/stratcon.metric_name_summary_tsvector.sql	2009-10-20 18:59:55 UTC (rev 980)
+++ branches/skeksis/sql/sprocs/stratcon.metric_name_summary_tsvector.sql	2009-10-20 19:47:29 UTC (rev 981)
@@ -1,55 +1,47 @@
--- Function: stratcon.metric_name_summary_tsvector(integer, text, text)
+set search_path = noit,pg_catalog;
 
-CREATE OR REPLACE FUNCTION stratcon.metric_name_summary_tsvector(in_sid integer, in_metric_name text, in_metric_type text)
-  RETURNS tsvector AS
-$BODY$DECLARE
-ref_sid integer;
-ref_module text;
-ref_name text;
-ref_target text;
-ref_tags text;
-ref_ctags text;
-ref_hostname text;
-ref_metric_name text;
-ref_alias text;
-v_fts_data tsvector;
+CREATE OR REPLACE FUNCTION stratcon.metric_name_summary_compile_fts_data
+(in_sid integer, in_metric_name text, in_metric_type text)
+RETURNS tsvector AS
+$BODY$
+DECLARE
+    ref_sid integer;
+    ref_module text;
+    ref_name text;
+    ref_target text;
+    ref_tags text;
+    ref_ctags text;
+    ref_hostname text;
+    ref_metric_name text;
+    ref_alias text;
+    v_fts_data tsvector;
 BEGIN
-    SELECT sid,module,name,target
-      INTO ref_sid,ref_module,ref_name,ref_target
-      FROM  noit.check_archive where sid=in_sid;
+    SELECT sid, module, name, target FROM check_archive WHERE sid=in_sid INTO ref_sid,ref_module,ref_name,ref_target;
     IF NOT FOUND THEN
         RETURN NULL;
     END IF;
 
-    SELECT COALESCE(array_to_string(tags_array, ' '), ' ') INTO ref_tags
-      FROM noit.metric_tag
-     WHERE sid=in_sid and metric_name=in_metric_name;
+    SELECT COALESCE(array_to_string(tags_array, ' '), ' ') FROM metric_tag WHERE sid=in_sid and metric_name=in_metric_name INTO ref_tags;
     IF NOT FOUND THEN
-        ref_tags:=' ';
+        ref_tags := ' ';
     END IF;
 
-    SELECT COALESCE(array_to_string(tags_array, ' '), ' ') INTO ref_ctags
-      FROM noit.check_tag
-     WHERE sid=in_sid;
+    SELECT COALESCE(array_to_string(tags_array, ' '), ' ') FROM check_tag WHERE sid=in_sid INTO ref_ctags;
     IF NOT FOUND THEN
-        ref_ctags:=' ';
+        ref_ctags := ' ';
     END IF;
 
-    SELECT value INTO ref_hostname
-      FROM noit.metric_text_currently mt
-      JOIN noit.check_archive s USING(sid)
-     WHERE module='dns' AND s.name='in-addr.arpa' AND target = ref_target;
+    SELECT value FROM metric_text_currently mt JOIN check_archive s USING(sid) 
+        WHERE module='dns' AND s.name='in-addr.arpa' AND target = ref_target INTO ref_hostname;
+      
+    SELECT mt.value FROM metric_text_currently mt JOIN check_archive s USING(sid)
+        WHERE s.module='snmp' AND mt.name='alias' AND s.sid=in_sid INTO ref_alias;
 
-    SELECT mt.value INTO ref_alias
-      FROM noit.metric_text_currently mt
-      JOIN noit.check_archive s USING(sid)
-     WHERE s.module='snmp' AND mt.name='alias' AND s.sid=in_sid;
-
     ref_hostname := coalesce(replace(ref_hostname, '.', ' '), ' ');
     ref_metric_name := regexp_replace(in_metric_name, E'[_\`/.\\134]', ' ', 'g');
     ref_alias := coalesce(regexp_replace(ref_alias, E'[_\`/.\\134]', ' ', 'g'), ' ');
 
-    v_fts_data=to_tsvector(ref_metric_name || ' ' ||
+    v_fts_data := to_tsvector(ref_metric_name || ' ' ||
                                 ref_module || ' ' ||
                                 ref_name || ' ' ||
                                 ref_target || ' ' ||
@@ -58,8 +50,8 @@
                                 ref_tags || ' ' ||
                                 ref_ctags);
     RETURN v_fts_data;
-END$BODY$
-  LANGUAGE 'plpgsql' SECURITY DEFINER;
+END
+$BODY$
+LANGUAGE 'plpgsql' 
+SECURITY DEFINER;
  
-GRANT EXECUTE ON FUNCTION stratcon.metric_name_summary_tsvector(integer, text, text) TO stratcon;
-



More information about the Reconnoiter-devel mailing list