On 9/11/21, 1:31 AM, "Bharath Rupireddy" <bharath.rupireddyforpostg...@gmail.com> wrote: > We have two static check_permissions functions (one in slotfuncs.c > another in logicalfuncs.c) with the same name and same code for > checking the privileges for using replication slots. Why can't we have > a single function CheckReplicationSlotPermissions in slot.c? This way, > we can get rid of redundant code. Attaching a patch for it.
+1 +/* + * Check whether the user has privilege to use replication slots. + */ +void +CheckReplicationSlotPermissions(void) +{ + if (!superuser() && !has_rolreplication(GetUserId())) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + (errmsg("must be superuser or replication role to use replication slots")))); +} nitpick: It looks like there's an extra set of parentheses around errmsg(). Nathan