LCOV - code coverage report
Current view: top level - src/include/utils - pgstat_kind.h (source / functions) Coverage Total Hit
Test: Code coverage Lines: 100.0 % 4 4
Test Date: 2026-01-26 10:56:24 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 75.0 % 4 3

             Branch data     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_SLRU        11
      40                 :             : #define PGSTAT_KIND_WAL 12
      41                 :             : 
      42                 :             : #define PGSTAT_KIND_BUILTIN_MIN PGSTAT_KIND_DATABASE
      43                 :             : #define PGSTAT_KIND_BUILTIN_MAX PGSTAT_KIND_WAL
      44                 :             : #define PGSTAT_KIND_BUILTIN_SIZE (PGSTAT_KIND_BUILTIN_MAX + 1)
      45                 :             : 
      46                 :             : /* Custom stats kinds */
      47                 :             : 
      48                 :             : /* Range of IDs allowed for custom stats kinds */
      49                 :             : #define PGSTAT_KIND_CUSTOM_MIN  24
      50                 :             : #define PGSTAT_KIND_CUSTOM_MAX  PGSTAT_KIND_MAX
      51                 :             : #define PGSTAT_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                 :             : #define PGSTAT_KIND_EXPERIMENTAL        24
      59                 :             : 
      60                 :             : static inline bool
      61                 :      457304 : pgstat_is_kind_builtin(PgStat_Kind kind)
      62                 :             : {
      63         [ -  + ]:      457304 :         return kind >= PGSTAT_KIND_BUILTIN_MIN && kind <= PGSTAT_KIND_BUILTIN_MAX;
      64                 :             : }
      65                 :             : 
      66                 :             : static inline bool
      67                 :       47449 : pgstat_is_kind_custom(PgStat_Kind kind)
      68                 :             : {
      69         [ +  + ]:       47449 :         return kind >= PGSTAT_KIND_CUSTOM_MIN && kind <= PGSTAT_KIND_CUSTOM_MAX;
      70                 :             : }
      71                 :             : 
      72                 :             : #endif                                                  /* PGSTAT_KIND_H */
        

Generated by: LCOV version 2.3.2-1