aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2018-01-06 11:48:21 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2018-01-06 11:48:21 +0000
commit6668a54eb8ef639a3182ae9e37e4e67982c44292 (patch)
treece8791072b2119048b2ef3dbd9c1c5cb4567173c /src
parentccf312a4488ab8bb38dfd87168bf8915045d1a82 (diff)
downloadpostgresql-6668a54eb8ef639a3182ae9e37e4e67982c44292.tar.gz
postgresql-6668a54eb8ef639a3182ae9e37e4e67982c44292.zip
Default monitoring roles - errata
25fff40798fc4ac11a241bfd9ab0c45c085e2212 introduced default monitoring roles. Apply these corrections: * Allow access to pg_stat_get_wal_senders() by role pg_read_all_stats * Correct comment in pg_stat_get_wal_receiver() to show it is no longer superuser-only. Author: Feike Steenbergen Reviewed-by: Michael Paquier Apply to HEAD, then later backpatch to 10
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walreceiver.c3
-rw-r--r--src/backend/replication/walsender.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index a7fc67153ad..a39a98ff187 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1442,7 +1442,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
{
/*
- * Only superusers can see details. Other users only get the pid value
+ * Only superusers and members of pg_read_all_stats can see details.
+ * Other users only get the pid value
* to know whether it is a WAL receiver, but no details.
*/
MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 9b63c40e8e2..8bef3fbdaf6 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -56,6 +56,7 @@
#include "access/xlog_internal.h"
#include "access/xlogutils.h"
+#include "catalog/pg_authid.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
@@ -3242,11 +3243,12 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
memset(nulls, 0, sizeof(nulls));
values[0] = Int32GetDatum(pid);
- if (!superuser())
+ if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
{
/*
- * Only superusers can see details. Other users only get the pid
- * value to know it's a walsender, but no details.
+ * Only superusers and members of pg_read_all_stats can see details.
+ * Other users only get the pid value to know it's a walsender,
+ * but no details.
*/
MemSet(&nulls[1], true, PG_STAT_GET_WAL_SENDERS_COLS - 1);
}