Re: Can I use Postgres rules to reset session variables before/after queries?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Andrew Stuart <andrew(at)salesgrid(dot)com(dot)au>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Can I use Postgres rules to reset session variables before/after queries?
Date: 2021-01-25 05:39:36
Message-ID: 1703888.1611553176@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christophe Pettus <xof(at)thebuild(dot)com> writes:
>> On Jan 24, 2021, at 21:00, Andrew Stuart <andrew(at)salesgrid(dot)com(dot)au> wrote:
>> Can anyone suggest if session variables can be SET/RESET using Postgres rules, or optionally perhaps there is a better way to do so?

> PostgreSQL poolers generally use the RESET ALL command when reassigning a session to clear the session state:
> https://www.postgresql.org/docs/current/sql-reset.html

See also DISCARD, which clears even more session state:

https://www.postgresql.org/docs/current/sql-discard.html

I concur that trying to use rules for this is unlikely to work well.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Guillaume Lelarge 2021-01-25 06:38:48 Re: CLUSTER, VACUUM, and TABLESPACEs (oh my)
Previous Message Christophe Pettus 2021-01-25 05:03:32 Re: Can I use Postgres rules to reset session variables before/after queries?