Changeset 95da4d03b21a3c6dddd17c80da46c7e2b62fd8c0

Show
Ignore:
Timestamp:
10/23/09 21:29:19 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1256333359 +0000
git-parent:

[15e6a4b643a979494b3b34356022cba81433525b]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1256333359 +0000
Message:

one rollup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/sprocs/stratcon.rollup_metric_numeric.sql

    rf681bab r95da4d0  
    1919    v_count         INTEGER; 
    2020BEGIN 
     21    IF in_roll = '5m' THEN 
     22        PERFORM stratcon.rollup_metric_numeric_5m(); 
     23        RETURN 0; 
     24    END IF; 
     25 
    2126    -- Get rollup config based on given name, and fail if its wrong name. 
    2227    SELECT * FROM metric_numeric_rollup_config WHERE rollup = in_roll INTO v_conf; 
     
    8287            v_offset        := floor( ( extract('epoch' from v_rec.rollup_time) - v_stored_rollup) / v_conf.seconds ); 
    8388 
    84             --v_offset := ( 12*(extract('hour' from v_info.rollup_time))+floor(extract('minute' from v_info.rollup_time)/5) ); 
    85             --v_stored_rollup := v_info.rollup_time::date; 
    86             -- RAISE NOTICE 'sid %, name %, rollup_time %, offset %', v_rec.sid, v_rec.name, v_stored_rollup, v_offset; 
    87  
    8889            v_sql := 'SELECT * FROM metric_numeric_rollup_'||in_roll||' WHERE rollup_time = '||quote_literal(v_stored_rollup_tm); 
    8990            v_sql := v_sql ||' and sid='||v_rec.sid||' and name = '|| quote_literal(v_rec.name); 
     
    105106            IF v_init THEN 
    106107                v_sql := 'INSERT INTO metric_numeric_rollup_'||in_roll||' (sid,name,rollup_time,count_rows,avg_value,counter_dev) 
    107                     VALUES ('|| v_segment.sid||','||quote_literal(v_segment.name)||','||quote_literal(v_stored_rollup_tm)||','||v_segment.count_rows 
    108                     ||','||v_segment.avg_value||','||v_segment.counter_dev||')'; 
    109                 EXECUTE v_sql; 
     108                    VALUES ($1,$2,$3,$4,$5,$6)'; 
     109                EXECUTE v_sql USING v_segment.sid, v_segment.name, v_stored_rollup_tm, v_segment.count_rows, v_segment.avg_value, v_segment.counter_dev; 
    110110                v_init := false; 
    111111            ELSE 
    112112                v_sql := 'UPDATE metric_numeric_rollup_'||in_roll; 
    113                 v_sql := v_sql || 'SET (count_rows,avg_value,counter_dev) = ('||v_rec.count_rows||','||v_rec.avg_value||','||v_rec.counter_dev||')'; 
    114                 v_sql := v_sql || 'WHERE rollup_time = '||v_stored_rollup_tm||'  AND sid = '||v_info.sid||'  AND name = '||quote_literal(v_info.name)
    115                 EXECUTE v_sql;  
     113                v_sql := v_sql || ' SET (count_rows,avg_value,counter_dev) = ($1,$2,$3)'; 
     114                v_sql := v_sql || ' WHERE rollup_time = $4  AND sid = $5 AND name = $6'
     115                EXECUTE v_sql USING v_segment.count_rows, v_segment.avg_value, v_segment.counter_dev, v_stored_rollup_tm, v_segment.sid, v_segment.name;  
    116116            END IF; 
    117117