Re: Remove duplicate static function check_permissions in slotfuncs.c and logicalfuncs.c
| От | Bossart, Nathan |
|---|---|
| Тема | Re: Remove duplicate static function check_permissions in slotfuncs.c and logicalfuncs.c |
| Дата | |
| Msg-id | 8B25951C-11C8-466E-9612-5DE0362083E1@amazon.com обсуждение исходный текст |
| Ответ на | Re: Remove duplicate static function check_permissions in slotfuncs.c and logicalfuncs.c ("Euler Taveira" <euler@eulerto.com>) |
| Ответы |
Re: Remove duplicate static function check_permissions in slotfuncs.c and logicalfuncs.c
|
| Список | pgsql-hackers |
On 9/11/21, 1:31 AM, "Bharath Rupireddy" <bharath.rupireddyforpostgres@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
В списке pgsql-hackers по дате отправления: