-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix typo in collection of aggregate of functions per DB (#101)
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|