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 1mEHLL-0007v5-PC for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 20:30:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mEHLK-0004O5-Nx for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 20:30:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEHLK-0004Nw-Ev for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 20:30:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEHLE-00006E-88 for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 20:30:21 +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 17CKUCG64105593; Thu, 12 Aug 2021 16:30:12 -0400 From: Tom Lane To: Mladen Gogala cc: pgsql-general Subject: Re: log_statement GUC parameter In-reply-to: <510207d8-8895-c3cb-e0a1-55135e4ce4f7@gmail.com> References: <510207d8-8895-c3cb-e0a1-55135e4ce4f7@gmail.com> Comments: In-reply-to Mladen Gogala message dated "Thu, 12 Aug 2021 16:19:18 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4105591.1628800212.1@sss.pgh.pa.us> Date: Thu, 12 Aug 2021 16:30:12 -0400 Message-ID: <4105592.1628800212@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mladen Gogala writes: > Unfortunately, only a superuser can set log_statement='all'; Would it be > possible to execute set session log_statement='all'; as an ordinary > user? I am trying to execute it from login.sql, a part of login_hook > extension which implements on-login triggers in PostgreSQL. I will > create a procedure with security definer, owned by the role "postgres", > and grant it to public. That should do the trick. However, it would be > much nicer if PostgreSQL allowed me to set the parameter as a part of > the normal session. If an ordinary user could manipulate that parameter, he could equally well hide his activities from the system log. Conversely, if the postmaster log setup is such that not a lot of volume is expected, then flooding it with extra traffic could create its own set of problems. Thus, basically all parameters that affect what is logged are superuser-only, and it'd be a hard sell to weaken that. The SECURITY DEFINER function approach is your best bet for poking local exceptions into that policy. regards, tom lane