PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pgstat_kind.c
Go to the documentation of this file.
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"
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 */
33{
34#define PG_STAT_KIND_INFO_COLS 7
36
37 InitMaterializedSRF(fcinfo, 0);
38 rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
39
40 for (int kind = PGSTAT_KIND_MIN; kind <= PGSTAT_KIND_MAX; kind++)
41 {
43 bool nulls[PG_STAT_KIND_INFO_COLS] = {0};
44 const PgStat_KindInfo *info;
45
46 info = pgstat_get_kind_info(kind);
47 if (info == NULL)
48 continue;
49
50 values[0] = Int32GetDatum(kind);
52
57
58 /*
59 * When track_entry_count is disabled, use NULL. Fixed-sized stats
60 * kinds report NULL here.
61 */
62 if (info->track_entry_count)
64 else
65 nulls[6] = true;
66
67 tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
68 }
69
70 return (Datum) 0;
71#undef PG_STAT_KIND_INFO_COLS
72}
static Datum values[MAXATTR]
Definition bootstrap.c:190
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
Definition funcapi.c:76
const PgStat_KindInfo * pgstat_get_kind_info(PgStat_Kind kind)
Definition pgstat.c:1479
static uint64 pgstat_get_entry_count(PgStat_Kind kind)
Datum pg_stat_get_kind_info(PG_FUNCTION_ARGS)
Definition pgstat_kind.c:32
#define PG_STAT_KIND_INFO_COLS
static bool pgstat_is_kind_builtin(PgStat_Kind kind)
Definition pgstat_kind.h:62
#define PGSTAT_KIND_MAX
Definition pgstat_kind.h:21
#define PGSTAT_KIND_MIN
Definition pgstat_kind.h:20
static Datum Int64GetDatum(int64 X)
Definition postgres.h:426
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
uint64_t Datum
Definition postgres.h:70
static Datum Int32GetDatum(int32 X)
Definition postgres.h:212
static int fb(int x)
const char *const name
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
Definition tuplestore.c:785