Format code
parent
122a30c82b
commit
2af9ae7a4a
|
@ -303,7 +303,7 @@ hash_entry_alloc(pgsmSharedState * pgsm, pgsmHashKey * key, int encoding)
|
||||||
memset(&entry->counters, 0, sizeof(Counters));
|
memset(&entry->counters, 0, sizeof(Counters));
|
||||||
entry->query_text.query_pos = InvalidDsaPointer;
|
entry->query_text.query_pos = InvalidDsaPointer;
|
||||||
entry->counters.info.parent_query = InvalidDsaPointer;
|
entry->counters.info.parent_query = InvalidDsaPointer;
|
||||||
entry->stats_since = GetCurrentTimestamp();
|
entry->stats_since = GetCurrentTimestamp();
|
||||||
entry->minmax_stats_since = entry->stats_since;
|
entry->minmax_stats_since = entry->stats_since;
|
||||||
|
|
||||||
/* set the appropriate initial usage count */
|
/* set the appropriate initial usage count */
|
||||||
|
|
|
@ -1362,9 +1362,10 @@ pgsm_update_entry(pgsmEntry * entry,
|
||||||
int plan_text_len = plan_info ? plan_info->plan_len : 0;
|
int plan_text_len = plan_info ? plan_info->plan_len : 0;
|
||||||
|
|
||||||
/* Start collecting data for next bucket and reset all counters and timestamps */
|
/* Start collecting data for next bucket and reset all counters and timestamps */
|
||||||
if (reset) {
|
if (reset)
|
||||||
|
{
|
||||||
memset(&entry->counters, 0, sizeof(Counters));
|
memset(&entry->counters, 0, sizeof(Counters));
|
||||||
entry->stats_since = GetCurrentTimestamp();
|
entry->stats_since = GetCurrentTimestamp();
|
||||||
entry->minmax_stats_since = entry->stats_since;
|
entry->minmax_stats_since = entry->stats_since;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2050,7 +2051,7 @@ IsBucketValid(uint64 bucketid)
|
||||||
|
|
||||||
TimestampDifference(pgsm->bucket_start_time[bucketid], current_tz, &secs, µsecs);
|
TimestampDifference(pgsm->bucket_start_time[bucketid], current_tz, &secs, µsecs);
|
||||||
|
|
||||||
if (secs > ((int64)pgsm_bucket_time * pgsm_max_buckets))
|
if (secs > ((int64) pgsm_bucket_time * pgsm_max_buckets))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2070,8 +2071,9 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
pgsmEntry *entry;
|
pgsmEntry *entry;
|
||||||
pgsmSharedState *pgsm;
|
pgsmSharedState *pgsm;
|
||||||
|
|
||||||
int expected_columns;
|
int expected_columns;
|
||||||
switch (api_version) {
|
switch (api_version)
|
||||||
|
{
|
||||||
case PGSM_V1_0:
|
case PGSM_V1_0:
|
||||||
expected_columns = PG_STAT_MONITOR_COLS_V1_0;
|
expected_columns = PG_STAT_MONITOR_COLS_V1_0;
|
||||||
break;
|
break;
|
||||||
|
@ -2083,8 +2085,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
|
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disallow old api usage */
|
/* Disallow old api usage */
|
||||||
|
|
|
@ -370,15 +370,15 @@ typedef struct Counters
|
||||||
*/
|
*/
|
||||||
typedef struct pgsmEntry
|
typedef struct pgsmEntry
|
||||||
{
|
{
|
||||||
pgsmHashKey key; /* hash key of entry - MUST BE FIRST */
|
pgsmHashKey key; /* hash key of entry - MUST BE FIRST */
|
||||||
uint64 pgsm_query_id; /* pgsm generate normalized query hash */
|
uint64 pgsm_query_id; /* pgsm generate normalized query hash */
|
||||||
char datname[NAMEDATALEN]; /* database name */
|
char datname[NAMEDATALEN]; /* database name */
|
||||||
char username[NAMEDATALEN]; /* user name */
|
char username[NAMEDATALEN]; /* user name */
|
||||||
Counters counters; /* the statistics for this query */
|
Counters counters; /* the statistics for this query */
|
||||||
int encoding; /* query text encoding */
|
int encoding; /* query text encoding */
|
||||||
TimestampTz stats_since; /* timestamp of entry allocation */
|
TimestampTz stats_since; /* timestamp of entry allocation */
|
||||||
TimestampTz minmax_stats_since; /* timestamp of last min/max values reset */
|
TimestampTz minmax_stats_since; /* timestamp of last min/max values reset */
|
||||||
slock_t mutex; /* protects the counters only */
|
slock_t mutex; /* protects the counters only */
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
dsa_pointer query_pos; /* query location within query buffer */
|
dsa_pointer query_pos; /* query location within query buffer */
|
||||||
|
|
Loading…
Reference in New Issue