Format code

pull/463/head
Artem Gavrilov 2024-06-06 16:43:38 +02:00
parent 122a30c82b
commit 2af9ae7a4a
3 changed files with 18 additions and 16 deletions

View File

@ -303,7 +303,7 @@ hash_entry_alloc(pgsmSharedState * pgsm, pgsmHashKey * key, int encoding)
memset(&entry->counters, 0, sizeof(Counters));
entry->query_text.query_pos = InvalidDsaPointer;
entry->counters.info.parent_query = InvalidDsaPointer;
entry->stats_since = GetCurrentTimestamp();
entry->stats_since = GetCurrentTimestamp();
entry->minmax_stats_since = entry->stats_since;
/* set the appropriate initial usage count */

View File

@ -1362,9 +1362,10 @@ pgsm_update_entry(pgsmEntry * entry,
int plan_text_len = plan_info ? plan_info->plan_len : 0;
/* Start collecting data for next bucket and reset all counters and timestamps */
if (reset) {
if (reset)
{
memset(&entry->counters, 0, sizeof(Counters));
entry->stats_since = GetCurrentTimestamp();
entry->stats_since = GetCurrentTimestamp();
entry->minmax_stats_since = entry->stats_since;
}
@ -2050,7 +2051,7 @@ IsBucketValid(uint64 bucketid)
TimestampDifference(pgsm->bucket_start_time[bucketid], current_tz, &secs, &microsecs);
if (secs > ((int64)pgsm_bucket_time * pgsm_max_buckets))
if (secs > ((int64) pgsm_bucket_time * pgsm_max_buckets))
return false;
return true;
}
@ -2069,9 +2070,10 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
PGSM_HASH_SEQ_STATUS hstat;
pgsmEntry *entry;
pgsmSharedState *pgsm;
int expected_columns;
switch (api_version) {
int expected_columns;
switch (api_version)
{
case PGSM_V1_0:
expected_columns = PG_STAT_MONITOR_COLS_V1_0;
break;
@ -2083,8 +2085,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
break;
default:
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
}
/* Disallow old api usage */

View File

@ -370,15 +370,15 @@ typedef struct Counters
*/
typedef struct pgsmEntry
{
pgsmHashKey key; /* hash key of entry - MUST BE FIRST */
uint64 pgsm_query_id; /* pgsm generate normalized query hash */
pgsmHashKey key; /* hash key of entry - MUST BE FIRST */
uint64 pgsm_query_id; /* pgsm generate normalized query hash */
char datname[NAMEDATALEN]; /* database name */
char username[NAMEDATALEN]; /* user name */
Counters counters; /* the statistics for this query */
int encoding; /* query text encoding */
TimestampTz stats_since; /* timestamp of entry allocation */
TimestampTz minmax_stats_since; /* timestamp of last min/max values reset */
slock_t mutex; /* protects the counters only */
Counters counters; /* the statistics for this query */
int encoding; /* query text encoding */
TimestampTz stats_since; /* timestamp of entry allocation */
TimestampTz minmax_stats_since; /* timestamp of last min/max values reset */
slock_t mutex; /* protects the counters only */
union
{
dsa_pointer query_pos; /* query location within query buffer */