From 484ea6857e408f26e56ab496fd5313f1d4c955cc 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 0bfd7d1..c821260 100644 --- a/pgstatapprox.c +++ b/pgstatapprox.c @@ -245,10 +245,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");