Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r1Bze-009veg-9l for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Nov 2023 20:51:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r1Bzc-00GtIY-Ki for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Nov 2023 20:51:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r1Bzc-00GtFz-Bo for pgsql-bugs@lists.postgresql.org; Thu, 09 Nov 2023 20:51:12 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r1Bza-004nWT-0j for pgsql-bugs@lists.postgresql.org; Thu, 09 Nov 2023 20:51:11 +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 3A9Kp11n1246788; Thu, 9 Nov 2023 15:51:01 -0500 From: Tom Lane To: Richard Guo cc: marian.krucina@linuxbox.cz, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18184: ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2 In-reply-to: References: <18184-5868dd258782058e@postgresql.org> Comments: In-reply-to Richard Guo message dated "Tue, 07 Nov 2023 11:06:30 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1246786.1699563061.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 09 Nov 2023 15:51:01 -0500 Message-ID: <1246787.1699563061@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Mon, Nov 6, 2023 at 10:39 PM PG Bug reporting form < > noreply@postgresql.org> wrote: >> ERROR: wrong varnullingrels (b) (expected (b 3)) for Var 2/2 > It seems that when we optimize field selection from a whole-row Var into > a simple Var while simplifying functions, we fail to propagate the > nullingrels into the new Var. Yup, good catch! Fix pushed with a little editorializing on the test case (mainly to try to ensure cross-platform stability of its plan). > Attached is a hotfix for this error. But I'm wondering if there are > other similar cases where we have mismatched nullingrels that we haven't > discovered yet. Any thoughts? It's worrisome I agree. I looked through the other calls of makeVar() and didn't find any that seemed wrong. (There are a lot of them that are concerned with cases like manufacturing rowmark Vars, which I think are OK because we don't support FOR UPDATE on nullable rels.) Still, I wouldn't be totally surprised if we find a few more. regards, tom lane