PostgreSQL Source Code git master
|
#include "datatype/timestamp.h"
#include "libpq/pqcomm.h"
#include "miscadmin.h"
#include "storage/procnumber.h"
#include "utils/backend_progress.h"
Go to the source code of this file.
Data Structures | |
struct | PgBackendSSLStatus |
struct | PgBackendGSSStatus |
struct | PgBackendStatus |
struct | LocalPgBackendStatus |
Macros | |
#define | PGSTAT_BEGIN_WRITE_ACTIVITY(beentry) |
#define | PGSTAT_END_WRITE_ACTIVITY(beentry) |
#define | pgstat_begin_read_activity(beentry, before_changecount) |
#define | pgstat_end_read_activity(beentry, after_changecount) |
#define | pgstat_read_activity_complete(before_changecount, after_changecount) |
Typedefs | |
typedef enum BackendState | BackendState |
typedef struct PgBackendSSLStatus | PgBackendSSLStatus |
typedef struct PgBackendGSSStatus | PgBackendGSSStatus |
typedef struct PgBackendStatus | PgBackendStatus |
typedef struct LocalPgBackendStatus | LocalPgBackendStatus |
Enumerations | |
enum | BackendState { STATE_UNDEFINED , STATE_IDLE , STATE_RUNNING , STATE_IDLEINTRANSACTION , STATE_FASTPATH , STATE_IDLEINTRANSACTION_ABORTED , STATE_DISABLED } |
Variables | |
PGDLLIMPORT bool | pgstat_track_activities |
PGDLLIMPORT int | pgstat_track_activity_query_size |
PGDLLIMPORT PgBackendStatus * | MyBEEntry |
#define pgstat_begin_read_activity | ( | beentry, | |
before_changecount | |||
) |
Definition at line 220 of file backend_status.h.
#define PGSTAT_BEGIN_WRITE_ACTIVITY | ( | beentry | ) |
Definition at line 205 of file backend_status.h.
#define pgstat_end_read_activity | ( | beentry, | |
after_changecount | |||
) |
Definition at line 226 of file backend_status.h.
#define PGSTAT_END_WRITE_ACTIVITY | ( | beentry | ) |
Definition at line 212 of file backend_status.h.
#define pgstat_read_activity_complete | ( | before_changecount, | |
after_changecount | |||
) |
Definition at line 232 of file backend_status.h.
typedef enum BackendState BackendState |
typedef struct LocalPgBackendStatus LocalPgBackendStatus |
typedef struct PgBackendGSSStatus PgBackendGSSStatus |
typedef struct PgBackendSSLStatus PgBackendSSLStatus |
typedef struct PgBackendStatus PgBackendStatus |
enum BackendState |
Enumerator | |
---|---|
STATE_UNDEFINED | |
STATE_IDLE | |
STATE_RUNNING | |
STATE_IDLEINTRANSACTION | |
STATE_FASTPATH | |
STATE_IDLEINTRANSACTION_ABORTED | |
STATE_DISABLED |
Definition at line 24 of file backend_status.h.
void BackendStatusShmemInit | ( | void | ) |
Definition at line 114 of file backend_status.c.
References BackendActivityBuffer, BackendActivityBufferSize, BackendAppnameBuffer, BackendClientHostnameBuffer, BackendStatusArray, i, MemSet, mul_size(), NAMEDATALEN, NumBackendStatSlots, pgstat_track_activity_query_size, ShmemInitStruct(), size, PgBackendStatus::st_activity_raw, PgBackendStatus::st_appname, PgBackendStatus::st_clienthostname, PgBackendStatus::st_gssstatus, and PgBackendStatus::st_sslstatus.
Referenced by CreateOrAttachShmemStructs().
Size BackendStatusShmemSize | ( | void | ) |
Definition at line 81 of file backend_status.c.
References add_size(), mul_size(), NAMEDATALEN, NumBackendStatSlots, pgstat_track_activity_query_size, and size.
Referenced by CalculateShmemSize().
void pgstat_beinit | ( | void | ) |
Definition at line 245 of file backend_status.c.
References Assert, BackendStatusArray, INVALID_PROC_NUMBER, MyBEEntry, MyProcNumber, NumBackendStatSlots, on_shmem_exit(), and pgstat_beshutdown_hook().
Referenced by AuxiliaryProcessMainCommon(), and InitPostgres().
void pgstat_bestart | ( | void | ) |
Definition at line 271 of file backend_status.c.
References application_name, Assert, B_BACKEND, B_BG_WORKER, B_WAL_SENDER, be_gssapi_get_auth(), be_gssapi_get_delegation(), be_gssapi_get_enc(), be_gssapi_get_princ(), be_tls_get_cipher(), be_tls_get_cipher_bits(), be_tls_get_peer_issuer_name(), be_tls_get_peer_serial(), be_tls_get_peer_subject_name(), be_tls_get_version(), GetSessionUserId(), Port::gss, PgBackendGSSStatus::gss_auth, PgBackendGSSStatus::gss_delegation, PgBackendGSSStatus::gss_enc, PgBackendGSSStatus::gss_princ, InvalidOid, MemSet, MyBackendType, MyBEEntry, MyDatabaseId, MyProcNumber, MyProcPid, MyProcPort, MyStartTimestamp, NAMEDATALEN, PGSTAT_BEGIN_WRITE_ACTIVITY, pgstat_create_backend(), PGSTAT_END_WRITE_ACTIVITY, pgstat_report_appname(), pgstat_track_activity_query_size, pgstat_tracks_backend_bktype(), PROGRESS_COMMAND_INVALID, Port::raddr, Port::remote_hostname, PgBackendSSLStatus::ssl_bits, PgBackendSSLStatus::ssl_cipher, PgBackendSSLStatus::ssl_client_dn, PgBackendSSLStatus::ssl_client_serial, Port::ssl_in_use, PgBackendSSLStatus::ssl_issuer_dn, PgBackendSSLStatus::ssl_version, PgBackendStatus::st_activity_raw, PgBackendStatus::st_activity_start_timestamp, PgBackendStatus::st_appname, PgBackendStatus::st_backendType, PgBackendStatus::st_changecount, PgBackendStatus::st_clientaddr, PgBackendStatus::st_clienthostname, PgBackendStatus::st_databaseid, PgBackendStatus::st_gss, PgBackendStatus::st_gssstatus, PgBackendStatus::st_proc_start_timestamp, PgBackendStatus::st_procpid, PgBackendStatus::st_progress_command, PgBackendStatus::st_progress_command_target, PgBackendStatus::st_query_id, PgBackendStatus::st_ssl, PgBackendStatus::st_sslstatus, PgBackendStatus::st_state, PgBackendStatus::st_state_start_timestamp, PgBackendStatus::st_userid, PgBackendStatus::st_xact_start_timestamp, STATE_UNDEFINED, strlcpy(), UINT64CONST, and unvolatize.
Referenced by AuxiliaryProcessMainCommon(), and InitPostgres().
void pgstat_clear_backend_activity_snapshot | ( | void | ) |
Definition at line 469 of file backend_status.c.
References backendStatusSnapContext, localBackendStatusTable, localNumBackends, and MemoryContextDelete().
Referenced by pgstat_clear_snapshot().
char * pgstat_clip_activity | ( | const char * | raw_activity | ) |
Definition at line 1191 of file backend_status.c.
References cliplen(), pg_mbcliplen(), pgstat_track_activity_query_size, and pnstrdup().
Referenced by pg_stat_get_activity(), pg_stat_get_backend_activity(), and pgstat_get_backend_current_activity().
int pgstat_fetch_stat_numbackends | ( | void | ) |
Definition at line 1175 of file backend_status.c.
References localNumBackends, and pgstat_read_current_status().
Referenced by pg_stat_get_activity(), pg_stat_get_backend_idset(), pg_stat_get_db_numbackends(), and pg_stat_get_progress_info().
const char * pgstat_get_backend_current_activity | ( | int | pid, |
bool | checkUser | ||
) |
Definition at line 887 of file backend_status.c.
References BackendStatusArray, CHECK_FOR_INTERRUPTS, GetUserId(), i, MaxBackends, pgstat_begin_read_activity, pgstat_clip_activity(), pgstat_end_read_activity, pgstat_read_activity_complete, PgBackendStatus::st_activity_raw, PgBackendStatus::st_procpid, PgBackendStatus::st_userid, and superuser().
Referenced by DeadLockReport().
BackendType pgstat_get_backend_type_by_proc_number | ( | ProcNumber | procNumber | ) |
Definition at line 1057 of file backend_status.c.
References BackendStatusArray, and PgBackendStatus::st_backendType.
Referenced by pg_signal_backend().
PgBackendStatus * pgstat_get_beentry_by_proc_number | ( | ProcNumber | procNumber | ) |
Definition at line 1099 of file backend_status.c.
References LocalPgBackendStatus::backendStatus, and pgstat_get_local_beentry_by_proc_number().
Referenced by pg_stat_get_backend_activity(), pg_stat_get_backend_activity_start(), pg_stat_get_backend_client_addr(), pg_stat_get_backend_client_port(), pg_stat_get_backend_dbid(), pg_stat_get_backend_io(), pg_stat_get_backend_pid(), pg_stat_get_backend_start(), pg_stat_get_backend_userid(), pg_stat_get_backend_wait_event(), pg_stat_get_backend_wait_event_type(), and pg_stat_get_backend_xact_start().
const char * pgstat_get_crashed_backend_activity | ( | int | pid, |
char * | buffer, | ||
int | buflen | ||
) |
Definition at line 965 of file backend_status.c.
References ascii_safe_strlcpy(), BackendActivityBuffer, BackendActivityBufferSize, BackendStatusArray, i, MaxBackends, Min, pgstat_track_activity_query_size, PgBackendStatus::st_activity_raw, and PgBackendStatus::st_procpid.
Referenced by LogChildExit().
LocalPgBackendStatus * pgstat_get_local_beentry_by_index | ( | int | idx | ) |
Definition at line 1155 of file backend_status.c.
References idx(), localBackendStatusTable, localNumBackends, and pgstat_read_current_status().
Referenced by pg_stat_get_activity(), pg_stat_get_backend_idset(), pg_stat_get_db_numbackends(), and pg_stat_get_progress_info().
LocalPgBackendStatus * pgstat_get_local_beentry_by_proc_number | ( | ProcNumber | procNumber | ) |
Definition at line 1124 of file backend_status.c.
References cmp_lbestatus(), sort-test::key, localBackendStatusTable, localNumBackends, and pgstat_read_current_status().
Referenced by pg_stat_get_backend_subxact(), and pgstat_get_beentry_by_proc_number().
uint64 pgstat_get_my_query_id | ( | void | ) |
Definition at line 1029 of file backend_status.c.
References MyBEEntry, and PgBackendStatus::st_query_id.
Referenced by _brin_begin_parallel(), _bt_begin_parallel(), ExecSerializePlan(), log_status_format(), parallel_vacuum_init(), write_csvlog(), and write_jsonlog().
void pgstat_report_activity | ( | BackendState | state, |
const char * | cmd_str | ||
) |
Definition at line 505 of file backend_status.c.
References GetCurrentStatementStartTimestamp(), GetCurrentTimestamp(), len, Min, MyBEEntry, MyProc, PGSTAT_BEGIN_WRITE_ACTIVITY, pgstat_count_conn_active_time, pgstat_count_conn_txn_idle_time, PGSTAT_END_WRITE_ACTIVITY, pgstat_track_activities, pgstat_track_activity_query_size, PgBackendStatus::st_activity_raw, PgBackendStatus::st_activity_start_timestamp, PgBackendStatus::st_query_id, PgBackendStatus::st_state, PgBackendStatus::st_state_start_timestamp, PgBackendStatus::st_xact_start_timestamp, STATE_DISABLED, STATE_FASTPATH, STATE_IDLEINTRANSACTION, STATE_IDLEINTRANSACTION_ABORTED, STATE_RUNNING, TimestampDifference(), UINT64CONST, and PGPROC::wait_event_info.
Referenced by _brin_parallel_build_main(), _bt_parallel_build_main(), apply_handle_begin(), apply_handle_begin_prepare(), apply_handle_commit(), apply_handle_commit_prepared(), apply_handle_prepare(), apply_handle_rollback_prepared(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_handle_stream_stop(), apply_spooled_messages(), autovac_report_activity(), autovac_report_workitem(), exec_bind_message(), exec_execute_message(), exec_parse_message(), exec_replication_command(), exec_simple_query(), initialize_worker_spi(), LogicalRepApplyLoop(), pa_stream_abort(), parallel_vacuum_main(), ParallelQueryMain(), PostgresMain(), and worker_spi_main().
void pgstat_report_appname | ( | const char * | appname | ) |
Definition at line 655 of file backend_status.c.
References len, MyBEEntry, NAMEDATALEN, pg_mbcliplen(), PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, and PgBackendStatus::st_appname.
Referenced by assign_application_name(), and pgstat_bestart().
void pgstat_report_query_id | ( | uint64 | query_id, |
bool | force | ||
) |
Definition at line 615 of file backend_status.c.
References MyBEEntry, PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, pgstat_track_activities, and PgBackendStatus::st_query_id.
Referenced by _brin_parallel_build_main(), _bt_parallel_build_main(), exec_bind_message(), exec_execute_message(), exec_simple_query(), ExecutorStart(), parallel_vacuum_main(), parse_analyze_fixedparams(), parse_analyze_varparams(), and parse_analyze_withcb().
void pgstat_report_tempfile | ( | size_t | filesize | ) |
Definition at line 175 of file pgstat_database.c.
References MyDatabaseId, pgstat_prep_database_pending(), pgstat_track_counts, PgStat_StatDBEntry::temp_bytes, and PgStat_StatDBEntry::temp_files.
Referenced by ReportTemporaryFileUsage().
void pgstat_report_xact_timestamp | ( | TimestampTz | tstamp | ) |
Definition at line 684 of file backend_status.c.
References MyBEEntry, PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, pgstat_track_activities, and PgBackendStatus::st_xact_start_timestamp.
Referenced by AbortTransaction(), CommitTransaction(), PrepareTransaction(), and StartTransaction().
|
extern |
Definition at line 47 of file backend_status.c.
Referenced by pgstat_beinit(), pgstat_beshutdown_hook(), pgstat_bestart(), pgstat_get_my_query_id(), pgstat_progress_end_command(), pgstat_progress_incr_param(), pgstat_progress_start_command(), pgstat_progress_update_multi_param(), pgstat_progress_update_param(), pgstat_report_activity(), pgstat_report_appname(), pgstat_report_query_id(), and pgstat_report_xact_timestamp().
|
extern |
Definition at line 42 of file backend_status.c.
Referenced by pgstat_progress_end_command(), pgstat_progress_incr_param(), pgstat_progress_start_command(), pgstat_progress_update_multi_param(), pgstat_progress_update_param(), pgstat_report_activity(), pgstat_report_query_id(), and pgstat_report_xact_timestamp().
|
extern |
Definition at line 43 of file backend_status.c.
Referenced by BackendStatusShmemInit(), BackendStatusShmemSize(), pgstat_bestart(), pgstat_clip_activity(), pgstat_get_crashed_backend_activity(), pgstat_read_current_status(), and pgstat_report_activity().