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 1mEHEv-0007lc-EG for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 20:23:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mEHEO-0001uk-KW for pgsql-general@arkaria.postgresql.org; Thu, 12 Aug 2021 20:23:12 +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 1mEHEO-0001sC-BZ for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 20:23:12 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEHEL-0003J2-BS for pgsql-general@lists.postgresql.org; Thu, 12 Aug 2021 20:23:11 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1mEHEK-0000C1-46; Thu, 12 Aug 2021 16:23:08 -0400 Date: Thu, 12 Aug 2021 16:23:08 -0400 From: Bruce Momjian To: Mladen Gogala Cc: pgsql-general Subject: Re: log_statement GUC parameter Message-ID: <20210812202308.GA4822@momjian.us> References: <510207d8-8895-c3cb-e0a1-55135e4ce4f7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <510207d8-8895-c3cb-e0a1-55135e4ce4f7@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Aug 12, 2021 at 04:19:18PM -0400, Mladen Gogala wrote: > Hi! > > 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. > > The idea is to log all statements by the particular user, not by everybody. > The user in question uses Weblogic 12.2.1.4  and creates a connection pool > so I need to find out which statements are the longest running ones and make > them perform. I think you can write a SECURITY DEFINER function that calls SET, call that function at login. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.