Re: BUG #18170: Unexpected error: no relation entry for relid 3

From: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, zuming(dot)jiang(at)inf(dot)ethz(dot)ch, pgsql-bugs(at)lists(dot)postgresql(dot)org, Alexander Korotkov <akorotkov(at)postgresql(dot)org>
Subject: Re: BUG #18170: Unexpected error: no relation entry for relid 3
Date: 2023-10-31 05:05:35
Message-ID: 7332bc61-a9fa-464b-b5a4-4e8e0f764a64@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 30/10/2023 13:24, Richard Guo wrote:
>
> On Mon, Oct 30, 2023 at 10:47 AM Andrei Lepikhov
> <a(dot)lepikhov(at)postgrespro(dot)ru <mailto:a(dot)lepikhov(at)postgrespro(dot)ru>> wrote:
>
> On 30/10/2023 09:24, Richard Guo wrote:
> > I also have some concerns about this patch.  It requires that
> > root->parse remains unchanged during the whole subquery_planner() in
> > order to work, which is an implicit constraint we did not have
> before.
>
> It is not about unchanged; it is about referencing the same query at
> the
> parent and child query blocks. Am I missing something?
>
>
> Yeah, that's what I meant.  We need to ensure that root->parse
> references the same Query structure during the whole subquery_planner()
> for this patch to work, which seems hacky, and error-prone for future
> development.  If we really want to do so, at least we need to emphasize
> this point in the comment of subquery_planner().

Okay, let's go another way and try to imagine what additional
opportunities it will give us in the future? I mean, save unchanged a
rte->subquery tree and, simultaneously, have some transformed version in
the subroot->parse field.
I can imagine kind of a subquery replanning procedure in the case we
realized during higher-level query planning that the underlying subquery
is not optimal.
Such a picture makes sense, and I can agree with your words. From this
point of view, all links to the subquery must reference the subroot
structures, and the patch you have proposed is the best solution. And
the SJE feature works correctly.
If we don't imagine the picture I have drawn above, it is reasonable to
save memory and not alter the parse tree while removing unneeded joins.
I think, in that case, we can use the walker procedure instead of a mutator.

--
regards,
Andrei Lepikhov
Postgres Professional

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2023-10-31 07:37:13 Re: BUG #18170: Unexpected error: no relation entry for relid 3
Previous Message Tom Lane 2023-10-30 16:23:11 Re: BUG #15172: Postgresql ts_headline with <-> operator does not highlight text properly