SET LOCAL doesn't become undefined after transaction is commited - Mailing list pgsql-general

From Kostya
Subject SET LOCAL doesn't become undefined after transaction is commited
Date
Msg-id CAB_pDVVa84w7hXhzvyuMTb8f5kKV3bee_p9QTZZ58Rg7zYM7sw@mail.gmail.com
Whole thread Raw
Responses Re: SET LOCAL doesn't become undefined after transaction is commited
List pgsql-general
Hi
We are using dynamic settings via SET LOCAL for row level security.
I would like to clarify that I'm seeing the correct behaviour
I create a new session to the database, I run the following query:

SELECT current_setting("session.my_tenant_id");

I will get the following error:
pq: unrecognized configuration parameter \"session.my_tenant_id\"

However, once I run the following transaction
BEGIN READ WRITE
SET LOCAL session.my_tenant_id="f00";
SELECT * FROM someTable;
COMMIT;

Then
SELECT current_setting("session.my_tenant_id");
will return an empty string "". Basically "session.my_tenant_id" becomes defined.

Is this supposed to work like this or could this be a bug?
Is it possible to entirely undefine "session.my_tenant_id" after the transaction was committed? Basically I would like to return to the initial state of the PSQL connection.

Thanks in advance.

pgsql-general by date:

Previous
From: stan
Date:
Subject: propogate RAISE levels < EXCEPTION through MS Access?
Next
From: Norberto Dellê
Date:
Subject: PostgreSQL 10 not archiving some WAL files