check_source_privileges

Function check_source_privileges 

Source
pub async fn check_source_privileges(client: &Client) -> Result<PrivilegeCheck>
Expand description

Check if connected user has replication privileges (needed for source)

Queries pg_roles to determine the privileges of the currently connected user. For source databases, the user must have REPLICATION privilege (or be a superuser) to enable logical replication.

§Arguments

  • client - Connected PostgreSQL client

§Returns

Returns a PrivilegeCheck containing the user’s privileges.

§Errors

This function will return an error if the database query fails.

§Examples

let client = connect("postgresql://user:pass@localhost:5432/mydb").await?;
let privs = check_source_privileges(&client).await?;
assert!(privs.has_replication || privs.is_superuser);