pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christophe Pettus <xof@thebuild.com>
Cc: Andrew Stuart <andrew@salesgrid.com.au>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Can I use Postgres rules to reset session variables before/after queries?
Date: Mon, 25 Jan 2021 00:39:36 -0500
Message-ID: <1703888.1611553176@sss.pgh.pa.us> (raw)
In-Reply-To: <8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com>
References: <CAFVsTWwnmXOE-=n5CBtxyT0ubOY6upkVUU=2iPqStg1xpdcuNA@mail.gmail.com>
	<8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com>

Christophe Pettus <xof@thebuild.com> writes:
>> On Jan 24, 2021, at 21:00, Andrew Stuart <andrew@salesgrid.com.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





view thread (3+ messages)

Message-ID: <1703888.1611553176@sss.pgh.pa.us>
Permalink:  ../1703888.1611553176@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1703888.1611553176@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, xof@thebuild.com, andrew@salesgrid.com.au
  Subject: Re: Can I use Postgres rules to reset session variables before/after queries?
  In-Reply-To: <1703888.1611553176@sss.pgh.pa.us>
  References: <CAFVsTWwnmXOE-=n5CBtxyT0ubOY6upkVUU=2iPqStg1xpdcuNA@mail.gmail.com> <8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com> <1703888.1611553176@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox