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

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Andrew Stuart <andrew(at)salesgrid(dot)com(dot)au>
Cc: 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:03:32
Message-ID: 8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 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

You probably want to do this rather than try to intercept every single operation in order to the reset at the end.

--
-- Christophe Pettus
xof(at)thebuild(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-01-25 05:39:36 Re: Can I use Postgres rules to reset session variables before/after queries?
Previous Message Andrew Stuart 2021-01-25 05:00:47 Can I use Postgres rules to reset session variables before/after queries?