pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: shihao zhong <zhong950419@gmail.com>
Cc: alpkeles99@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19784: "no relation entry for relid 1" when costing = ANY (<array expr over max(col)>) in a MinMaxAggPath
Date: Fri, 23 Oct 2026 12:09:58 -0400
Message-ID: <3087487.1792771798@sss.pgh.pa.us> (raw)
In-Reply-To: <2962069.1792767739@sss.pgh.pa.us>
References: <19784-93f76236decd0656@postgresql.org>
	<2828180.1792700071@sss.pgh.pa.us>
	<CAGRkXqSqDDwfPFyvpbb7APi3KM0SEH7yX9zbZUG9_yyhHMFjKA@mail.gmail.com>
	<2962069.1792767739@sss.pgh.pa.us>

shihao zhong <zhong950419@gmail.com> 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 <rguo@postgresql.org>
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






view thread (8+ messages)  latest in thread

Message-ID: <3087487.1792771798@sss.pgh.pa.us>
Permalink:  ../3087487.1792771798@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3087487.1792771798@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, guofenglinux@gmail.com, zhong950419@gmail.com, alpkeles99@gmail.com
  Subject: Re: BUG #19784: "no relation entry for relid 1" when costing = ANY (<array expr over max(col)>) in a MinMaxAggPath
  In-Reply-To: <3087487.1792771798@sss.pgh.pa.us>
  References: <19784-93f76236decd0656@postgresql.org> <2828180.1792700071@sss.pgh.pa.us> <CAGRkXqSqDDwfPFyvpbb7APi3KM0SEH7yX9zbZUG9_yyhHMFjKA@mail.gmail.com> <2962069.1792767739@sss.pgh.pa.us> <3087487.1792771798@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox