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 1lbalN-0006aj-4t for pgsql-committers@arkaria.postgresql.org; Wed, 28 Apr 2021 03:21:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lbalL-0006xw-26 for pgsql-committers@arkaria.postgresql.org; Wed, 28 Apr 2021 03:21:19 +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 1lbalK-0006xp-Ss for pgsql-committers@lists.postgresql.org; Wed, 28 Apr 2021 03:21:18 +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 1lbalE-0001pA-DQ; Wed, 28 Apr 2021 03:21:17 +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 13S3LAZO2760470; Tue, 27 Apr 2021 23:21:10 -0400 From: Tom Lane To: Amit Kapila cc: Amit Kapila , pgsql-committers Subject: Re: pgsql: Implement streaming mode in ReorderBuffer. In-reply-to: References: <2752962.1619568098@sss.pgh.pa.us> Comments: In-reply-to Amit Kapila message dated "Wed, 28 Apr 2021 08:24:06 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2760468.1619580070.1@sss.pgh.pa.us> Date: Tue, 27 Apr 2021 23:21:10 -0400 Message-ID: <2760469.1619580070@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amit Kapila writes: > On Wed, Apr 28, 2021 at 5:31 AM Tom Lane wrote: >> It's griping about this: >> curtxn->concurrent_abort = true; >> and I think it's got a point. There is little if any reason to have >> confidence that curtxn must be non-NULL when this code is reached, >> because it's in a PG_CATCH segment and there is a lot of code within >> the PG_TRY that could throw an error before the spot where curtxn >> is set. Not to mention that curtxn is set only conditionally. > We can do that to silence this Warning, otherwise, there won't be any > problem because it is set only when we get a particular error code and > we can get that error code only when the conditions that lead to > curtxn being set are met. To be blunt, that argument is hopelessly naive. You cannot safely make assumptions about a CATCH block having omniscient knowledge of where an error was thrown from. At least, not with a check no stronger than checking the SQLSTATE. All you need is some extension ... or a user-defined function ... deciding to throw that same SQLSTATE, and you're hosed. If this code really does make the assumption that there's only one possible cause of that SQLSTATE, I wonder whether it's broken in ways worse than a mere core dump. regards, tom lane