1/*--------------------------------------------------------------------------
3 * injection_stats_fixed.c
4 * Code for fixed-numbered statistics of injection points.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/test/modules/injection_points/injection_stats_fixed.c
12 * -------------------------------------------------------------------------
27/* Structures for statistics of injection points, fixed-size */
46/* Callbacks for fixed-numbered stats */
52 .
name =
"injection_points_fixed",
54 .write_to_file =
true,
66 * Kind ID reserved for statistics of injection points.
68 #define PGSTAT_KIND_INJECTION_FIXED 26
70/* Track if fixed-numbered stats are loaded */
91 sizeof(stats_shmem->
stats),
109 sizeof(stats_shmem->
stats),
113 memcpy(&
reset, reset_offset,
sizeof(stats_shmem->
stats));
116 /* compensate by reset offsets */
117#define FIXED_COMP(fld) stat_snap->fld -= reset.fld;
127 * Workhorse to do the registration work, called in _PG_init().
134 /* mark stats as loaded */
139 * Report fixed number of statistics for an injection point.
150 /* leave if disabled */
170 * SQL function returning fixed-numbered statistics for injection points.
187 /* Initialise attributes information in the tuple descriptor */
212 /* Returns the record as Datum */
static Datum values[MAXATTR]
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
#define PG_RETURN_DATUM(x)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
struct PgStat_StatInjFixedEntry PgStat_StatInjFixedEntry
static void injection_stats_fixed_reset_all_cb(TimestampTz ts)
static bool inj_fixed_loaded
void pgstat_register_inj_fixed(void)
Datum injection_points_stats_fixed(PG_FUNCTION_ARGS)
#define PGSTAT_KIND_INJECTION_FIXED
struct PgStatShared_InjectionPointFixed PgStatShared_InjectionPointFixed
void pgstat_report_inj_fixed(uint32 numattach, uint32 numdetach, uint32 numrun, uint32 numcached, uint32 numloaded)
static const PgStat_KindInfo injection_stats_fixed
static void injection_stats_fixed_snapshot_cb(void)
static void injection_stats_fixed_init_shmem_cb(void *stats)
PG_FUNCTION_INFO_V1(injection_points_stats_fixed)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void LWLockInitialize(LWLock *lock, int tranche_id)
void pgstat_snapshot_fixed(PgStat_Kind kind)
void pgstat_register_kind(PgStat_Kind kind, const PgStat_KindInfo *kind_info)
static void * pgstat_get_custom_snapshot_data(PgStat_Kind kind)
static void * pgstat_get_custom_shmem_data(PgStat_Kind kind)
static void pgstat_end_changecount_write(uint32 *cc)
static void pgstat_begin_changecount_write(uint32 *cc)
static void pgstat_copy_changecounted_stats(void *dst, void *src, size_t len, uint32 *cc)
static Datum Int64GetDatum(int64 X)
PgStat_StatInjFixedEntry stats
PgStat_StatInjFixedEntry reset_offset
TimestampTz stat_reset_timestamp
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)