22 .
name =
"test_custom_var_stats",
26#define TEST_CUSTOM_VAR_MAGIC_NUMBER (0xBEEFBEEF)
36#define PGSTAT_KIND_TEST_CUSTOM_VAR_STATS 25
39#define TEST_CUSTOM_AUX_DATA_DESC "pg_stat/test_custom_var_stats_desc.stats"
44#define PGSTAT_CUSTOM_VAR_STATS_IDX(name) hash_bytes_extended((const unsigned char *) name, strlen(name), 0)
107 .
name =
"test_custom_var_stats",
108 .fixed_amount =
false,
109 .write_to_file =
true,
110 .track_entry_count =
true,
111 .accessed_across_databases =
true,
217 errmsg(
"could not open statistics file \"%s\" for writing: %m",
294 elog(
WARNING,
"failed to read magic number from statistics file");
300 elog(
WARNING,
"found magic number %u from statistics file, should be %u",
311 elog(
WARNING,
"failed to read metadata offset from statistics file");
324 errmsg(
"could not open statistics file \"%s\" for reading: %m",
342 elog(
WARNING,
"failed to read hash key from file");
347 if (file_key.
kind !=
key->kind ||
351 elog(
WARNING,
"found entry key %u/%u/%" PRIu64
" not matching with %u/%u/%" PRIu64,
362 elog(
WARNING,
"failed to read metadata length from statistics file");
379 elog(
WARNING,
"could not access DSA for custom statistics descriptions");
387 elog(
WARNING,
"failed to read description from file");
422 errmsg(
"could not write to file \"%s\": %m",
431 errmsg(
"could not close file \"%s\": %m",
456 "didn't need to unlink file \"%s\" - didn't exist",
461 errmsg(
"could not unlink file \"%s\": %m",
523 (
errcode(ERRCODE_NAME_TOO_LONG),
524 errmsg(
"custom statistic name \"%s\" is too long", stat_name),
533 (
errmsg(
"could not access DSA for custom statistics descriptions")));
551 memset(&shared_entry->
stats, 0,
sizeof(shared_entry->
stats));
632 elog(
ERROR,
"test_custom_stats_var_report: return type is not composite");
645 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 errmsg_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
FILE * AllocateFile(const char *name, const char *mode)
#define PG_GETARG_TEXT_PP(n)
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)
if(TABLE==NULL||TABLE_index==NULL)
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)
struct PgStat_HashKey PgStat_HashKey
#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)
MemoryContext multi_call_memory_ctx
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)
PG_FUNCTION_INFO_V1(test_custom_stats_var_create)
static pgoff_t fd_description_offset
Datum test_custom_stats_var_update(PG_FUNCTION_ARGS)
struct PgStatShared_CustomVarEntry PgStatShared_CustomVarEntry
Datum test_custom_stats_var_drop(PG_FUNCTION_ARGS)
static const PgStat_KindInfo custom_stats
struct PgStat_StatCustomVarEntry PgStat_StatCustomVarEntry
PG_MODULE_MAGIC_EXT(.name="test_custom_var_stats",.version=PG_VERSION)
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, const 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)