Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7LTh-0001tp-C7 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Oct 2018 14:16:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g7LTe-0004Qk-T8 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Oct 2018 14:16:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7LTa-0003yw-Lp for pgsql-hackers@lists.postgresql.org; Tue, 02 Oct 2018 14:16:38 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g7LTT-0003Qv-3M for pgsql-hackers@postgresql.org; Tue, 02 Oct 2018 14:16:36 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1g7LTR-0007Wg-1e; Tue, 02 Oct 2018 10:16:29 -0400 Date: Tue, 2 Oct 2018 10:16:29 -0400 From: Bruce Momjian To: Peter Eisentraut Cc: PostgreSQL-development , Alvaro Herrera , Tom Lane , Michael Paquier , Andres Freund Subject: Re: transction_timestamp() inside of procedures Message-ID: <20181002141629.GA22680@momjian.us> References: <20180926155443.u4zh7jactzflys3z@alvherre.pgsql> <4ff8e6a2-c585-02fe-3f20-b9aa26fa2c4f@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ff8e6a2-c585-02fe-3f20-b9aa26fa2c4f@2ndquadrant.com> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Oct 2, 2018 at 10:55:56AM +0200, Peter Eisentraut wrote: > On 28/09/2018 09:35, Peter Eisentraut wrote: > >> That's certainly a good argument. Note that if we implemented that the > >> transaction timestamp is advanced inside procedures, that would also > >> mean that the transaction timestamp as observed in pg_stat_activity > >> would move during VACUUM, for example. That might or might not be > >> desirable. > > > > Attached is a rough implementation. > > > > I'd be mildly in favor of doing this, but we have mentioned tradeoffs in > > this thread. > > So do we want to do this or not? I thought some more about this. I think there are a few issues: 1 Utility: since you can't use CALL in a transaction block, our current code will always have transaction_timestamp() and statement_timestamp() as identical in a procedure. Having transaction_timestamp() advance on COMMIT gives users a new ability. 2 Surprise: What do people use transaction_timestamp() for and what behavior would be most expected? 3 Other databases: How do other database systems handle this, and the SQL standard? Based on 1 and 2, I suggest we change transaction_timestamp() to advance on COMMIT in procedure, and document this. I have no idea on #3. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +