PostgreSQL Source Code git master
Loading...
Searching...
No Matches
test_custom_var_stats.c File Reference
#include "postgres.h"
#include "common/hashfn.h"
#include "funcapi.h"
#include "storage/dsm_registry.h"
#include "utils/builtins.h"
#include "utils/pgstat_internal.h"
Include dependency graph for test_custom_var_stats.c:

Go to the source code of this file.

Data Structures

struct  PgStat_StatCustomVarEntry
 
struct  PgStatShared_CustomVarEntry
 

Macros

#define TEST_CUSTOM_VAR_MAGIC_NUMBER   (0xBEEFBEEF)
 
#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS   25
 
#define TEST_CUSTOM_AUX_DATA_DESC   "pg_stat/test_custom_var_stats_desc.stats"
 
#define PGSTAT_CUSTOM_VAR_STATS_IDX(name)   hash_bytes_extended((const unsigned char *) name, strlen(name), 0)
 

Typedefs

typedef struct PgStat_StatCustomVarEntry PgStat_StatCustomVarEntry
 
typedef struct PgStatShared_CustomVarEntry PgStatShared_CustomVarEntry
 

Functions

 PG_MODULE_MAGIC_EXT (.name="test_custom_var_stats",.version=PG_VERSION)
 
static bool test_custom_stats_var_flush_pending_cb (PgStat_EntryRef *entry_ref, bool nowait)
 
static void test_custom_stats_var_to_serialized_data (const PgStat_HashKey *key, const PgStatShared_Common *header, FILE *statfile)
 
static bool test_custom_stats_var_from_serialized_data (const PgStat_HashKey *key, PgStatShared_Common *header, FILE *statfile)
 
static void test_custom_stats_var_finish (PgStat_StatsFileOp status)
 
void _PG_init (void)
 
static PgStat_StatCustomVarEntrytest_custom_stats_var_fetch_entry (const char *stat_name)
 
 PG_FUNCTION_INFO_V1 (test_custom_stats_var_create)
 
Datum test_custom_stats_var_create (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_custom_stats_var_update)
 
Datum test_custom_stats_var_update (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_custom_stats_var_drop)
 
Datum test_custom_stats_var_drop (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (test_custom_stats_var_report)
 
Datum test_custom_stats_var_report (PG_FUNCTION_ARGS)
 

Variables

static FILEfd_description = NULL
 
static pgoff_t fd_description_offset = 0
 
static dsa_areacustom_stats_description_dsa = NULL
 
static const PgStat_KindInfo custom_stats
 

Macro Definition Documentation

◆ PGSTAT_CUSTOM_VAR_STATS_IDX

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

Definition at line 44 of file test_custom_var_stats.c.

◆ PGSTAT_KIND_TEST_CUSTOM_VAR_STATS

#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS   25

Definition at line 36 of file test_custom_var_stats.c.

◆ TEST_CUSTOM_AUX_DATA_DESC

#define TEST_CUSTOM_AUX_DATA_DESC   "pg_stat/test_custom_var_stats_desc.stats"

Definition at line 39 of file test_custom_var_stats.c.

◆ TEST_CUSTOM_VAR_MAGIC_NUMBER

#define TEST_CUSTOM_VAR_MAGIC_NUMBER   (0xBEEFBEEF)

Definition at line 26 of file test_custom_var_stats.c.

Typedef Documentation

◆ PgStat_StatCustomVarEntry

◆ PgStatShared_CustomVarEntry

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 128 of file test_custom_var_stats.c.

129{
130 /* Must be loaded via shared_preload_libraries */
132 return;
133
134 /* Register custom statistics kind */
136}
bool process_shared_preload_libraries_in_progress
Definition miscinit.c:1786
void pgstat_register_kind(PgStat_Kind kind, const PgStat_KindInfo *kind_info)
Definition pgstat.c:1473
static const PgStat_KindInfo custom_stats
#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS

References custom_stats, PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, pgstat_register_kind(), and process_shared_preload_libraries_in_progress.

◆ PG_FUNCTION_INFO_V1() [1/4]

PG_FUNCTION_INFO_V1 ( test_custom_stats_var_create  )

◆ PG_FUNCTION_INFO_V1() [2/4]

PG_FUNCTION_INFO_V1 ( test_custom_stats_var_drop  )

◆ PG_FUNCTION_INFO_V1() [3/4]

PG_FUNCTION_INFO_V1 ( test_custom_stats_var_report  )

◆ PG_FUNCTION_INFO_V1() [4/4]

PG_FUNCTION_INFO_V1 ( test_custom_stats_var_update  )

◆ PG_MODULE_MAGIC_EXT()

PG_MODULE_MAGIC_EXT ( name = "test_custom_var_stats",
version = PG_VERSION 
)

◆ test_custom_stats_var_create()

Datum test_custom_stats_var_create ( PG_FUNCTION_ARGS  )

Definition at line 511 of file test_custom_var_stats.c.

512{
513 PgStat_EntryRef *entry_ref;
514 PgStatShared_CustomVarEntry *shared_entry;
518 bool found;
519
520 /* Validate name length first */
524 errmsg("custom statistic name \"%s\" is too long", stat_name),
525 errdetail("Name must be less than %d characters.", NAMEDATALEN)));
526
527 /* Initialize DSA and description provided */
529 custom_stats_description_dsa = GetNamedDSA("test_custom_stat_dsa", &found);
530
533 (errmsg("could not access DSA for custom statistics descriptions")));
534
535 /* Allocate space in DSA and copy description */
539 strlen(description) + 1);
540
541 /* Create or get existing entry */
544
545 if (!entry_ref)
547
548 shared_entry = (PgStatShared_CustomVarEntry *) entry_ref->shared_stats;
549
550 /* Zero-initialize statistics */
551 memset(&shared_entry->stats, 0, sizeof(shared_entry->stats));
552
553 /* Store description pointer */
554 shared_entry->description = dp;
555
556 pgstat_unlock_entry(entry_ref);
557
559}
void * dsa_get_address(dsa_area *area, dsa_pointer dp)
Definition dsa.c:957
uint64 dsa_pointer
Definition dsa.h:62
#define dsa_allocate(area, size)
Definition dsa.h:109
#define InvalidDsaPointer
Definition dsa.h:78
dsa_area * GetNamedDSA(const char *name, bool *found)
int errdetail(const char *fmt,...)
Definition elog.c:1216
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
#define PG_RETURN_VOID()
Definition fmgr.h:350
#define PG_GETARG_TEXT_PP(n)
Definition fmgr.h:310
#define NAMEDATALEN
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
PgStat_EntryRef * pgstat_get_entry_ref_locked(PgStat_Kind kind, Oid dboid, uint64 objid, bool nowait)
#define InvalidOid
static int fb(int x)
PgStat_StatCustomVarEntry stats
PgStatShared_Common * shared_stats
static dsa_area * custom_stats_description_dsa
#define PGSTAT_CUSTOM_VAR_STATS_IDX(name)
char * text_to_cstring(const text *t)
Definition varlena.c:214
const char * description

References custom_stats_description_dsa, description, PgStatShared_CustomVarEntry::description, dsa_allocate, dsa_get_address(), ereport, errcode(), errdetail(), errmsg(), ERROR, fb(), GetNamedDSA(), InvalidDsaPointer, InvalidOid, NAMEDATALEN, PG_GETARG_TEXT_PP, PG_RETURN_VOID, PGSTAT_CUSTOM_VAR_STATS_IDX, pgstat_get_entry_ref_locked(), PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, pgstat_unlock_entry(), PgStat_EntryRef::shared_stats, PgStatShared_CustomVarEntry::stats, and text_to_cstring().

◆ test_custom_stats_var_drop()

Datum test_custom_stats_var_drop ( PG_FUNCTION_ARGS  )

Definition at line 594 of file test_custom_var_stats.c.

595{
597
598 /* Drop entry and request GC if the entry could not be freed */
602
604}
void pgstat_request_entry_refs_gc(void)
bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid)

References fb(), InvalidOid, PG_GETARG_TEXT_PP, PG_RETURN_VOID, PGSTAT_CUSTOM_VAR_STATS_IDX, pgstat_drop_entry(), PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, pgstat_request_entry_refs_gc(), and text_to_cstring().

◆ test_custom_stats_var_fetch_entry()

static PgStat_StatCustomVarEntry * test_custom_stats_var_fetch_entry ( const char stat_name)
static

Definition at line 489 of file test_custom_var_stats.c.

490{
491 /* Fetch entry by hashed name */
496}
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition pgstat.c:944

References fb(), InvalidOid, PGSTAT_CUSTOM_VAR_STATS_IDX, pgstat_fetch_entry(), and PGSTAT_KIND_TEST_CUSTOM_VAR_STATS.

Referenced by test_custom_stats_var_report().

◆ test_custom_stats_var_finish()

static void test_custom_stats_var_finish ( PgStat_StatsFileOp  status)
static

Definition at line 407 of file test_custom_var_stats.c.

408{
409 switch (status)
410 {
411 case STATS_WRITE:
412 if (!fd_description)
413 return;
414
416
417 /* Check for write errors and cleanup if necessary */
419 {
420 ereport(LOG,
422 errmsg("could not write to file \"%s\": %m",
426 }
427 else if (FreeFile(fd_description) < 0)
428 {
429 ereport(LOG,
431 errmsg("could not close file \"%s\": %m",
434 }
435 break;
436
437 case STATS_READ:
438 if (fd_description)
440
441 /* Remove the file after reading */
442 elog(DEBUG2, "removing file \"%s\"", TEST_CUSTOM_AUX_DATA_DESC);
444 break;
445
446 case STATS_DISCARD:
447 {
448 int ret;
449
450 /* Attempt to remove the file */
452 if (ret != 0)
453 {
454 if (errno == ENOENT)
455 elog(LOG,
456 "didn't need to unlink file \"%s\" - didn't exist",
458 else
459 ereport(LOG,
461 errmsg("could not unlink file \"%s\": %m",
463 }
464 else
465 {
466 ereport(LOG,
467 (errmsg_internal("unlinked file \"%s\"",
469 }
470 }
471 break;
472 }
473
475}
int errmsg_internal(const char *fmt,...)
Definition elog.c:1170
int errcode_for_file_access(void)
Definition elog.c:886
#define LOG
Definition elog.h:31
#define DEBUG2
Definition elog.h:29
#define elog(elevel,...)
Definition elog.h:226
int FreeFile(FILE *file)
Definition fd.c:2823
@ STATS_WRITE
@ STATS_READ
@ STATS_DISCARD
static pgoff_t fd_description_offset
#define TEST_CUSTOM_AUX_DATA_DESC
static FILE * fd_description

References DEBUG2, elog, ereport, errcode_for_file_access(), errmsg(), errmsg_internal(), fb(), fd_description, fd_description_offset, FreeFile(), LOG, STATS_DISCARD, STATS_READ, STATS_WRITE, and TEST_CUSTOM_AUX_DATA_DESC.

◆ test_custom_stats_var_flush_pending_cb()

static bool test_custom_stats_var_flush_pending_cb ( PgStat_EntryRef entry_ref,
bool  nowait 
)
static

Definition at line 153 of file test_custom_var_stats.c.

154{
156 PgStatShared_CustomVarEntry *shared_entry;
157
159 shared_entry = (PgStatShared_CustomVarEntry *) entry_ref->shared_stats;
160
161 if (!pgstat_lock_entry(entry_ref, nowait))
162 return false;
163
164 /* Add pending counts to shared totals */
165 shared_entry->stats.numcalls += pending_entry->numcalls;
166
167 pgstat_unlock_entry(entry_ref);
168
169 return true;
170}
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)

References fb(), PgStat_StatCustomVarEntry::numcalls, PgStat_EntryRef::pending, pgstat_lock_entry(), pgstat_unlock_entry(), PgStat_EntryRef::shared_stats, and PgStatShared_CustomVarEntry::stats.

◆ test_custom_stats_var_from_serialized_data()

static bool test_custom_stats_var_from_serialized_data ( const PgStat_HashKey key,
PgStatShared_Common header,
FILE statfile 
)
static

Definition at line 278 of file test_custom_var_stats.c.

281{
284 size_t len;
285 pgoff_t offset;
286 char *buffer;
287 bool found;
290
291 /* Check the magic number first, in the main file. */
293 {
294 elog(WARNING, "failed to read magic number from statistics file");
295 return false;
296 }
297
299 {
300 elog(WARNING, "found magic number %u from statistics file, should be %u",
302 return false;
303 }
304
305 /*
306 * Read the offset from the main stats file, to be able to read the
307 * auxiliary data from the secondary statistics file.
308 */
309 if (!pgstat_read_chunk_s(statfile, &offset))
310 {
311 elog(WARNING, "failed to read metadata offset from statistics file");
312 return false;
313 }
314
315 /* Open statistics file for reading if not already open */
316 if (!fd_description)
317 {
319 if (fd_description == NULL)
320 {
321 if (errno != ENOENT)
322 ereport(LOG,
324 errmsg("could not open statistics file \"%s\" for reading: %m",
327 return false;
328 }
329 }
330
331 /* Read data from the secondary statistics file, at the specified offset */
332 if (fseeko(fd_description, offset, SEEK_SET) != 0)
333 {
334 elog(WARNING, "could not seek in file \"%s\": %m",
336 return false;
337 }
338
339 /* Read the hash key from the secondary statistics file */
341 {
342 elog(WARNING, "failed to read hash key from file");
343 return false;
344 }
345
346 /* Check key consistency */
347 if (file_key.kind != key->kind ||
348 file_key.dboid != key->dboid ||
349 file_key.objid != key->objid)
350 {
351 elog(WARNING, "found entry key %u/%u/%" PRIu64 " not matching with %u/%u/%" PRIu64,
352 file_key.kind, file_key.dboid, file_key.objid,
353 key->kind, key->dboid, key->objid);
354 return false;
355 }
356
357 entry = (PgStatShared_CustomVarEntry *) header;
358
359 /* Read the description length and its data */
361 {
362 elog(WARNING, "failed to read metadata length from statistics file");
363 return false;
364 }
365
366 /* Handle empty descriptions */
367 if (len == 0)
368 {
370 return true;
371 }
372
373 /* Initialize DSA if needed */
375 custom_stats_description_dsa = GetNamedDSA("test_custom_stat_dsa", &found);
376
378 {
379 elog(WARNING, "could not access DSA for custom statistics descriptions");
380 return false;
381 }
382
383 buffer = palloc(len);
384 if (!pgstat_read_chunk(fd_description, buffer, len))
385 {
386 pfree(buffer);
387 elog(WARNING, "failed to read description from file");
388 return false;
389 }
390
391 /* Allocate space in DSA and copy the description */
394 entry->description = dp;
395 pfree(buffer);
396
397 return true;
398}
#define PG_BINARY_R
Definition c.h:1283
uint32_t uint32
Definition c.h:546
#define WARNING
Definition elog.h:36
FILE * AllocateFile(const char *name, const char *mode)
Definition fd.c:2624
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc(Size size)
Definition mcxt.c:1387
const void size_t len
void pgstat_reset_of_kind(PgStat_Kind kind)
Definition pgstat.c:886
bool pgstat_read_chunk(FILE *fpin, void *ptr, size_t len)
Definition pgstat.c:1763
#define pgstat_read_chunk_s(fpin, ptr)
off_t pgoff_t
Definition port.h:421
#define TEST_CUSTOM_VAR_MAGIC_NUMBER
#define fseeko(stream, offset, origin)
Definition win32_port.h:206

References AllocateFile(), custom_stats_description_dsa, PgStatShared_CustomVarEntry::description, dsa_allocate, dsa_get_address(), elog, ereport, errcode_for_file_access(), errmsg(), fb(), fd_description, fseeko, GetNamedDSA(), InvalidDsaPointer, len, LOG, palloc(), pfree(), PG_BINARY_R, PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, pgstat_read_chunk(), pgstat_read_chunk_s, pgstat_reset_of_kind(), TEST_CUSTOM_AUX_DATA_DESC, TEST_CUSTOM_VAR_MAGIC_NUMBER, and WARNING.

◆ test_custom_stats_var_report()

Datum test_custom_stats_var_report ( PG_FUNCTION_ARGS  )

Definition at line 615 of file test_custom_var_stats.c.

616{
618 char *stat_name;
620
621 if (SRF_IS_FIRSTCALL())
622 {
623 TupleDesc tupdesc;
624 MemoryContext oldcontext;
625
626 /* Initialize SRF context */
628 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
629
630 /* Get composite return type */
631 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
632 elog(ERROR, "test_custom_stats_var_report: return type is not composite");
633
634 funcctx->tuple_desc = BlessTupleDesc(tupdesc);
635 funcctx->max_calls = 1; /* single row result */
636
637 MemoryContextSwitchTo(oldcontext);
638 }
639
641
642 if (funcctx->call_cntr < funcctx->max_calls)
643 {
644 Datum values[3];
645 bool nulls[3] = {false, false, false};
646 HeapTuple tuple;
647 PgStat_EntryRef *entry_ref;
648 PgStatShared_CustomVarEntry *shared_entry;
649 char *description = NULL;
650 bool found;
651
654
655 /* Return row only if entry exists */
656 if (stat_entry)
657 {
658 /* Get entry ref to access shared entry */
661
662 if (entry_ref)
663 {
664 shared_entry = (PgStatShared_CustomVarEntry *) entry_ref->shared_stats;
665
666 /* Get description from DSA if available */
667 if (DsaPointerIsValid(shared_entry->description))
668 {
670 custom_stats_description_dsa = GetNamedDSA("test_custom_stat_dsa", &found);
671
674 }
675 }
676
678 values[1] = Int64GetDatum(stat_entry->numcalls);
679
680 if (description)
682 else
683 nulls[2] = true;
684
685 tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
687 }
688 }
689
691}
static Datum values[MAXATTR]
Definition bootstrap.c:155
#define DsaPointerIsValid(x)
Definition dsa.h:106
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition funcapi.c:276
#define SRF_IS_FIRSTCALL()
Definition funcapi.h:304
#define SRF_PERCALL_SETUP()
Definition funcapi.h:308
@ TYPEFUNC_COMPOSITE
Definition funcapi.h:149
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition funcapi.h:310
#define SRF_FIRSTCALL_INIT()
Definition funcapi.h:306
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition funcapi.h:230
#define SRF_RETURN_DONE(_funcctx)
Definition funcapi.h:328
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1117
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry)
static Datum Int64GetDatum(int64 X)
Definition postgres.h:423
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
uint64_t Datum
Definition postgres.h:70
static PgStat_StatCustomVarEntry * test_custom_stats_var_fetch_entry(const char *stat_name)
text * cstring_to_text(const char *s)
Definition varlena.c:181

References BlessTupleDesc(), cstring_to_text(), custom_stats_description_dsa, description, PgStatShared_CustomVarEntry::description, dsa_get_address(), DsaPointerIsValid, elog, ERROR, fb(), get_call_result_type(), GetNamedDSA(), heap_form_tuple(), HeapTupleGetDatum(), Int64GetDatum(), InvalidOid, MemoryContextSwitchTo(), PG_GETARG_TEXT_PP, PGSTAT_CUSTOM_VAR_STATS_IDX, pgstat_get_entry_ref(), PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, PointerGetDatum(), PgStat_EntryRef::shared_stats, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, test_custom_stats_var_fetch_entry(), text_to_cstring(), TYPEFUNC_COMPOSITE, and values.

◆ test_custom_stats_var_to_serialized_data()

static void test_custom_stats_var_to_serialized_data ( const PgStat_HashKey key,
const PgStatShared_Common header,
FILE statfile 
)
static

Definition at line 193 of file test_custom_var_stats.c.

196{
197 char *description;
198 size_t len;
199 const PgStatShared_CustomVarEntry *entry = (const PgStatShared_CustomVarEntry *) header;
200 bool found;
202
203 /*
204 * First mark the main file with a magic number, keeping a trace that some
205 * auxiliary data will exist in the secondary statistics file.
206 */
208
209 /* Open statistics file for writing. */
210 if (!fd_description)
211 {
213 if (fd_description == NULL)
214 {
215 ereport(LOG,
217 errmsg("could not open statistics file \"%s\" for writing: %m",
219 return;
220 }
221
222 /* Initialize offset for secondary statistics file. */
224 }
225
226 /* Write offset to the main data file */
228
229 /*
230 * First write the entry key to the secondary statistics file. This will
231 * be cross-checked with the key read from main stats file at loading
232 * time.
233 */
236
238 custom_stats_description_dsa = GetNamedDSA("test_custom_stat_dsa", &found);
239
240 /* Handle entries without descriptions */
242 {
243 /* length to description file */
244 len = 0;
246 fd_description_offset += sizeof(size_t);
247 return;
248 }
249
250 /*
251 * Retrieve description from DSA, then write the length followed by the
252 * description.
253 */
255 entry->description);
256 len = strlen(description) + 1;
259
260 /*
261 * Update offset for next entry, counting for the length (size_t) of the
262 * description and the description contents.
263 */
264 fd_description_offset += len + sizeof(size_t);
265}
#define PG_BINARY_W
Definition c.h:1284
void pgstat_write_chunk(FILE *fpout, void *ptr, size_t len)
Definition pgstat.c:1565
#define pgstat_write_chunk_s(fpout, ptr)

References AllocateFile(), custom_stats_description_dsa, description, PgStatShared_CustomVarEntry::description, dsa_get_address(), DsaPointerIsValid, ereport, errcode_for_file_access(), errmsg(), fb(), fd_description, fd_description_offset, GetNamedDSA(), len, LOG, PG_BINARY_W, pgstat_write_chunk(), pgstat_write_chunk_s, TEST_CUSTOM_AUX_DATA_DESC, and TEST_CUSTOM_VAR_MAGIC_NUMBER.

◆ test_custom_stats_var_update()

Datum test_custom_stats_var_update ( PG_FUNCTION_ARGS  )

Definition at line 570 of file test_custom_var_stats.c.

571{
573 PgStat_EntryRef *entry_ref;
575
576 /* Get pending entry in local memory */
579
581 pending_entry->numcalls++;
582
584}
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
Definition pgstat.c:1275

References fb(), InvalidOid, PgStat_EntryRef::pending, PG_GETARG_TEXT_PP, PG_RETURN_VOID, PGSTAT_CUSTOM_VAR_STATS_IDX, PGSTAT_KIND_TEST_CUSTOM_VAR_STATS, pgstat_prep_pending_entry(), and text_to_cstring().

Variable Documentation

◆ custom_stats

const PgStat_KindInfo custom_stats
static
Initial value:
= {
.name = "test_custom_var_stats",
.fixed_amount = false,
.write_to_file = true,
.track_entry_count = true,
.accessed_across_databases = true,
.shared_size = sizeof(PgStatShared_CustomVarEntry),
.shared_data_off = offsetof(PgStatShared_CustomVarEntry, stats),
.shared_data_len = sizeof(((PgStatShared_CustomVarEntry *) 0)->stats),
.pending_size = sizeof(PgStat_StatCustomVarEntry),
}
static void test_custom_stats_var_to_serialized_data(const PgStat_HashKey *key, const PgStatShared_Common *header, FILE *statfile)
static void test_custom_stats_var_finish(PgStat_StatsFileOp status)
static bool test_custom_stats_var_flush_pending_cb(PgStat_EntryRef *entry_ref, bool nowait)
static bool test_custom_stats_var_from_serialized_data(const PgStat_HashKey *key, PgStatShared_Common *header, FILE *statfile)

Definition at line 106 of file test_custom_var_stats.c.

106 {
107 .name = "test_custom_var_stats",
108 .fixed_amount = false, /* variable number of entries */
109 .write_to_file = true, /* persist across restarts */
110 .track_entry_count = true, /* count active entries */
111 .accessed_across_databases = true, /* global statistics */
112 .shared_size = sizeof(PgStatShared_CustomVarEntry),
113 .shared_data_off = offsetof(PgStatShared_CustomVarEntry, stats),
114 .shared_data_len = sizeof(((PgStatShared_CustomVarEntry *) 0)->stats),
115 .pending_size = sizeof(PgStat_StatCustomVarEntry),
116 .flush_pending_cb = test_custom_stats_var_flush_pending_cb,
117 .to_serialized_data = test_custom_stats_var_to_serialized_data,
118 .from_serialized_data = test_custom_stats_var_from_serialized_data,
120};

Referenced by _PG_init().

◆ custom_stats_description_dsa

◆ fd_description

◆ fd_description_offset

pgoff_t fd_description_offset = 0
static