PostgreSQL Source Code git master
Data Structures | Macros | Typedefs | Functions | Variables
injection_stats.c File Reference
#include "postgres.h"
#include "fmgr.h"
#include "common/hashfn.h"
#include "injection_stats.h"
#include "pgstat.h"
#include "utils/builtins.h"
#include "utils/pgstat_internal.h"
Include dependency graph for injection_stats.c:

Go to the source code of this file.

Data Structures

 
 

Macros

#define  PGSTAT_INJ_IDX(name)   hash_bytes_extended((const unsigned char *) name, strlen(name), 0)
 
#define  PGSTAT_KIND_INJECTION   25
 

Typedefs

 
 

Functions

static bool  injection_stats_flush_cb (PgStat_EntryRef *entry_ref, bool nowait)
 
 
void  pgstat_register_inj (void)
 
void  pgstat_create_inj (const char *name)
 
void  pgstat_drop_inj (const char *name)
 
void  pgstat_report_inj (const char *name)
 
 
 
 
 
static bool  match_inj_entries (PgStatShared_HashEntry *entry, Datum match_data)
 
 
 

Variables

 
static bool  inj_stats_loaded = false
 

Macro Definition Documentation

PGSTAT_INJ_IDX

#define PGSTAT_INJ_IDX (   name )    hash_bytes_extended((const unsigned char *) name, strlen(name), 0)

Definition at line 58 of file injection_stats.c.

PGSTAT_KIND_INJECTION

#define PGSTAT_KIND_INJECTION   25

Definition at line 63 of file injection_stats.c.

Typedef Documentation

PgStat_StatInjEntry

PgStatShared_InjectionPoint

Function Documentation

injection_points_stats_count()

Datum injection_points_stats_count ( PG_FUNCTION_ARGS  )

Definition at line 206 of file injection_stats.c.

207{
209}
#define PG_RETURN_INT64(x)
Definition: fmgr.h:368
#define PGSTAT_KIND_INJECTION
static uint64 pgstat_get_entry_count(PgStat_Kind kind)

References PG_RETURN_INT64, pgstat_get_entry_count(), and PGSTAT_KIND_INJECTION.

injection_points_stats_drop()

Datum injection_points_stats_drop ( PG_FUNCTION_ARGS  )

Definition at line 223 of file injection_stats.c.

224{
226
228}
#define PG_RETURN_VOID()
Definition: fmgr.h:349
static bool match_inj_entries(PgStatShared_HashEntry *entry, Datum match_data)
void pgstat_drop_matching_entries(bool(*do_drop)(PgStatShared_HashEntry *, Datum), Datum match_data)
Definition: pgstat_shmem.c:1049

References match_inj_entries(), PG_RETURN_VOID, and pgstat_drop_matching_entries().

injection_points_stats_numcalls()

Datum injection_points_stats_numcalls ( PG_FUNCTION_ARGS  )

Definition at line 189 of file injection_stats.c.

190{
193
194 if (entry == NULL)
196
198}
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_RETURN_NULL()
Definition: fmgr.h:345
static PgStat_StatInjEntry * pgstat_fetch_stat_injentry(const char *name)
PgStat_Counter numcalls
char * text_to_cstring(const text *t)
Definition: varlena.c:214
const char * name

References name, PgStat_StatInjEntry::numcalls, PG_GETARG_TEXT_PP, PG_RETURN_INT64, PG_RETURN_NULL, pgstat_fetch_stat_injentry(), and text_to_cstring().

injection_stats_flush_cb()

static bool injection_stats_flush_cb ( PgStat_EntryRefentry_ref,
bool  nowait 
)
static

Definition at line 72 of file injection_stats.c.

73{
74 PgStat_StatInjEntry *localent;
76
77 localent = (PgStat_StatInjEntry *) entry_ref->pending;
78 shfuncent = (PgStatShared_InjectionPoint *) entry_ref->shared_stats;
79
80 if (!pgstat_lock_entry(entry_ref, nowait))
81 return false;
82
83 shfuncent->stats.numcalls += localent->numcalls;
84
85 pgstat_unlock_entry(entry_ref);
86
87 return true;
88}
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
Definition: pgstat_shmem.c:720
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
Definition: pgstat_shmem.c:690
PgStat_StatInjEntry stats
PgStatShared_Common * shared_stats

References PgStat_StatInjEntry::numcalls, PgStat_EntryRef::pending, pgstat_lock_entry(), pgstat_unlock_entry(), PgStat_EntryRef::shared_stats, and PgStatShared_InjectionPoint::stats.

match_inj_entries()

static bool match_inj_entries ( PgStatShared_HashEntryentry,
Datum  match_data 
)
static

Definition at line 213 of file injection_stats.c.

214{
215 return entry->key.kind == PGSTAT_KIND_INJECTION;
216}
PgStat_HashKey key
PgStat_Kind kind

References PgStatShared_HashEntry::key, PgStat_HashKey::kind, and PGSTAT_KIND_INJECTION.

Referenced by injection_points_stats_drop().

PG_FUNCTION_INFO_V1() [1/3]

PG_FUNCTION_INFO_V1 ( injection_points_stats_count  )

PG_FUNCTION_INFO_V1() [2/3]

PG_FUNCTION_INFO_V1 ( injection_points_stats_drop  )

PG_FUNCTION_INFO_V1() [3/3]

PG_FUNCTION_INFO_V1 ( injection_points_stats_numcalls  )

pgstat_create_inj()

void pgstat_create_inj ( const char *  name )

Definition at line 125 of file injection_stats.c.

126{
127 PgStat_EntryRef *entry_ref;
129
130 /* leave if disabled */
132 return;
133
135 PGSTAT_INJ_IDX(name), NULL);
136
137 shstatent = (PgStatShared_InjectionPoint *) entry_ref->shared_stats;
138
139 /* initialize shared memory data */
140 memset(&shstatent->stats, 0, sizeof(shstatent->stats));
141}
bool inj_stats_enabled
static bool inj_stats_loaded
#define PGSTAT_INJ_IDX(name)
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
Definition: pgstat.c:1265
#define InvalidOid
Definition: postgres_ext.h:37

References inj_stats_enabled, inj_stats_loaded, InvalidOid, name, PGSTAT_INJ_IDX, PGSTAT_KIND_INJECTION, pgstat_prep_pending_entry(), PgStat_EntryRef::shared_stats, and PgStatShared_InjectionPoint::stats.

Referenced by injection_points_attach().

pgstat_drop_inj()

void pgstat_drop_inj ( const char *  name )

Definition at line 147 of file injection_stats.c.

148{
149 /* leave if disabled */
151 return;
152
156}
void pgstat_request_entry_refs_gc(void)
Definition: pgstat_shmem.c:745
bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat_shmem.c:1004

References inj_stats_enabled, inj_stats_loaded, InvalidOid, name, pgstat_drop_entry(), PGSTAT_INJ_IDX, PGSTAT_KIND_INJECTION, and pgstat_request_entry_refs_gc().

Referenced by injection_points_cleanup(), and injection_points_detach().

pgstat_fetch_stat_injentry()

static PgStat_StatInjEntry * pgstat_fetch_stat_injentry ( const char *  name )
static

Definition at line 95 of file injection_stats.c.

96{
97 PgStat_StatInjEntry *entry = NULL;
98
100 return NULL;
101
102 /* Compile the lookup key as a hash of the point name */
106 return entry;
107}
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat.c:934

References inj_stats_enabled, inj_stats_loaded, InvalidOid, name, pgstat_fetch_entry(), PGSTAT_INJ_IDX, and PGSTAT_KIND_INJECTION.

Referenced by injection_points_stats_numcalls().

pgstat_register_inj()

void pgstat_register_inj ( void  )

Definition at line 113 of file injection_stats.c.

114{
116
117 /* mark stats as loaded */
118 inj_stats_loaded = true;
119}
static const PgStat_KindInfo injection_stats
void pgstat_register_kind(PgStat_Kind kind, const PgStat_KindInfo *kind_info)
Definition: pgstat.c:1463

References inj_stats_loaded, injection_stats, PGSTAT_KIND_INJECTION, and pgstat_register_kind().

Referenced by _PG_init().

pgstat_report_inj()

void pgstat_report_inj ( const char *  name )

Definition at line 165 of file injection_stats.c.

166{
167 PgStat_EntryRef *entry_ref;
168 PgStat_StatInjEntry *pending;
169
170 /* leave if disabled */
172 return;
173
175 PGSTAT_INJ_IDX(name), NULL);
176
177 pending = (PgStat_StatInjEntry *) entry_ref->pending;
178
179 /* Update the injection point pending statistics */
180 pending->numcalls++;
181}

References inj_stats_enabled, inj_stats_loaded, InvalidOid, name, PgStat_StatInjEntry::numcalls, PgStat_EntryRef::pending, PGSTAT_INJ_IDX, PGSTAT_KIND_INJECTION, and pgstat_prep_pending_entry().

Referenced by injection_error(), injection_notice(), and injection_wait().

Variable Documentation

inj_stats_loaded

bool inj_stats_loaded = false
static

Definition at line 66 of file injection_stats.c.

Referenced by pgstat_create_inj(), pgstat_drop_inj(), pgstat_fetch_stat_injentry(), pgstat_register_inj(), and pgstat_report_inj().

injection_stats

const PgStat_KindInfo injection_stats
static
Initial value:
= {
.name = "injection_points",
.fixed_amount = false,
.write_to_file = true,
.track_entry_count = true,
.accessed_across_databases = true,
.shared_size = sizeof(PgStatShared_InjectionPoint),
.shared_data_off = offsetof(PgStatShared_InjectionPoint, stats),
.shared_data_len = sizeof(((PgStatShared_InjectionPoint *) 0)->stats),
.pending_size = sizeof(PgStat_StatInjEntry),
.flush_pending_cb = injection_stats_flush_cb,
}
static bool injection_stats_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
struct PgStatShared_InjectionPoint PgStatShared_InjectionPoint

Definition at line 39 of file injection_stats.c.

Referenced by pgstat_register_inj().

AltStyle によって変換されたページ (->オリジナル) /