PG-161: Miscellaneous small issues.

pull/70/head
Ibrar Ahmed 2021-01-12 07:47:22 +00:00
parent 84de947da6
commit a297ac19ea
2 changed files with 11 additions and 10 deletions

View File

@ -93,13 +93,13 @@ FROM pg_stat_monitor_settings();
CREATE VIEW pg_stat_monitor AS SELECT
bucket,
bucket_start_time AS bucket_start_time,
userid,
dbid,
userid::regrole,
datname,
'0.0.0.0'::inet + client_ip AS client_ip,
queryid,
query,
application_name,
(string_to_array(relations, ',')) AS relations,
(string_to_array(relations, ','))::oid[]::regclass[] AS relations,
CASE
WHEN query like 'BEGIN' THEN ''
WHEN query like 'END' THEN ''
@ -110,7 +110,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
message,
plans,
round( CAST(plan_total_time as numeric), 2)::float8 as plan_total_time,
round( CAST(plan_min_time as numeric), 2)::float8 as plan_min_timei,
round( CAST(plan_min_time as numeric), 2)::float8 as plan_min_time,
round( CAST(plan_max_time as numeric), 2)::float8 as plan_max_time,
round( CAST(plan_mean_time as numeric), 2)::float8 as plan_mean_time,
round( CAST(plan_stddev_time as numeric), 2)::float8 as plan_stddev_time,
@ -136,7 +136,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time
FROM pg_stat_monitor(TRUE);
FROM pg_stat_monitor(TRUE), pg_database WHERE dbid = oid;
CREATE FUNCTION decode_error_level(elevel int)
RETURNS text

View File

@ -401,6 +401,7 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
float utime;
float stime;
uint64 queryId = queryDesc->plannedstmt->queryId;
pgssSharedState *pgss = pgsm_get_ss();
if (queryId != UINT64CONST(0) && queryDesc->totaltime)
{
@ -437,7 +438,8 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
prev_ExecutorEnd(queryDesc);
else
standard_ExecutorEnd(queryDesc);
memset(pgss->relations, 0x0, sizeof(pgss->relations));
memset(pgss->cmdTag, 0x0, sizeof(pgss->cmdTag));
}
static bool
@ -450,6 +452,7 @@ pgss_ExecutorCheckPerms(List *rt, bool abort)
LWLockAcquire(pgss->lock, LW_EXCLUSIVE);
memset(pgss->cmdTag, 0x0, sizeof(pgss->cmdTag));
memset(pgss->relations, 0x0, sizeof(pgss->relations));
foreach(lr, rt)
{
@ -838,10 +841,7 @@ static void pgss_store(uint64 queryId,
/* Set up key for hashtable search */
key.bucket_id = bucket_id;
if (elevel == 0)
key.userid = GetUserId();
else
key.userid = 1;
key.userid = GetUserId();
key.dbid = MyDatabaseId;
key.queryid = queryId;
key.ip = pg_get_client_addr();
@ -947,6 +947,7 @@ static void pgss_store(uint64 queryId,
for (i = 0; i < application_name_len; i++)
e->counters.info.application_name[i] = application_name[i];
found = false;
for (i = 0; i < REL_LST; i++)
if (e->counters.info.relations[i] != 0)
found = true;