Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3ubF-0000iK-Lh for pgsql-general@arkaria.postgresql.org; Mon, 25 Jan 2021 05:39:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l3ubE-0000AF-Kd for pgsql-general@arkaria.postgresql.org; Mon, 25 Jan 2021 05:39:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3ubE-0000A5-Dd for pgsql-general@lists.postgresql.org; Mon, 25 Jan 2021 05:39:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3ubC-0007Mn-4S for pgsql-general@lists.postgresql.org; Mon, 25 Jan 2021 05:39:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 10P5dawu1703889; Mon, 25 Jan 2021 00:39:36 -0500 From: Tom Lane To: Christophe Pettus cc: Andrew Stuart , pgsql-general@lists.postgresql.org Subject: Re: Can I use Postgres rules to reset session variables before/after queries? In-reply-to: <8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com> References: <8828B96C-3953-49B4-BE8D-5D6591F407F2@thebuild.com> Comments: In-reply-to Christophe Pettus message dated "Sun, 24 Jan 2021 21:03:32 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1703887.1611553176.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Jan 2021 00:39:36 -0500 Message-ID: <1703888.1611553176@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Christophe Pettus writes: >> On Jan 24, 2021, at 21:00, Andrew Stuart wrot= e: >> 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