PG-161: Miscellaneous small issues.
parent
84de947da6
commit
a297ac19ea
|
@ -93,13 +93,13 @@ FROM pg_stat_monitor_settings();
|
||||||
CREATE VIEW pg_stat_monitor AS SELECT
|
CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
bucket,
|
bucket,
|
||||||
bucket_start_time AS bucket_start_time,
|
bucket_start_time AS bucket_start_time,
|
||||||
userid,
|
userid::regrole,
|
||||||
dbid,
|
datname,
|
||||||
'0.0.0.0'::inet + client_ip AS client_ip,
|
'0.0.0.0'::inet + client_ip AS client_ip,
|
||||||
queryid,
|
queryid,
|
||||||
query,
|
query,
|
||||||
application_name,
|
application_name,
|
||||||
(string_to_array(relations, ',')) AS relations,
|
(string_to_array(relations, ','))::oid[]::regclass[] AS relations,
|
||||||
CASE
|
CASE
|
||||||
WHEN query like 'BEGIN' THEN ''
|
WHEN query like 'BEGIN' THEN ''
|
||||||
WHEN query like 'END' THEN ''
|
WHEN query like 'END' THEN ''
|
||||||
|
@ -110,7 +110,7 @@ CREATE VIEW pg_stat_monitor AS SELECT
|
||||||
message,
|
message,
|
||||||
plans,
|
plans,
|
||||||
round( CAST(plan_total_time as numeric), 2)::float8 as plan_total_time,
|
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_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_mean_time as numeric), 2)::float8 as plan_mean_time,
|
||||||
round( CAST(plan_stddev_time as numeric), 2)::float8 as plan_stddev_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,
|
(string_to_array(resp_calls, ',')) resp_calls,
|
||||||
cpu_user_time,
|
cpu_user_time,
|
||||||
cpu_sys_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)
|
CREATE FUNCTION decode_error_level(elevel int)
|
||||||
RETURNS text
|
RETURNS text
|
||||||
|
|
|
@ -401,6 +401,7 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
|
||||||
float utime;
|
float utime;
|
||||||
float stime;
|
float stime;
|
||||||
uint64 queryId = queryDesc->plannedstmt->queryId;
|
uint64 queryId = queryDesc->plannedstmt->queryId;
|
||||||
|
pgssSharedState *pgss = pgsm_get_ss();
|
||||||
|
|
||||||
if (queryId != UINT64CONST(0) && queryDesc->totaltime)
|
if (queryId != UINT64CONST(0) && queryDesc->totaltime)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +438,8 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
|
||||||
prev_ExecutorEnd(queryDesc);
|
prev_ExecutorEnd(queryDesc);
|
||||||
else
|
else
|
||||||
standard_ExecutorEnd(queryDesc);
|
standard_ExecutorEnd(queryDesc);
|
||||||
|
memset(pgss->relations, 0x0, sizeof(pgss->relations));
|
||||||
|
memset(pgss->cmdTag, 0x0, sizeof(pgss->cmdTag));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -450,6 +452,7 @@ pgss_ExecutorCheckPerms(List *rt, bool abort)
|
||||||
|
|
||||||
LWLockAcquire(pgss->lock, LW_EXCLUSIVE);
|
LWLockAcquire(pgss->lock, LW_EXCLUSIVE);
|
||||||
memset(pgss->cmdTag, 0x0, sizeof(pgss->cmdTag));
|
memset(pgss->cmdTag, 0x0, sizeof(pgss->cmdTag));
|
||||||
|
memset(pgss->relations, 0x0, sizeof(pgss->relations));
|
||||||
|
|
||||||
foreach(lr, rt)
|
foreach(lr, rt)
|
||||||
{
|
{
|
||||||
|
@ -838,10 +841,7 @@ static void pgss_store(uint64 queryId,
|
||||||
|
|
||||||
/* Set up key for hashtable search */
|
/* Set up key for hashtable search */
|
||||||
key.bucket_id = bucket_id;
|
key.bucket_id = bucket_id;
|
||||||
if (elevel == 0)
|
|
||||||
key.userid = GetUserId();
|
key.userid = GetUserId();
|
||||||
else
|
|
||||||
key.userid = 1;
|
|
||||||
key.dbid = MyDatabaseId;
|
key.dbid = MyDatabaseId;
|
||||||
key.queryid = queryId;
|
key.queryid = queryId;
|
||||||
key.ip = pg_get_client_addr();
|
key.ip = pg_get_client_addr();
|
||||||
|
@ -947,6 +947,7 @@ static void pgss_store(uint64 queryId,
|
||||||
for (i = 0; i < application_name_len; i++)
|
for (i = 0; i < application_name_len; i++)
|
||||||
e->counters.info.application_name[i] = application_name[i];
|
e->counters.info.application_name[i] = application_name[i];
|
||||||
|
|
||||||
|
found = false;
|
||||||
for (i = 0; i < REL_LST; i++)
|
for (i = 0; i < REL_LST; i++)
|
||||||
if (e->counters.info.relations[i] != 0)
|
if (e->counters.info.relations[i] != 0)
|
||||||
found = true;
|
found = true;
|
||||||
|
|
Loading…
Reference in New Issue