From 2ade0e0508bc9833e22122b43e08b06f447f2c2f Mon Sep 17 00:00:00 2001 From: Antonin Houska Date: Thu, 13 Jun 2024 16:58:12 +0200 Subject: [PATCH] Make privileges check consistent with the other ones. --- pgstatapprox.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pgstatapprox.c b/pgstatapprox.c index 237fe69..7f1c3cb 100644 --- a/pgstatapprox.c +++ b/pgstatapprox.c @@ -248,10 +248,11 @@ squeeze_pgstattuple_approx(PG_FUNCTION_ARGS) HeapTuple ret; int i = 0; - if (!superuser()) + if (!superuser() && !has_rolreplication(GetUserId())) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("must be superuser to use pgstattuple functions")))); + (errmsg("must be superuser or replication role to run this function")))); + if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) elog(ERROR, "return type must be a row type");