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 1mb2fu-0002KB-Qe for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Oct 2021 15:29:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mb2ft-00046c-O7 for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Oct 2021 15:29:41 +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 1mb2ft-0003v6-Fm for pgsql-bugs@lists.postgresql.org; Thu, 14 Oct 2021 15:29:41 +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 1mb2fr-0004Tn-57 for pgsql-bugs@lists.postgresql.org; Thu, 14 Oct 2021 15:29:40 +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 19EFTXdG794911; Thu, 14 Oct 2021 11:29:34 -0400 From: Tom Lane To: Alvaro Herrera cc: bernddorn@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17227: segmentation fault with jsonb_to_recordset In-reply-to: <709405.1634165890@sss.pgh.pa.us> References: <202110131359.a6m35hpudkg7@alvherre.pgsql> <649678.1634135335@sss.pgh.pa.us> <675396.1634157283@sss.pgh.pa.us> <676464.1634158492@sss.pgh.pa.us> <709405.1634165890@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 13 Oct 2021 18:58:10 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <794909.1634225373.1@sss.pgh.pa.us> Date: Thu, 14 Oct 2021 11:29:33 -0400 Message-ID: <794910.1634225373@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > The whole thing makes me itch a little bit, because this logic is > assuming that eval_const_expressions is idempotent, something > we can't test very well and (AFAIR) are not assuming anywhere else. > If somebody made some sub-case not idempotent, we'd not notice until > that case got used in a lateral function RTE. It occurred to me that we could test for problems with double execution of eval_const_expressions by making planner.c deliberately call it twice in all cases. A quick hack later, I can say that "make check-world" doesn't reveal any such problem. While that's hardly conclusive, it's pretty strong evidence, since the code coverage report shows eval_const_expressions as well covered (and the lines not reached are mostly returning simplified Const nodes, so hardly likely to be a problem here). We could make a persistent check for that by enclosing the extra calls in something like "#ifdef DOUBLE_EVAL_CONST_EXPRESSIONS" and setting up some buildfarm member to define that. But since (AFAIR) we've never actually had such a bug, it seems unlikely to be worth the trouble. I'll go ahead with the patch as presented. regards, tom lane