Commit 5c46e7d8 authored by Alvaro Herrera's avatar Alvaro Herrera

pg_stat_{ssl,gssapi}: Show only processes with connections

It is pointless to show in those views auxiliary processes that don't
open network connections.

A small incompatibility is that anybody joining pg_stat_activity and
pg_stat_ssl/pg_stat_gssapi will have to use a left join if they want to
see such auxiliary processes.

Author: Euler Taveira
Discussion: https://postgr.es/m/20190904151535.GA29108@alvherre.pgsql
parent 1f55ebae
...@@ -826,7 +826,8 @@ CREATE VIEW pg_stat_ssl AS ...@@ -826,7 +826,8 @@ CREATE VIEW pg_stat_ssl AS
S.ssl_client_dn AS client_dn, S.ssl_client_dn AS client_dn,
S.ssl_client_serial AS client_serial, S.ssl_client_serial AS client_serial,
S.ssl_issuer_dn AS issuer_dn S.ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL) AS S; FROM pg_stat_get_activity(NULL) AS S
WHERE S.client_port IS NOT NULL;
CREATE VIEW pg_stat_gssapi AS CREATE VIEW pg_stat_gssapi AS
SELECT SELECT
...@@ -834,7 +835,8 @@ CREATE VIEW pg_stat_gssapi AS ...@@ -834,7 +835,8 @@ CREATE VIEW pg_stat_gssapi AS
S.gss_auth AS gss_authenticated, S.gss_auth AS gss_authenticated,
S.gss_princ AS principal, S.gss_princ AS principal,
S.gss_enc AS encrypted S.gss_enc AS encrypted
FROM pg_stat_get_activity(NULL) AS S; FROM pg_stat_get_activity(NULL) AS S
WHERE S.client_port IS NOT NULL;
CREATE VIEW pg_replication_slots AS CREATE VIEW pg_replication_slots AS
SELECT SELECT
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201910251 #define CATALOG_VERSION_NO 201911121
#endif #endif
...@@ -1845,7 +1845,8 @@ pg_stat_gssapi| SELECT s.pid, ...@@ -1845,7 +1845,8 @@ pg_stat_gssapi| SELECT s.pid,
s.gss_auth AS gss_authenticated, s.gss_auth AS gss_authenticated,
s.gss_princ AS principal, s.gss_princ AS principal,
s.gss_enc AS encrypted s.gss_enc AS encrypted
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc); FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc)
WHERE (s.client_port IS NOT NULL);
pg_stat_progress_cluster| SELECT s.pid, pg_stat_progress_cluster| SELECT s.pid,
s.datid, s.datid,
d.datname, d.datname,
...@@ -1964,7 +1965,8 @@ pg_stat_ssl| SELECT s.pid, ...@@ -1964,7 +1965,8 @@ pg_stat_ssl| SELECT s.pid,
s.ssl_client_dn AS client_dn, s.ssl_client_dn AS client_dn,
s.ssl_client_serial AS client_serial, s.ssl_client_serial AS client_serial,
s.ssl_issuer_dn AS issuer_dn s.ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc); FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc)
WHERE (s.client_port IS NOT NULL);
pg_stat_subscription| SELECT su.oid AS subid, pg_stat_subscription| SELECT su.oid AS subid,
su.subname, su.subname,
st.pid, st.pid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment