Only show pg_stat_replication details to superusers
This commit is contained in:
parent
fe12263c9f
commit
f88a638199
@ -299,7 +299,9 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
|
|||||||
<entry>One row per WAL sender process, showing process <acronym>ID</>,
|
<entry>One row per WAL sender process, showing process <acronym>ID</>,
|
||||||
user OID, user name, application name, client's address and port number,
|
user OID, user name, application name, client's address and port number,
|
||||||
time at which the server process began execution, current WAL sender
|
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.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
@ -1141,8 +1141,20 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
memset(nulls, 0, sizeof(nulls));
|
memset(nulls, 0, sizeof(nulls));
|
||||||
values[0] = Int32GetDatum(walsnd->pid);
|
values[0] = Int32GetDatum(walsnd->pid);
|
||||||
|
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[1] = CStringGetTextDatum(WalSndGetStateString(state));
|
||||||
values[2] = CStringGetTextDatum(sent_location);
|
values[2] = CStringGetTextDatum(sent_location);
|
||||||
|
}
|
||||||
|
|
||||||
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user