mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Remove code duplication for permission checks with replication slots
Two functions, both named check_permissions(), used the same checks to verify if a user had required privileges to work on replication slots. This commit removes the duplication, and moves the function doing the checks to slot.c to be centralized. Author: Bharath Rupireddy Reviewed-by: Nathan Bossart, Euler Taveira Discussion: https://postgr.es/m/CALj2ACUPpVw1u7sQocFVWrSs0n10pt_G_4NPZKSxXK6cW1dErw@mail.gmail.com
This commit is contained in:
@ -95,15 +95,6 @@ LogicalOutputWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xi
|
||||
p->returned_rows++;
|
||||
}
|
||||
|
||||
static void
|
||||
check_permissions(void)
|
||||
{
|
||||
if (!superuser() && !has_rolreplication(GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser or replication role to use replication slots")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function for the various SQL callable logical decoding functions.
|
||||
*/
|
||||
@ -124,7 +115,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
|
||||
List *options = NIL;
|
||||
DecodingOutputState *p;
|
||||
|
||||
check_permissions();
|
||||
CheckSlotPermissions();
|
||||
|
||||
CheckLogicalDecodingRequirements();
|
||||
|
||||
|
Reference in New Issue
Block a user