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

Commitd35ea27

Browse files
committed
Move information about pgstats kinds into its own header pgstat_kind.h
This includes all the definitions for the various PGSTAT_KIND_* values,the range allowed for custom stats kinds and some macros related allthat.One use-case behind this split is the possibility to use thisinformation for frontend tools, without having to rely on pgstat.h and abackend footprint.Author: Michael PaquierReviewed-by: Bertrand DrouvotDiscussion:https://postgr.es/m/Z24fyb3ipXKR38oS@paquier.xyz
1 parentd2181b3 commitd35ea27

File tree

2 files changed

+73
-56
lines changed

2 files changed

+73
-56
lines changed

‎src/include/pgstat.h

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"replication/conflict.h"
1919
#include"utils/backend_progress.h"/* for backward compatibility */
2020
#include"utils/backend_status.h"/* for backward compatibility */
21+
#include"utils/pgstat_kind.h"
2122
#include"utils/relcache.h"
2223
#include"utils/wait_event.h"/* for backward compatibility */
2324

@@ -33,62 +34,6 @@
3334
/* Default directory to store temporary statistics data in */
3435
#definePG_STAT_TMP_DIR"pg_stat_tmp"
3536

36-
/* The types of statistics entries */
37-
#definePgStat_Kind uint32
38-
39-
/* Range of IDs allowed, for built-in and custom kinds */
40-
#definePGSTAT_KIND_MIN1/* Minimum ID allowed */
41-
#definePGSTAT_KIND_MAX256/* Maximum ID allowed */
42-
43-
/* use 0 for INVALID, to catch zero-initialized data */
44-
#definePGSTAT_KIND_INVALID 0
45-
46-
/* stats for variable-numbered objects */
47-
#definePGSTAT_KIND_DATABASE1/* database-wide statistics */
48-
#definePGSTAT_KIND_RELATION2/* per-table statistics */
49-
#definePGSTAT_KIND_FUNCTION3/* per-function statistics */
50-
#definePGSTAT_KIND_REPLSLOT4/* per-slot statistics */
51-
#definePGSTAT_KIND_SUBSCRIPTION5/* per-subscription statistics */
52-
#definePGSTAT_KIND_BACKEND6/* per-backend statistics */
53-
54-
/* stats for fixed-numbered objects */
55-
#definePGSTAT_KIND_ARCHIVER7
56-
#definePGSTAT_KIND_BGWRITER8
57-
#definePGSTAT_KIND_CHECKPOINTER9
58-
#definePGSTAT_KIND_IO10
59-
#definePGSTAT_KIND_SLRU11
60-
#definePGSTAT_KIND_WAL12
61-
62-
#definePGSTAT_KIND_BUILTIN_MIN PGSTAT_KIND_DATABASE
63-
#definePGSTAT_KIND_BUILTIN_MAX PGSTAT_KIND_WAL
64-
#definePGSTAT_KIND_BUILTIN_SIZE (PGSTAT_KIND_BUILTIN_MAX + 1)
65-
66-
/* Custom stats kinds */
67-
68-
/* Range of IDs allowed for custom stats kinds */
69-
#definePGSTAT_KIND_CUSTOM_MIN128
70-
#definePGSTAT_KIND_CUSTOM_MAXPGSTAT_KIND_MAX
71-
#definePGSTAT_KIND_CUSTOM_SIZE(PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1)
72-
73-
/*
74-
* PgStat_Kind to use for extensions that require an ID, but are still in
75-
* development and have not reserved their own unique kind ID yet. See:
76-
* https://wiki.postgresql.org/wiki/CustomCumulativeStats
77-
*/
78-
#definePGSTAT_KIND_EXPERIMENTAL128
79-
80-
staticinlinebool
81-
pgstat_is_kind_builtin(PgStat_Kindkind)
82-
{
83-
returnkind >=PGSTAT_KIND_BUILTIN_MIN&&kind <=PGSTAT_KIND_BUILTIN_MAX;
84-
}
85-
86-
staticinlinebool
87-
pgstat_is_kind_custom(PgStat_Kindkind)
88-
{
89-
returnkind >=PGSTAT_KIND_CUSTOM_MIN&&kind <=PGSTAT_KIND_CUSTOM_MAX;
90-
}
91-
9237
/* Values for track_functions GUC variable --- order is significant! */
9338
typedefenumTrackFunctionsLevel
9439
{

‎src/include/utils/pgstat_kind.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* ----------
2+
*pgstat_kind.h
3+
*
4+
*Definitions related to the statistics kinds for the PostgreSQL
5+
*cumulative statistics system. Can be included in backend or
6+
*frontend code.
7+
*
8+
*Copyright (c) 2001-2025, PostgreSQL Global Development Group
9+
*
10+
*src/include/utils/pgstat_kind.h
11+
* ----------
12+
*/
13+
#ifndefPGSTAT_KIND_H
14+
#definePGSTAT_KIND_H
15+
16+
/* The types of statistics entries */
17+
#definePgStat_Kind uint32
18+
19+
/* Range of IDs allowed, for built-in and custom kinds */
20+
#definePGSTAT_KIND_MIN1/* Minimum ID allowed */
21+
#definePGSTAT_KIND_MAX256/* Maximum ID allowed */
22+
23+
/* use 0 for INVALID, to catch zero-initialized data */
24+
#definePGSTAT_KIND_INVALID 0
25+
26+
/* stats for variable-numbered objects */
27+
#definePGSTAT_KIND_DATABASE1/* database-wide statistics */
28+
#definePGSTAT_KIND_RELATION2/* per-table statistics */
29+
#definePGSTAT_KIND_FUNCTION3/* per-function statistics */
30+
#definePGSTAT_KIND_REPLSLOT4/* per-slot statistics */
31+
#definePGSTAT_KIND_SUBSCRIPTION5/* per-subscription statistics */
32+
#definePGSTAT_KIND_BACKEND6/* per-backend statistics */
33+
34+
/* stats for fixed-numbered objects */
35+
#definePGSTAT_KIND_ARCHIVER7
36+
#definePGSTAT_KIND_BGWRITER8
37+
#definePGSTAT_KIND_CHECKPOINTER9
38+
#definePGSTAT_KIND_IO10
39+
#definePGSTAT_KIND_SLRU11
40+
#definePGSTAT_KIND_WAL12
41+
42+
#definePGSTAT_KIND_BUILTIN_MIN PGSTAT_KIND_DATABASE
43+
#definePGSTAT_KIND_BUILTIN_MAX PGSTAT_KIND_WAL
44+
#definePGSTAT_KIND_BUILTIN_SIZE (PGSTAT_KIND_BUILTIN_MAX + 1)
45+
46+
/* Custom stats kinds */
47+
48+
/* Range of IDs allowed for custom stats kinds */
49+
#definePGSTAT_KIND_CUSTOM_MIN128
50+
#definePGSTAT_KIND_CUSTOM_MAXPGSTAT_KIND_MAX
51+
#definePGSTAT_KIND_CUSTOM_SIZE(PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1)
52+
53+
/*
54+
* PgStat_Kind to use for extensions that require an ID, but are still in
55+
* development and have not reserved their own unique kind ID yet. See:
56+
* https://wiki.postgresql.org/wiki/CustomCumulativeStats
57+
*/
58+
#definePGSTAT_KIND_EXPERIMENTAL128
59+
60+
staticinlinebool
61+
pgstat_is_kind_builtin(PgStat_Kindkind)
62+
{
63+
returnkind >=PGSTAT_KIND_BUILTIN_MIN&&kind <=PGSTAT_KIND_BUILTIN_MAX;
64+
}
65+
66+
staticinlinebool
67+
pgstat_is_kind_custom(PgStat_Kindkind)
68+
{
69+
returnkind >=PGSTAT_KIND_CUSTOM_MIN&&kind <=PGSTAT_KIND_CUSTOM_MAX;
70+
}
71+
72+
#endif/* PGSTAT_KIND_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp