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 1pbohl-0006f4-5K for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Mar 2023 20:23:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbohk-0003GI-4C for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Mar 2023 20:23:36 +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 1pbohj-0003G1-SL for pgsql-bugs@lists.postgresql.org; Mon, 13 Mar 2023 20:23:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbohh-0000Bk-G8 for pgsql-bugs@lists.postgresql.org; Mon, 13 Mar 2023 20:23:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32DKNVF72179741; Mon, 13 Mar 2023 16:23:32 -0400 From: Tom Lane To: 857348270@qq.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17837: The potential risks associated with executing "commit" in a procedure. In-reply-to: <17837-9e65be9846767162@postgresql.org> References: <17837-9e65be9846767162@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 13 Mar 2023 12:40:11 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2179739.1678739011.1@sss.pgh.pa.us> Date: Mon, 13 Mar 2023 16:23:31 -0400 Message-ID: <2179740.1678739011@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > Recently, I have noticed that executing "commit" in a procedure calls > PreCommit_Portals in the kernel, which sets the resowner of the top level > portal to null. However, subsequent statements still use this portal, and > its resowner remains null. Is there any risk associated with this or could > it lead to unexpected behavior? I do not see any reason to believe there's a bug here. After the COMMIT, CurrentResourceOwner won't be pointing at the portal's resowner anymore, but at a resowner belonging to the newly-started transaction (cf AtStart_ResourceOwner). The portal's resowner would only have been used for resources that went away at commit, so it's not needed anymore. Nor is there any code that would try to re-install that resowner as active. regards, tom lane