Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3188a45

Browse files
committed
Switch PgStat_Kind from an enum to a uint32 type
A follow-up patch is planned to make cumulative statistics pluggable,and using a type is useful in the internal routines used by pgstats asPgStat_Kind may have a value that was not originally in the enum removedhere, once made pluggable.While on it, this commit switches pgstat_is_kind_valid() to usePgStat_Kind rather than an int, to be more consistent with its existingcallers. Some loops based on the stats kind IDs are switched to usePgStat_Kind rather than int, for consistency with the new time.Author: Michael PaquierReviewed-by: Dmitry Dolgov, Bertrand DrouvotDiscussion:https://postgr.es/m/Zmqm9j5EO0I4W8dx@paquier.xyz
1 parentb860848 commit3188a45

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

‎src/backend/utils/activity/pgstat.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void pgstat_prep_snapshot(void);
183183
staticvoidpgstat_build_snapshot(void);
184184
staticvoidpgstat_build_snapshot_fixed(PgStat_Kindkind);
185185

186-
staticinlineboolpgstat_is_kind_valid(intikind);
186+
staticinlineboolpgstat_is_kind_valid(PgStat_Kindkind);
187187

188188

189189
/* ----------
@@ -1089,7 +1089,7 @@ pgstat_build_snapshot(void)
10891089
/*
10901090
* Build snapshot of all fixed-numbered stats.
10911091
*/
1092-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
1092+
for (PgStat_Kindkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
10931093
{
10941094
constPgStat_KindInfo*kind_info=pgstat_get_kind_info(kind);
10951095

@@ -1286,7 +1286,7 @@ pgstat_flush_pending_entries(bool nowait)
12861286
PgStat_Kind
12871287
pgstat_get_kind_from_str(char*kind_str)
12881288
{
1289-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
1289+
for (PgStat_Kindkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
12901290
{
12911291
if (pg_strcasecmp(kind_str,pgstat_kind_infos[kind].name)==0)
12921292
returnkind;
@@ -1299,9 +1299,9 @@ pgstat_get_kind_from_str(char *kind_str)
12991299
}
13001300

13011301
staticinlinebool
1302-
pgstat_is_kind_valid(intikind)
1302+
pgstat_is_kind_valid(PgStat_Kindkind)
13031303
{
1304-
returnikind >=PGSTAT_KIND_FIRST_VALID&&ikind <=PGSTAT_KIND_LAST;
1304+
returnkind >=PGSTAT_KIND_FIRST_VALID&&kind <=PGSTAT_KIND_LAST;
13051305
}
13061306

13071307
constPgStat_KindInfo*
@@ -1393,7 +1393,7 @@ pgstat_write_statsfile(XLogRecPtr redo)
13931393
write_chunk_s(fpout,&redo);
13941394

13951395
/* Write various stats structs for fixed number of objects */
1396-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
1396+
for (PgStat_Kindkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
13971397
{
13981398
char*ptr;
13991399
constPgStat_KindInfo*info=pgstat_get_kind_info(kind);
@@ -1777,7 +1777,7 @@ pgstat_reset_after_failure(void)
17771777
TimestampTzts=GetCurrentTimestamp();
17781778

17791779
/* reset fixed-numbered stats */
1780-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
1780+
for (PgStat_Kindkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
17811781
{
17821782
constPgStat_KindInfo*kind_info=pgstat_get_kind_info(kind);
17831783

‎src/backend/utils/activity/pgstat_shmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ StatsShmemInit(void)
197197
pg_atomic_init_u64(&ctl->gc_request_count,1);
198198

199199
/* initialize fixed-numbered stats */
200-
for (intkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
200+
for (PgStat_Kindkind=PGSTAT_KIND_FIRST_VALID;kind <=PGSTAT_KIND_LAST;kind++)
201201
{
202202
constPgStat_KindInfo*kind_info=pgstat_get_kind_info(kind);
203203
char*ptr;

‎src/include/pgstat.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,25 @@
3333
#definePG_STAT_TMP_DIR"pg_stat_tmp"
3434

3535
/* The types of statistics entries */
36-
typedefenumPgStat_Kind
37-
{
38-
/* use 0 for INVALID, to catch zero-initialized data */
39-
PGSTAT_KIND_INVALID=0,
40-
41-
/* stats for variable-numbered objects */
42-
PGSTAT_KIND_DATABASE,/* database-wide statistics */
43-
PGSTAT_KIND_RELATION,/* per-table statistics */
44-
PGSTAT_KIND_FUNCTION,/* per-function statistics */
45-
PGSTAT_KIND_REPLSLOT,/* per-slot statistics */
46-
PGSTAT_KIND_SUBSCRIPTION,/* per-subscription statistics */
47-
48-
/* stats for fixed-numbered objects */
49-
PGSTAT_KIND_ARCHIVER,
50-
PGSTAT_KIND_BGWRITER,
51-
PGSTAT_KIND_CHECKPOINTER,
52-
PGSTAT_KIND_IO,
53-
PGSTAT_KIND_SLRU,
54-
PGSTAT_KIND_WAL,
55-
}PgStat_Kind;
36+
#definePgStat_Kind uint32
37+
38+
/* use 0 for INVALID, to catch zero-initialized data */
39+
#definePGSTAT_KIND_INVALID 0
40+
41+
/* stats for variable-numbered objects */
42+
#definePGSTAT_KIND_DATABASE1/* database-wide statistics */
43+
#definePGSTAT_KIND_RELATION2/* per-table statistics */
44+
#definePGSTAT_KIND_FUNCTION3/* per-function statistics */
45+
#definePGSTAT_KIND_REPLSLOT4/* per-slot statistics */
46+
#definePGSTAT_KIND_SUBSCRIPTION5/* per-subscription statistics */
47+
48+
/* stats for fixed-numbered objects */
49+
#definePGSTAT_KIND_ARCHIVER6
50+
#definePGSTAT_KIND_BGWRITER7
51+
#definePGSTAT_KIND_CHECKPOINTER8
52+
#definePGSTAT_KIND_IO9
53+
#definePGSTAT_KIND_SLRU10
54+
#definePGSTAT_KIND_WAL11
5655

5756
#definePGSTAT_KIND_FIRST_VALID PGSTAT_KIND_DATABASE
5857
#definePGSTAT_KIND_LAST PGSTAT_KIND_WAL

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp