Skip to content

Commit

Permalink
Fix typo in collection of aggregate of functions per DB (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
marco44 authored Feb 16, 2025
1 parent f939909 commit 8400305
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions powa--5.0.1--5.0.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,60 @@ BEGIN
END;
$_$
SET search_path = pg_catalog; /* end of powa_check_dropped_extensions */

CREATE OR REPLACE FUNCTION @[email protected]_user_functions_aggregate(_srvid integer)
RETURNS void AS $PROC$
DECLARE
v_funcname text := format('@extschema@.%I(%s)',
'powa_user_functions_aggregate', _srvid);
v_rowcount bigint;
BEGIN
PERFORM @[email protected]_log('running powa_user_functions_aggregate(' || _srvid ||')');

PERFORM @[email protected]_prevent_concurrent_snapshot(_srvid);

-- aggregate user_functions table
INSERT INTO @[email protected]_user_functions_history
(srvid, dbid, funcid, coalesce_range, records,
mins_in_range, maxs_in_range)
SELECT srvid, dbid, funcid,
tstzrange(min((record).ts), max((record).ts),'[]'),
array_agg(record),
ROW(min((record).ts), min((record).calls),min((record).total_time),
min((record).self_time))::@[email protected]_user_functions_history_record,
ROW(max((record).ts), max((record).calls),max((record).total_time),
max((record).self_time))::@[email protected]_user_functions_history_record
FROM @[email protected]_user_functions_history_current
WHERE srvid = _srvid
GROUP BY srvid, dbid, funcid;

GET DIAGNOSTICS v_rowcount = ROW_COUNT;
PERFORM @[email protected]_log(format('%s - (powa_user_functions_history_current) rowcount: %s',
v_funcname, v_rowcount));

DELETE FROM @[email protected]_user_functions_history_current WHERE srvid = _srvid;

-- aggregate user_functions_db table
INSERT INTO @[email protected]_user_functions_history_db
(srvid, dbid, coalesce_range, records, mins_in_range, maxs_in_range)
SELECT srvid, dbid,
tstzrange(min((record).ts), max((record).ts),'[]'),
array_agg(record),
ROW(min((record).ts), min((record).calls),min((record).total_time),
min((record).self_time))::@[email protected]_user_functions_history_record,
ROW(max((record).ts), max((record).calls),max((record).total_time),
max((record).self_time))::@[email protected]_user_functions_history_record
FROM @[email protected]_user_functions_history_current_db
WHERE srvid = _srvid
GROUP BY srvid, dbid;

GET DIAGNOSTICS v_rowcount = ROW_COUNT;
PERFORM @[email protected]_log(format('%s - (powa_user_functions_history_current_db) rowcount: %s',
v_funcname, v_rowcount));

DELETE FROM @[email protected]_user_functions_history_current_db WHERE srvid = _srvid;
END;
$PROC$ LANGUAGE plpgsql
SET search_path = pg_catalog; /* end of powa_user_functions_aggregate */


2 changes: 1 addition & 1 deletion powa--5.0.2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5772,7 +5772,7 @@ BEGIN
min((record).self_time))::@[email protected]_user_functions_history_record,
ROW(max((record).ts), max((record).calls),max((record).total_time),
max((record).self_time))::@[email protected]_user_functions_history_record
FROM @extschema@.powa_user_functions_history_current
FROM @extschema@.powa_user_functions_history_current_db
WHERE srvid = _srvid
GROUP BY srvid, dbid;

Expand Down

0 comments on commit 8400305

Please sign in to comment.