Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Jun 6, 2024
1 parent 122a30c commit 2af9ae7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion hash_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
18 changes: 10 additions & 8 deletions pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -2083,8 +2085,8 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
break;
default:
ereport(ERROR,

Check warning on line 2087 in pg_stat_monitor.c

View check run for this annotation

Codecov / codecov/patch

pg_stat_monitor.c#L2086-L2087

Added lines #L2086 - L2087 were not covered by tests
(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 */
Expand Down
14 changes: 7 additions & 7 deletions pg_stat_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2af9ae7

Please sign in to comment.