23 .
name =
"test_custom_var_stats",
27#define TEST_CUSTOM_VAR_MAGIC_NUMBER (0xBEEFBEEF)
37#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS 25
40#define TEST_CUSTOM_AUX_DATA_DESC "pg_stat/test_custom_var_stats_desc.stats"
45#define PGSTAT_CUSTOM_VAR_STATS_IDX(name) hash_bytes_extended((const unsigned char *) name, strlen(name), 0)
108 .
name =
"test_custom_var_stats",
109 .fixed_amount =
false,
110 .write_to_file =
true,
111 .track_entry_count =
true,
112 .accessed_across_databases =
true,
218 errmsg(
"could not open statistics file \"%s\" for writing: %m",
295 elog(
WARNING,
"failed to read magic number from statistics file");
301 elog(
WARNING,
"found magic number %u from statistics file, should be %u",
312 elog(
WARNING,
"failed to read metadata offset from statistics file");
325 errmsg(
"could not open statistics file \"%s\" for reading: %m",
343 elog(
WARNING,
"failed to read hash key from file");
354 key->kind, key->dboid, key->objid);
363 elog(
WARNING,
"failed to read metadata length from statistics file");
380 elog(
WARNING,
"could not access DSA for custom statistics descriptions");
388 elog(
WARNING,
"failed to read description from file");
423 errmsg(
"could not write to file \"%s\": %m",
432 errmsg(
"could not close file \"%s\": %m",
457 "didn't need to unlink file \"%s\" - didn't exist",
462 errmsg(
"could not unlink file \"%s\": %m",
534 (
errmsg(
"could not access DSA for custom statistics descriptions")));
633 elog(
ERROR,
"test_custom_stats_var_report: return type is not composite");
646 bool nulls[3] = {
false,
false,
false};
static Datum values[MAXATTR]
void * dsa_get_address(dsa_area *area, dsa_pointer dp)
#define dsa_allocate(area, size)
#define InvalidDsaPointer
#define DsaPointerIsValid(x)
dsa_area * GetNamedDSA(const char *name, bool *found)
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
FILE * AllocateFile(const char *name, const char *mode)
#define PG_GETARG_TEXT_PP(n)
#define PG_MODULE_MAGIC_EXT(...)
#define PG_FUNCTION_INFO_V1(funcname)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define SRF_RETURN_DONE(_funcctx)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void pfree(void *pointer)
bool process_shared_preload_libraries_in_progress
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
void pgstat_reset_of_kind(PgStat_Kind kind)
bool pgstat_read_chunk(FILE *fpin, void *ptr, size_t len)
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
void pgstat_register_kind(PgStat_Kind kind, const PgStat_KindInfo *kind_info)
void pgstat_write_chunk(FILE *fpout, void *ptr, size_t len)
#define pgstat_write_chunk_s(fpout, ptr)
#define pgstat_read_chunk_s(fpin, ptr)
void pgstat_request_entry_refs_gc(void)
PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry)
bool pgstat_drop_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
PgStat_EntryRef * pgstat_get_entry_ref_locked(PgStat_Kind kind, Oid dboid, uint64 objid, bool nowait)
static Datum Int64GetDatum(int64 X)
static Datum PointerGetDatum(const void *X)
PgStat_StatCustomVarEntry stats
PgStatShared_Common header
PgStatShared_Common * shared_stats
static dsa_area * custom_stats_description_dsa
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 pgoff_t fd_description_offset
Datum test_custom_stats_var_update(PG_FUNCTION_ARGS)
Datum test_custom_stats_var_drop(PG_FUNCTION_ARGS)
static const PgStat_KindInfo custom_stats
Datum test_custom_stats_var_create(PG_FUNCTION_ARGS)
Datum test_custom_stats_var_report(PG_FUNCTION_ARGS)
static bool test_custom_stats_var_flush_pending_cb(PgStat_EntryRef *entry_ref, bool nowait)
#define TEST_CUSTOM_AUX_DATA_DESC
static PgStat_StatCustomVarEntry * test_custom_stats_var_fetch_entry(const char *stat_name)
static bool test_custom_stats_var_from_serialized_data(const PgStat_HashKey *key, PgStatShared_Common *header, FILE *statfile)
#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS
#define TEST_CUSTOM_VAR_MAGIC_NUMBER
#define PGSTAT_CUSTOM_VAR_STATS_IDX(name)
static FILE * fd_description
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
#define fseeko(stream, offset, origin)