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"
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
pg_stat_get_kind_info
(
PG_FUNCTION_ARGS
)
33
{
34
#define PG_STAT_KIND_INFO_COLS 7
35
ReturnSetInfo
*
rsinfo
;
36
37
InitMaterializedSRF
(fcinfo, 0);
38
rsinfo
= (
ReturnSetInfo
*) fcinfo->resultinfo;
39
40
for
(
int
kind =
PGSTAT_KIND_MIN
; kind <=
PGSTAT_KIND_MAX
; kind++)
41
{
42
Datum
values
[
PG_STAT_KIND_INFO_COLS
] = {0};
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);
51
values
[1] =
CStringGetTextDatum
(info->
name
);
52
53
values
[2] =
BoolGetDatum
(
pgstat_is_kind_builtin
(kind));
54
values
[3] =
BoolGetDatum
(info->
fixed_amount
);
55
values
[4] =
BoolGetDatum
(info->
accessed_across_databases
);
56
values
[5] =
BoolGetDatum
(info->
write_to_file
);
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
)
63
values
[6] =
Int64GetDatum
(
pgstat_get_entry_count
(kind));
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
}
values
static Datum values[MAXATTR]
Definition
bootstrap.c:190
builtins.h
CStringGetTextDatum
#define CStringGetTextDatum(s)
Definition
builtins.h:98
fmgr.h
PG_FUNCTION_ARGS
#define PG_FUNCTION_ARGS
Definition
fmgr.h:193
InitMaterializedSRF
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
Definition
funcapi.c:76
funcapi.h
pgstat_get_kind_info
const PgStat_KindInfo * pgstat_get_kind_info(PgStat_Kind kind)
Definition
pgstat.c:1479
pgstat_internal.h
pgstat_get_entry_count
static uint64 pgstat_get_entry_count(PgStat_Kind kind)
Definition
pgstat_internal.h:1024
pg_stat_get_kind_info
Datum pg_stat_get_kind_info(PG_FUNCTION_ARGS)
Definition
pgstat_kind.c:32
PG_STAT_KIND_INFO_COLS
#define PG_STAT_KIND_INFO_COLS
pgstat_kind.h
pgstat_is_kind_builtin
static bool pgstat_is_kind_builtin(PgStat_Kind kind)
Definition
pgstat_kind.h:62
PGSTAT_KIND_MAX
#define PGSTAT_KIND_MAX
Definition
pgstat_kind.h:21
PGSTAT_KIND_MIN
#define PGSTAT_KIND_MIN
Definition
pgstat_kind.h:20
postgres.h
Int64GetDatum
static Datum Int64GetDatum(int64 X)
Definition
postgres.h:426
BoolGetDatum
static Datum BoolGetDatum(bool X)
Definition
postgres.h:112
Datum
uint64_t Datum
Definition
postgres.h:70
Int32GetDatum
static Datum Int32GetDatum(int32 X)
Definition
postgres.h:212
fb
static int fb(int x)
Definition
preproc-init.c:92
PgStat_KindInfo
Definition
pgstat_internal.h:232
PgStat_KindInfo::accessed_across_databases
bool accessed_across_databases
Definition
pgstat_internal.h:243
PgStat_KindInfo::track_entry_count
bool track_entry_count
Definition
pgstat_internal.h:252
PgStat_KindInfo::write_to_file
bool write_to_file
Definition
pgstat_internal.h:246
PgStat_KindInfo::name
const char *const name
Definition
pgstat_internal.h:383
PgStat_KindInfo::fixed_amount
bool fixed_amount
Definition
pgstat_internal.h:237
ReturnSetInfo
Definition
execnodes.h:367
tuplestore_putvalues
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
Definition
tuplestore.c:785
tuplestore.h
src
backend
utils
activity
pgstat_kind.c
Generated on Thu Jul 2 2026 21:13:14 for PostgreSQL Source Code by
1.9.8