backup_started_in_recovery = RecoveryInProgress();
- if (!superuser() && !is_authenticated_user_replication_role())
+ if (!superuser() && !has_rolreplication(GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or replication role to run a backup")));
backup_started_in_recovery = RecoveryInProgress();
- if (!superuser() && !is_authenticated_user_replication_role())
+ if (!superuser() && !has_rolreplication(GetUserId()))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("must be superuser or replication role to run a backup"))));
/*
- * Check if the authenticated user is a replication role
+ * Check whether specified role has explicit REPLICATION privilege
*/
bool
-is_authenticated_user_replication_role(void)
+has_rolreplication(Oid roleid)
{
bool result = false;
HeapTuple utup;
- utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(AuthenticatedUserId));
+ utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
if (HeapTupleIsValid(utup))
{
result = ((Form_pg_authid) GETSTRUCT(utup))->rolreplication;
{
Assert(!bootstrap);
- if (!superuser() && !is_authenticated_user_replication_role())
+ if (!superuser() && !has_rolreplication(GetUserId()))
ereport(FATAL,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or replication role to start walsender")));
extern void process_shared_preload_libraries(void);
extern void process_local_preload_libraries(void);
extern void pg_bindtextdomain(const char *domain);
-extern bool is_authenticated_user_replication_role(void);
+extern bool has_rolreplication(Oid roleid);
/* in access/transam/xlog.c */
extern bool BackupInProgress(void);