Azure Database for PostgreSQL - Flexible Server: Setting Session Replication Role in JDBC Options

lye 20 Reputation points
2024-11-21T09:37:48.5066667+00:00

Is it possible to set the session replication role in JDBC options for Azure Database for PostgreSQL - Flexible Server (Postgres v13)?

While I was able to execute SET session_replication_role = 'replica' directly in the database, I encountered an error when trying to configure it in the JDBC options: "Permission denied to set parameter 'session_replication_role'."

Here’s the JDBC connection string I used:

jdbc:postgresql://xxxx:5432/postgres?options=-c%20session_replication_role=replica

Azure Database for PostgreSQL
0 comments No comments
{count} votes

Accepted answer
  1. Sai Raghunadh M 1,295 Reputation points Microsoft Vendor
    2024-11-21T10:10:15.4933333+00:00

    Hi @lye,

    Thanks for the question and using MS Q&A platform.

    The error "Permission denied to set parameter 'session_replication_role'" happens because PostgreSQL doesn't allow certain settings to be changed by regular users. These settings, like session_replication_role, can only be modified by superusers.

    In Azure Database for PostgreSQL - Flexible Server, non-superuser accounts cannot change this parameter directly, even when using the JDBC connection string. This is done for security and performance reasons.

    User's image

    Please go through this documentation that might help you: session_replication_role

    Hope this helps. Do let us know if you any further queries. If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.