From 2af9ae7a4ac39829676b6161c85d571ec1db636c Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Thu, 6 Jun 2024 16:43:38 +0200 Subject: [PATCH] Format code --- hash_query.c | 2 +- pg_stat_monitor.c | 18 ++++++++++-------- pg_stat_monitor.h | 14 +++++++------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/hash_query.c b/hash_query.c index 7383de3..c9021e3 100644 --- a/hash_query.c +++ b/hash_query.c @@ -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 */ diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index 6f930de..a224caa 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -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, µsecs); - 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 */ diff --git a/pg_stat_monitor.h b/pg_stat_monitor.h index 1658852..4d21536 100644 --- a/pg_stat_monitor.h +++ b/pg_stat_monitor.h @@ -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 */