From f88a638199d8505e7a01548cb647f908ae1e469f Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 23 Jan 2011 17:28:19 +0100 Subject: [PATCH] Only show pg_stat_replication details to superusers --- doc/src/sgml/monitoring.sgml | 4 +++- src/backend/replication/walsender.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 241131ce61..306af4e454 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -299,7 +299,9 @@ postgres: user database host One row per WAL sender process, showing process ID, user OID, user name, application name, client's address and port number, time at which the server process began execution, current WAL sender - state and transaction log location. + state and transaction log location. The columns detailing what exactly + the connection is doing are only visible if the user examining the view + is a superuser. diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 14b43d855b..8a63923456 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1141,8 +1141,20 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS) memset(nulls, 0, sizeof(nulls)); values[0] = Int32GetDatum(walsnd->pid); - values[1] = CStringGetTextDatum(WalSndGetStateString(state)); - values[2] = CStringGetTextDatum(sent_location); + if (!superuser()) + { + /* + * Only superusers can see details. Other users only get + * the pid value to know it's a walsender, but no details. + */ + nulls[1] = true; + nulls[2] = true; + } + else + { + values[1] = CStringGetTextDatum(WalSndGetStateString(state)); + values[2] = CStringGetTextDatum(sent_location); + } tuplestore_putvalues(tupstore, tupdesc, values, nulls); }