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 1mOc7g-0001LE-QA for pgsql-admin@arkaria.postgresql.org; Fri, 10 Sep 2021 08:43:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mOc7f-0006bm-6A for pgsql-admin@arkaria.postgresql.org; Fri, 10 Sep 2021 08:42:59 +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 1mOc7e-0006be-Tn for pgsql-admin@lists.postgresql.org; Fri, 10 Sep 2021 08:42:58 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOc7d-0002og-5K for pgsql-admin@lists.postgresql.org; Fri, 10 Sep 2021 08:42:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tbhIYOm7yF9kFHCSEK2Bx68h0JMMyAqfuDLO0mlHP5c=; b=kid+td428HnRndFZP0VIMToN9z 6LFuNNR+YgbIGGkKbz3BXKi54I/DRs9kN5idXXha7Xce8pKfYjbmm8cs3sp5r3yqgAE5gQ1z0gV01 daFTP41pwLQdSREyHqhKQCV1PtHrJRtfeRWy5lcAGizW297XVDpVJFuvmdOjTZtzulRA=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1mOc7b-0003TM-Pd; Fri, 10 Sep 2021 10:42:55 +0200 Date: Fri, 10 Sep 2021 10:42:55 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Hotmail Cc: pgsql-admin@lists.postgresql.org Subject: Re: Is there anyway for non-superuser to log all sql statements at the session level? Message-ID: <20210910084255.GB11352@depesz.com> Reply-To: depesz@depesz.com References: <16e9ff79-fe32-4d0d-be57-7c823744a793@Spark> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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, Sep 09, 2021 at 05:30:55PM -0600, Hotmail wrote: > We use liquibase to run migrations against our postgres 11 database. > We run the migrations as an application user that does not have > superuser permissions. Is there any workaround we could use that would > allow us to capture the migration sql that is run by our application > user? We want to capture all of the ddl as well as the dml run by the > migration user. Since setting log_statement=all  at the session level > isn’t possible unless the user is a superuser is there any other way > to accomplish this task? Sure. Make a security-definer function that changes the log_statement, and grant privileges to call it to whoever you need. Best regards, depesz