34 #define UINT32_ACCESS_ONCE(var) ((uint32)(*((volatile uint32 *)&(var)))) 49 result = (int64) (tabentry->
numscans);
425 if (result <= fctx[1])
443 #define PG_STAT_GET_PROGRESS_COLS PGSTAT_NUM_PROGRESS_PARAM + 3 457 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
458 errmsg(
"set-valued function called in context that cannot accept a set")));
461 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
462 errmsg(
"materialize mode required, but it is not " \
463 "allowed in this context")));
467 elog(
ERROR,
"return type must be a row type");
478 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
479 errmsg(
"invalid command name: \"%s\"", cmd)));
491 for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
499 MemSet(values, 0,
sizeof(values));
500 MemSet(nulls, 0,
sizeof(nulls));
549 #define PG_STAT_GET_ACTIVITY_COLS 29 562 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
563 errmsg(
"set-valued function called in context that cannot accept a set")));
566 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
567 errmsg(
"materialize mode required, but it is not " \
568 "allowed in this context")));
572 elog(
ERROR,
"return type must be a row type");
585 for (curr_backend = 1; curr_backend <= num_backends; curr_backend++)
593 const char *wait_event_type = NULL;
594 const char *wait_event = NULL;
596 MemSet(values, 0,
sizeof(values));
597 MemSet(nulls, 0,
sizeof(nulls));
609 for (i = 0; i <
lengthof(nulls); i++)
658 char *clipped_activity;
687 pfree(clipped_activity);
750 memset(&zero_clientaddr, 0,
sizeof(zero_clientaddr));
752 sizeof(zero_clientaddr)) == 0)
770 remote_host[0] =
'\0';
771 remote_port[0] =
'\0';
774 remote_host,
sizeof(remote_host),
775 remote_port,
sizeof(remote_port),
819 const char *bgw_type;
861 nulls[19] = nulls[20] = nulls[21] = nulls[22] = nulls[23] = nulls[24] = nulls[25] =
true;
972 const char *activity;
973 char *clipped_activity;
977 activity =
"<backend information not available>";
979 activity =
"<insufficient privilege>";
981 activity =
"<command string not enabled>";
987 pfree(clipped_activity);
998 const char *wait_event_type = NULL;
1001 wait_event_type =
"<backend information not available>";
1003 wait_event_type =
"<insufficient privilege>";
1007 if (!wait_event_type)
1019 const char *wait_event = NULL;
1022 wait_event =
"<backend information not available>";
1024 wait_event =
"<insufficient privilege>";
1121 memset(&zero_clientaddr, 0,
sizeof(zero_clientaddr));
1123 sizeof(zero_clientaddr)) == 0)
1137 remote_host[0] =
'\0';
1140 remote_host,
sizeof(remote_host),
1168 memset(&zero_clientaddr, 0,
sizeof(zero_clientaddr));
1170 sizeof(zero_clientaddr)) == 0)
1186 remote_port[0] =
'\0';
1190 remote_port,
sizeof(remote_port),
1209 for (beid = 1; beid <= tot_backends; beid++)
1721 for (trans = tabentry->
trans; trans != NULL; trans = trans->
upper)
1742 for (trans = tabentry->
trans; trans != NULL; trans = trans->
upper)
1763 for (trans = tabentry->
trans; trans != NULL; trans = trans->
upper)
1916 MemSet(values, 0,
sizeof(values));
1917 MemSet(nulls, 0,
sizeof(nulls));
1926 TIMESTAMPTZOID, -1, 0);
1932 TIMESTAMPTZOID, -1, 0);
1934 TIMESTAMPTZOID, -1, 0);
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Datum pg_stat_get_db_conflict_snapshot(PG_FUNCTION_ARGS)
char ssl_issuer_dn[NAMEDATALEN]
Datum pg_stat_get_db_tuples_updated(PG_FUNCTION_ARGS)
const char * GetBackgroundWorkerTypeByPid(pid_t pid)
char gss_princ[NAMEDATALEN]
Datum pg_stat_get_db_xact_commit(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS)
Datum pg_stat_get_autoanalyze_count(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_conflict_all(PG_FUNCTION_ARGS)
Datum pg_stat_get_buf_fsync_backend(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_wait_event_type(PG_FUNCTION_ARGS)
PgStat_Counter analyze_count
char ssl_cipher[NAMEDATALEN]
char last_failed_wal[MAX_XFN_CHARS+1]
Datum pg_stat_get_progress_info(PG_FUNCTION_ARGS)
#define PG_GETARG_INT32(n)
Datum pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_numbackends(PG_FUNCTION_ARGS)
PgStat_Counter archived_count
Datum pg_stat_reset_single_function_counters(PG_FUNCTION_ARGS)
#define IsA(nodeptr, _type_)
Oid st_progress_command_target
Datum pg_stat_get_archiver(PG_FUNCTION_ARGS)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Datum pg_stat_get_checkpoint_sync_time(PG_FUNCTION_ARGS)
PgStat_Counter tuples_updated
PgStat_Counter tuples_returned
Datum pg_stat_get_xact_tuples_updated(PG_FUNCTION_ARGS)
Datum pg_stat_get_last_analyze_time(PG_FUNCTION_ARGS)
Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS)
TupleDesc CreateTemplateTupleDesc(int natts)
Datum pg_stat_get_xact_function_calls(PG_FUNCTION_ARGS)
const char * pgstat_get_wait_event_type(uint32 wait_event_info)
PgStat_Counter t_tuples_fetched
PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid func_id)
TimestampTz st_activity_start_timestamp
PGPROC * BackendPidGetProc(int pid)
#define PG_RETURN_INT64(x)
PgStat_Counter n_blocks_hit
bool DataChecksumsEnabled(void)
#define SRF_IS_FIRSTCALL()
PgStat_Counter n_conflict_bufferpin
#define PG_STAT_GET_ACTIVITY_COLS
PgStat_Counter n_conflict_startup_deadlock
const char * pgstat_get_backend_desc(BackendType backendType)
PgStat_Counter t_tuples_hot_updated
Datum pg_stat_get_db_blk_write_time(PG_FUNCTION_ARGS)
#define INSTR_TIME_GET_MILLISEC(t)
Datum pg_stat_get_analyze_count(PG_FUNCTION_ARGS)
TimestampTz autovac_analyze_timestamp
Datum int4in(PG_FUNCTION_ARGS)
Datum pg_stat_get_checkpoint_write_time(PG_FUNCTION_ARGS)
bool has_privs_of_role(Oid member, Oid role)
#define PG_RETURN_FLOAT8(x)
PgStat_Counter n_checksum_failures
char ssl_client_dn[NAMEDATALEN]
PgStat_Counter n_temp_files
#define tuplestore_donestoring(state)
void pgstat_reset_shared_counters(const char *target)
struct sockaddr_storage addr
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define PG_RETURN_INT32(x)
Datum pg_stat_get_xact_function_total_time(PG_FUNCTION_ARGS)
TimestampTz last_checksum_failure
#define PG_RETURN_INET_P(x)
TransactionId backend_xmin
Datum pg_stat_reset(PG_FUNCTION_ARGS)
char ssl_version[NAMEDATALEN]
Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS)
Datum pg_stat_get_tuples_returned(PG_FUNCTION_ARGS)
PgStat_Counter n_tuples_returned
PgStat_Counter vacuum_count
Datum pg_stat_get_backend_start(PG_FUNCTION_ARGS)
int errcode(int sqlerrcode)
Datum pg_stat_get_db_checksum_last_failure(PG_FUNCTION_ARGS)
#define MemSet(start, val, len)
Datum pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS)
Datum pg_stat_get_bgwriter_maxwritten_clean(PG_FUNCTION_ARGS)
PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid)
TimestampTz stat_reset_timestamp
Datum pg_stat_get_tuples_fetched(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS)
Datum pg_stat_get_last_autoanalyze_time(PG_FUNCTION_ARGS)
Datum pg_backend_pid(PG_FUNCTION_ARGS)
Datum pg_stat_get_xact_blocks_hit(PG_FUNCTION_ARGS)
PgStat_GlobalStats * pgstat_fetch_global(void)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Datum pg_stat_get_db_tuples_returned(PG_FUNCTION_ARGS)
Datum pg_stat_get_numscans(PG_FUNCTION_ARGS)
#define DirectFunctionCall1(func, arg1)
ProgressCommandType st_progress_command
int pg_strcasecmp(const char *s1, const char *s2)
PgStat_TableCounts t_counts
Datum pg_stat_get_buf_alloc(PG_FUNCTION_ARGS)
char ssl_client_serial[NAMEDATALEN]
PgStat_Counter tuples_hot_updated
PgStat_Counter f_total_time
Datum pg_stat_get_db_temp_bytes(PG_FUNCTION_ARGS)
PgStat_Counter t_tuples_returned
Datum pg_stat_get_backend_wait_event(PG_FUNCTION_ARGS)
#define PG_RETURN_TIMESTAMPTZ(x)
#define SRF_PERCALL_SETUP()
PgStat_Counter tuples_inserted
PgStat_Counter f_numcalls
Datum pg_stat_get_function_calls(PG_FUNCTION_ARGS)
Datum pg_stat_get_xact_function_self_time(PG_FUNCTION_ARGS)
Datum pg_stat_get_bgwriter_buf_written_checkpoints(PG_FUNCTION_ARGS)
LocalPgBackendStatus * pgstat_fetch_stat_local_beentry(int beid)
Datum pg_stat_get_db_tuples_deleted(PG_FUNCTION_ARGS)
#define PG_GETARG_TEXT_PP(n)
PgStat_Counter n_xact_commit
PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS)
#define SRF_RETURN_NEXT(_funcctx, _result)
#define PGSTAT_NUM_PROGRESS_PARAM
PgStat_Counter n_blocks_fetched
Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS)
PgStat_Counter n_live_tuples
Datum pg_stat_get_db_blk_read_time(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS)
void pfree(void *pointer)
PgStat_FunctionCounts f_counts
PgStat_Counter n_conflict_tablespace
Datum pg_stat_get_db_xact_rollback(PG_FUNCTION_ARGS)
#define ObjectIdGetDatum(X)
Datum pg_stat_get_last_vacuum_time(PG_FUNCTION_ARGS)
TransactionId backend_xid
TimestampTz vacuum_timestamp
PgStat_Counter t_tuples_updated
Datum pg_stat_get_db_temp_files(PG_FUNCTION_ARGS)
#define TimestampTzGetDatum(X)
PgStat_Counter n_dead_tuples
Datum pg_stat_get_last_autovacuum_time(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
Datum pg_stat_get_xact_tuples_fetched(PG_FUNCTION_ARGS)
Datum pg_stat_get_buf_written_backend(PG_FUNCTION_ARGS)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
PgStat_Counter f_numcalls
Datum pg_stat_get_xact_tuples_returned(PG_FUNCTION_ARGS)
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
Datum pg_stat_get_live_tuples(PG_FUNCTION_ARGS)
PGPROC * AuxiliaryPidGetProc(int pid)
PgStat_Counter n_tuples_inserted
PgStat_Counter tuples_inserted
Datum pg_stat_clear_snapshot(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_conflict_bufferpin(PG_FUNCTION_ARGS)
const char * pgstat_get_wait_event(uint32 wait_event_info)
Datum pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS)
#define CStringGetDatum(X)
Datum pg_stat_get_db_conflict_lock(PG_FUNCTION_ARGS)
PgStat_BackendFunctionEntry * find_funcstat_entry(Oid func_id)
PgStat_Counter tuples_fetched
PgStat_Counter n_conflict_snapshot
Datum pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
Datum numeric_in(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
TimestampTz st_state_start_timestamp
PgStat_Counter n_tuples_deleted
Datum Int64GetDatum(int64 X)
PgStat_Counter n_conflict_lock
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
#define ereport(elevel, rest)
PgStat_Counter t_blocks_hit
void pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
struct PgStat_TableXactStatus * upper
PgStat_Counter n_xact_rollback
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Datum pg_stat_get_xact_tuples_hot_updated(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_xact_start(PG_FUNCTION_ARGS)
Datum pg_stat_get_vacuum_count(PG_FUNCTION_ARGS)
Datum pg_stat_get_autovacuum_count(PG_FUNCTION_ARGS)
PgStat_Counter t_tuples_deleted
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
#define TransactionIdGetDatum(X)
Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_blocks_fetched(PG_FUNCTION_ARGS)
PgBackendStatus backendStatus
PgStat_Counter tuples_deleted
Datum pg_stat_get_tuples_hot_updated(PG_FUNCTION_ARGS)
#define PG_RETURN_DATUM(x)
Datum pg_stat_get_xact_blocks_fetched(PG_FUNCTION_ARGS)
BackendType st_backendType
PgStat_Counter blocks_hit
TimestampTz analyze_timestamp
Datum pg_stat_get_function_self_time(PG_FUNCTION_ARGS)
TimestampTz last_failed_timestamp
PgStat_Counter changes_since_analyze
PgStat_Counter t_numscans
PgStat_MsgBgWriter bgwriterStats
Datum pg_stat_get_db_checksum_failures(PG_FUNCTION_ARGS)
PgStat_Counter n_tuples_updated
bool is_member_of_role(Oid member, Oid role)
#define PG_RETURN_TEXT_P(x)
Datum pg_stat_get_db_tuples_fetched(PG_FUNCTION_ARGS)
SetFunctionReturnMode returnMode
text * cstring_to_text(const char *s)
Datum pg_stat_get_bgwriter_stat_reset_time(PG_FUNCTION_ARGS)
int pgstat_fetch_stat_numbackends(void)
int pg_getnameinfo_all(const struct sockaddr_storage *addr, int salen, char *node, int nodelen, char *service, int servicelen, int flags)
PgBackendStatus * pgstat_fetch_stat_beentry(int beid)
Datum pg_stat_reset_shared(PG_FUNCTION_ARGS)
PgStat_Counter failed_count
PgStat_Counter n_block_write_time
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
Datum inet_in(PG_FUNCTION_ARGS)
PgStat_Counter tuples_deleted
Datum pg_stat_get_function_total_time(PG_FUNCTION_ARGS)
void pgstat_clear_snapshot(void)
MemoryContext multi_call_memory_ctx
PgStat_Counter tuples_updated
Datum pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
void clean_ipv6_addr(int addr_family, char *addr)
Datum pg_stat_get_db_tuples_inserted(PG_FUNCTION_ARGS)
Datum pg_stat_reset_single_table_counters(PG_FUNCTION_ARGS)
#define HeapTupleGetDatum(tuple)
MemoryContext ecxt_per_query_memory
TimestampTz autovac_vacuum_timestamp
PgStat_Counter n_block_read_time
struct PgStat_TableXactStatus * trans
Datum pg_stat_get_db_blocks_hit(PG_FUNCTION_ARGS)
Tuplestorestate * setResult
PgStat_Counter autovac_analyze_count
Datum pg_stat_get_activity(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
char * text_to_cstring(const text *t)
char * pgstat_clip_activity(const char *raw_activity)
TimestampTz stat_reset_timestamp
TimestampTz last_archived_timestamp
Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS)
static zic_t trans[TZ_MAX_LEAPS]
int errmsg(const char *fmt,...)
PgStat_Counter n_deadlocks
Datum pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS)
void * MemoryContextAlloc(MemoryContext context, Size size)
TimestampTz st_xact_start_timestamp
#define PG_STAT_GET_PROGRESS_COLS
#define UINT32_ACCESS_ONCE(var)
Datum pg_stat_get_xact_tuples_inserted(PG_FUNCTION_ARGS)
Datum pg_stat_get_xact_numscans(PG_FUNCTION_ARGS)
#define CStringGetTextDatum(s)
Datum pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS)
Datum pg_stat_get_db_conflict_startup_deadlock(PG_FUNCTION_ARGS)
Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS)
#define TransactionIdIsValid(xid)
PgStat_Counter f_self_time
PgStat_Counter blocks_fetched
Datum pg_stat_get_dead_tuples(PG_FUNCTION_ARGS)
TimestampTz st_proc_start_timestamp
Datum pg_stat_get_xact_tuples_deleted(PG_FUNCTION_ARGS)
Datum pg_stat_get_bgwriter_buf_written_clean(PG_FUNCTION_ARGS)
PgBackendSSLStatus * st_sslstatus
PgStat_Counter t_tuples_inserted
void pgstat_reset_counters(void)
PgBackendGSSStatus * st_gssstatus
PgStat_Counter t_blocks_fetched
PgStat_Counter n_tuples_fetched
#define SRF_RETURN_DONE(_funcctx)
char last_archived_wal[MAX_XFN_CHARS+1]
PgStat_Counter autovac_vacuum_count
Datum pg_stat_get_db_conflict_tablespace(PG_FUNCTION_ARGS)
PgStat_Counter n_temp_bytes
#define SRF_FIRSTCALL_INIT()