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 1g59Ig-00033h-J4 for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Sep 2018 12:52:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g59Ie-0004fW-No for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Sep 2018 12:52:16 +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 1g59Ie-0004fP-Ct for pgsql-hackers@lists.postgresql.org; Wed, 26 Sep 2018 12:52:16 +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 1g59IX-0000KW-9R for pgsql-hackers@postgresql.org; Wed, 26 Sep 2018 12:52:14 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1g59IV-0002oo-Di; Wed, 26 Sep 2018 08:52:07 -0400 Date: Wed, 26 Sep 2018 08:52:07 -0400 From: Bruce Momjian To: Peter Eisentraut Cc: Michael Paquier , Andres Freund , PostgreSQL-development Subject: Re: transction_timestamp() inside of procedures Message-ID: <20180926125207.GA10161@momjian.us> References: <20180920234040.GC29981@momjian.us> <20180921045536.GJ1338@paquier.xyz> <20180921051206.bzfiew4nthmunpbj@alap3.anarazel.de> <20180921053425.GM1338@paquier.xyz> <20180921102822.GA22699@momjian.us> <20180921223502.GA18319@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Sep 26, 2018 at 02:38:25PM +0200, Peter Eisentraut wrote: > On 22/09/2018 00:35, Bruce Momjian wrote: > > I have always thought of clock/statement/transation as decreasing levels > > of time precision, and it might be odd to change that. I don't think we > > want to change the behavior of statement_timestamp() in procedures, so > > that kind of requires us not to change transaction_timestamp() inside of > > procedures. > > > > However, no change in behavior causes the problem that if you have a > > transaction block using transaction_timestamp() or CURRENT_TIMESTAMP, > > and you move it into a procedure, the behavior of those functions will > > change, but this was always true of moving statement_timestamp() into a > > function, and I have never heard a complaint about that. > > Right. Statement timestamp actually means the timestamp of the > top-level statement, because it's set where the protocol interaction > happens. The transaction timestamp is implemented as the statement > timestamp when the transaction starts, but for intra-procedural > transactions, the statement timestamp does not advance, so the > transaction timestamp doesn't change. > > Note that this also affects the xact_start column in pg_stat_activity. > > We could certainly address this by adding three or four or five new > timestamps that cover all these varieties. But perhaps it's worth > asking what these timestamps are useful for and which ones we really need. Frankly, we might be fine with just documenting it and see if anyone complains. I think the top-level statement part is obvious, but I am not sure the top-level transaction part is. This is because it is clear the top-level statement causes all the lower statements underneath it, but the top-level transaction doesn't control all the transactions under it in the same way. -- 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 +