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

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, 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-30 02:01:02
Message-ID: CAMbWs4-8Pk9TjTs3C74tLb+fGdcrD1Prn5nK+XTpKR0Rn2PowQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Oct 27, 2023 at 10:41 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> > Alternatively, can we look at subroot->parse->targetList instead of
> > subquery->targetList where we call estimate_num_groups on the output of
> > the subquery?
>
> Please read the comment just above that.

Hmm, I understand that we cannot look at subroot->processed_tlist here
because of the "varno 0" hack explained in the comment. But what I
proposed is to look at subroot->parse->targetList, which should be fine
because the tlist generated by generate_append_tlist would only be
returned into processed_tlist not the original parse->targetList. For
instance, the query below still works if we look at
subroot->parse->targetList, even though the subquery is itself a setop.

(SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) INTERSECT SELECT 4,5,6;
?column? | ?column? | ?column?
----------+----------+----------
4 | 5 | 6
(1 row)

Thanks
Richard

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2023-10-30 02:24:11 Re: BUG #18170: Unexpected error: no relation entry for relid 3
Previous Message Tom Lane 2023-10-29 15:56:56 Re: BUG #18170: Unexpected error: no relation entry for relid 3