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.98.2) (envelope-from ) id 1xKHqF-00000000m4V-4BAn for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Oct 2026 16:10:04 +0000 Received: from localhost ([127.0.0.1]:44838 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xKHqF-0000000GTX2-236t for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Oct 2026 16:10:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:42728) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xKHqF-0000000GTWu-0uXE for pgsql-bugs@lists.postgresql.org; Fri, 23 Oct 2026 16:10:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xKHqC-00000000bcI-3L9S for pgsql-bugs@lists.postgresql.org; Fri, 23 Oct 2026 16:10:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 69NG9wQC3087488; Fri, 23 Oct 2026 12:09:58 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 sss.pgh.pa.us 69NG9wQC3087488 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sss.pgh.pa.us; s=default; t=1792771798; bh=PKVFH9rMLni4pzvuMccd33UPyAUigoYgYf6s8HUNGoA=; h=From:To:cc:Subject:In-reply-to:References:Date:From; b=rPMLrP/4rH2QShHzeXBpmq+wplO6H7TbkQwSlTQM8AasWFfTJVtGe2aTKuRrEpehu v32n7SVFQO4MnMFtsPSBQGztR8QaFI1h6Z7z40HXtzQirLS/gbLg+isEuw0QMpe/hB qePYWmOcu/G8l17/Ojd/IopJxNWjZA24rCZtXINA= From: Tom Lane To: Richard Guo cc: shihao zhong , alpkeles99@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19784: "no relation entry for relid 1" when costing = ANY () in a MinMaxAggPath In-reply-to: <2962069.1792767739@sss.pgh.pa.us> References: <19784-93f76236decd0656@postgresql.org> <2828180.1792700071@sss.pgh.pa.us> <2962069.1792767739@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 23 Oct 2026 11:02:19 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3087486.1792771798.1@sss.pgh.pa.us> Date: Fri, 23 Oct 2026 12:09:58 -0400 Message-ID: <3087487.1792771798@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk shihao zhong writes: >> It does not fix this: >> CREATE TABLE ei (a int4[]); >> CREATE INDEX ON ei >> ((((1 = ANY (a))::int + (2 = ANY (a))::int) <@ int4range(0, 5))); >> SELECT * FROM ei; >> ERROR: no relation entry for relid 1 BTW, I wondered when that failure started, and found that git bisect pins it on c925ad30b047ec1388247539e86729d584c34b8d is the first bad commit commit c925ad30b047ec1388247539e86729d584c34b8d Author: Richard Guo Date: Tue Dec 9 16:56:26 2025 +0900 Fix const-simplification for index expressions and predicate ... Because we need to cache the const-simplified index expressions and predicate in the relcache entry, we cannot fix the Vars before applying eval_const_expressions. To ensure proper reduction of NullTest clauses, this patch runs eval_const_expressions a second time -- after the Vars have been fixed and with a valid root. So I'm thinking there is a problem here. This commit appears to be supposing that it's accomplishing something by running eval_const_expressions with baserel data available -- but as this failure shows, the baserel data *isn't* available yet. So even with a fix that prevents examine_variable from failing, it seems likely that we are not managing to reduce index expressions the same as we will reduce query expressions later. Not very sure what to do about that. Maybe index expressions have to be loaded in a second pass after we've set up baserel data? Maybe the idea of caching them in relcache has to be abandoned (or at least we have to rethink whether we can cache an eval'd form of them)? regards, tom lane