Age Owner Branch data TLA Line data Source code
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-2026, PostgreSQL Global Development Group
9 : : *
10 : : * src/include/utils/pgstat_kind.h
11 : : * ----------
12 : : */
13 : : #ifndef PGSTAT_KIND_H
14 : : #define PGSTAT_KIND_H
15 : :
16 : : /* The types of statistics entries */
17 : : #define PgStat_Kind uint32
18 : :
19 : : /* Range of IDs allowed, for built-in and custom kinds */
20 : : #define PGSTAT_KIND_MIN 1 /* Minimum ID allowed */
21 : : #define PGSTAT_KIND_MAX 32 /* Maximum ID allowed */
22 : :
23 : : /* use 0 for INVALID, to catch zero-initialized data */
24 : : #define PGSTAT_KIND_INVALID 0
25 : :
26 : : /* stats for variable-numbered objects */
27 : : #define PGSTAT_KIND_DATABASE 1 /* database-wide statistics */
28 : : #define PGSTAT_KIND_RELATION 2 /* per-table statistics */
29 : : #define PGSTAT_KIND_FUNCTION 3 /* per-function statistics */
30 : : #define PGSTAT_KIND_REPLSLOT 4 /* per-slot statistics */
31 : : #define PGSTAT_KIND_SUBSCRIPTION 5 /* per-subscription statistics */
32 : : #define PGSTAT_KIND_BACKEND 6 /* per-backend statistics */
33 : :
34 : : /* stats for fixed-numbered objects */
35 : : #define PGSTAT_KIND_ARCHIVER 7
36 : : #define PGSTAT_KIND_BGWRITER 8
37 : : #define PGSTAT_KIND_CHECKPOINTER 9
38 : : #define PGSTAT_KIND_IO 10
39 : : #define PGSTAT_KIND_LOCK 11
40 : : #define PGSTAT_KIND_SLRU 12
41 : : #define PGSTAT_KIND_WAL 13
42 : :
43 : : #define PGSTAT_KIND_BUILTIN_MIN PGSTAT_KIND_DATABASE
44 : : #define PGSTAT_KIND_BUILTIN_MAX PGSTAT_KIND_WAL
45 : : #define PGSTAT_KIND_BUILTIN_SIZE (PGSTAT_KIND_BUILTIN_MAX + 1)
46 : :
47 : : /* Custom stats kinds */
48 : :
49 : : /* Range of IDs allowed for custom stats kinds */
50 : : #define PGSTAT_KIND_CUSTOM_MIN 24
51 : : #define PGSTAT_KIND_CUSTOM_MAX PGSTAT_KIND_MAX
52 : : #define PGSTAT_KIND_CUSTOM_SIZE (PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1)
53 : :
54 : : /*
55 : : * PgStat_Kind to use for extensions that require an ID, but are still in
56 : : * development and have not reserved their own unique kind ID yet. See:
57 : : * https://wiki.postgresql.org/wiki/CustomCumulativeStats
58 : : */
59 : : #define PGSTAT_KIND_EXPERIMENTAL 24
60 : :
61 : : static inline bool
476 michael@paquier.xyz 62 :CBC 11474488 : pgstat_is_kind_builtin(PgStat_Kind kind)
63 : : {
64 [ + - + + ]: 11474488 : return kind >= PGSTAT_KIND_BUILTIN_MIN && kind <= PGSTAT_KIND_BUILTIN_MAX;
65 : : }
66 : :
67 : : static inline bool
68 : 1475814 : pgstat_is_kind_custom(PgStat_Kind kind)
69 : : {
70 [ + + + - ]: 1475814 : return kind >= PGSTAT_KIND_CUSTOM_MIN && kind <= PGSTAT_KIND_CUSTOM_MAX;
71 : : }
72 : :
73 : : #endif /* PGSTAT_KIND_H */
|