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 1mOXGB-00062i-3O for pgsql-admin@arkaria.postgresql.org; Fri, 10 Sep 2021 03:31:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mOXGA-0002Ib-0q for pgsql-admin@arkaria.postgresql.org; Fri, 10 Sep 2021 03:31:26 +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 1mOXG9-0002IT-OM for pgsql-admin@lists.postgresql.org; Fri, 10 Sep 2021 03:31:25 +0000 Received: from mailout.easymail.ca ([64.68.200.34]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOXG7-0000IP-Dv for pgsql-admin@lists.postgresql.org; Fri, 10 Sep 2021 03:31:24 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 86755115059; Fri, 10 Sep 2021 03:31:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo02-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo02-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z5AvWRWzIgaR; Fri, 10 Sep 2021 03:31:21 +0000 (UTC) Received: from smtpclient.apple (unknown [4.28.96.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 2436C115056; Fri, 10 Sep 2021 03:31:21 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Is there anyway for non-superuser to log all sql statements at the session level? From: Scott Ribe In-Reply-To: Date: Thu, 9 Sep 2021 21:31:20 -0600 Cc: pgsql-admin , Dan Smith Content-Transfer-Encoding: quoted-printable Message-Id: References: <16e9ff79-fe32-4d0d-be57-7c823744a793@Spark> To: Hotmail X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sep 9, 2021, at 9:18 PM, Hotmail wrote: >=20 > Thanks for the suggestion. We currently use pgaudit at the database = level for all ddL. Unfortunately, you must be a superuser to change = pgaudit settings at the session level. Our desire is to capture the = ddl/dml for a specific session. Capturing the dml at the database level = with pgaudit would generate too much logging with our application user. = Our migrations scripts are all checked into a git repo.=20 >=20 > We would like to get specific timestamp/timing info for each migration = ddl/dml statement as it is executed. May not be possible in postgres for = a non-superuser. We recently migrated off Oracle and we were able to do = this as a non-superuser with session tracing but we are not aware = similar capabilities in postgres. Can't you use a single-purpose user to run migration scripts, and = pgaudit to log everything that user does?