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 1g5AvP-0002yK-3h for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Sep 2018 14:36:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5AvK-0004Gy-KT for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Sep 2018 14:36:18 +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 1g5AvK-0004Gr-9f for pgsql-hackers@lists.postgresql.org; Wed, 26 Sep 2018 14:36:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5AvC-0002aj-SA for pgsql-hackers@postgresql.org; Wed, 26 Sep 2018 14:36:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8QEa1HV003265; Wed, 26 Sep 2018 10:36:01 -0400 From: Tom Lane To: Alvaro Herrera cc: Bruce Momjian , Peter Eisentraut , Michael Paquier , Andres Freund , PostgreSQL-development Subject: Re: transction_timestamp() inside of procedures In-reply-to: <20180926141336.z7gpojck3tpruqwv@alvherre.pgsql> References: <20180926141336.z7gpojck3tpruqwv@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 26 Sep 2018 11:13:36 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3263.1537972561.1@sss.pgh.pa.us> Date: Wed, 26 Sep 2018 10:36:01 -0400 Message-ID: <3264.1537972561@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2018-Sep-26, Tom Lane wrote: >> I agree that it would be surprising for transaction timestamp to be newer >> than statement timestamp. So for now at least, I'd be satisfied with >> documenting the behavior. > Really? I thought it was practically obvious that for transaction- > controlling procedures, the transaction timestamp would not necessarily > be aligned with the statement timestamp. The surprise would come > together with the usage of the new feature, so existing users would not > be surprised in any way. Nope. That's the same poor reasoning we've fallen into in some other cases, of assuming that "the user" is a point source of knowledge. But DBMSes tend to interact with lots of different code. If some part of application A starts using intraprocedure transactions, and then application B breaks because it wasn't expecting to see xact_start later than query_start in pg_stat_activity, you've still got a problem. I'm also a bit hesitant to invent new semantics here based on the assumption that we've got only one, nonoverlapping, top-level transaction at a time. It's not terribly hard to imagine suspend-and-resume- transaction features coming down the pike at some point. What will we do then? We'll already have a definitional issue for xact_start, but it'll get worse the more different kinds of xact_start we have. regards, tom lane