LCOV - code coverage report
Current view: top level - src/backend/utils/activity - pgstat_kind.c (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 100.0 % 21 21
Test Date: 2026-10-29 00:16:02 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 100.0 % 6 6

             Branch data     Line data    Source code
       1                 :             : /*-------------------------------------------------------------------------
       2                 :             :  *
       3                 :             :  * pgstat_kind.c
       4                 :             :  *    Functions related to statistics kinds.
       5                 :             :  *
       6                 :             :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
       7                 :             :  * Portions Copyright (c) 1994, Regents of the University of California
       8                 :             :  *
       9                 :             :  *
      10                 :             :  * IDENTIFICATION
      11                 :             :  *    src/backend/utils/activity/pgstat_kind.c
      12                 :             :  *
      13                 :             :  *-------------------------------------------------------------------------
      14                 :             :  */
      15                 :             : #include "postgres.h"
      16                 :             : 
      17                 :             : #include "fmgr.h"
      18                 :             : #include "funcapi.h"
      19                 :             : #include "utils/builtins.h"
      20                 :             : #include "utils/fmgrprotos.h"
      21                 :             : #include "utils/pgstat_internal.h"
      22                 :             : #include "utils/pgstat_kind.h"
      23                 :             : #include "utils/tuplestore.h"
      24                 :             : 
      25                 :             : 
      26                 :             : /*
      27                 :             :  * pg_stat_get_kind_info
      28                 :             :  *
      29                 :             :  * Get information about the statistics kinds registered into the system.
      30                 :             :  */
      31                 :             : Datum
      32                 :           7 : pg_stat_get_kind_info(PG_FUNCTION_ARGS)
      33                 :             : {
      34                 :             : #define PG_STAT_KIND_INFO_COLS  8
      35                 :             :     ReturnSetInfo *rsinfo;
      36                 :             : 
      37                 :           7 :     InitMaterializedSRF(fcinfo, 0);
      38                 :           7 :     rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
      39                 :             : 
      40         [ +  + ]:         231 :     for (int kind = PGSTAT_KIND_MIN; kind <= PGSTAT_KIND_MAX; kind++)
      41                 :             :     {
      42                 :         224 :         Datum       values[PG_STAT_KIND_INFO_COLS] = {0};
      43                 :         224 :         bool        nulls[PG_STAT_KIND_INFO_COLS] = {0};
      44                 :             :         const PgStat_KindInfo *info;
      45                 :             : 
      46                 :         224 :         info = pgstat_get_kind_info(kind);
      47         [ +  + ]:         224 :         if (info == NULL)
      48                 :         120 :             continue;
      49                 :             : 
      50                 :         104 :         values[0] = Int32GetDatum(kind);
      51                 :         104 :         values[1] = CStringGetTextDatum(info->name);
      52                 :             : 
      53                 :         104 :         values[2] = BoolGetDatum(pgstat_is_kind_builtin(kind));
      54                 :         104 :         values[3] = BoolGetDatum(info->fixed_amount);
      55                 :         104 :         values[4] = BoolGetDatum(info->accessed_across_databases);
      56                 :         104 :         values[5] = BoolGetDatum(info->write_to_file);
      57                 :         104 :         values[6] = BoolGetDatum(info->own_hash);
      58                 :             : 
      59                 :             :         /*
      60                 :             :          * When track_entry_count is disabled, use NULL.  Fixed-sized stats
      61                 :             :          * kinds report NULL here.
      62                 :             :          */
      63         [ +  + ]:         104 :         if (info->track_entry_count)
      64                 :           3 :             values[7] = Int64GetDatum(pgstat_get_entry_count(kind));
      65                 :             :         else
      66                 :         101 :             nulls[7] = true;
      67                 :             : 
      68                 :         104 :         tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
      69                 :             :     }
      70                 :             : 
      71                 :           7 :     return (Datum) 0;
      72                 :             : #undef PG_STAT_KIND_INFO_COLS
      73                 :             : }
        

Generated by: LCOV version 2.0-1