| From: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
|---|---|
| To: | Tender Wang <tndrwang(at)gmail(dot)com> |
| Cc: | Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, ammmkilo(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19435: Error: "No relation entry for relid 2" Triggered by Complex Join with Self-Referencing Tables |
| Date: | 2026-03-17 13:24:26 |
| Message-ID: | CALdSSPj1kTTQvmV3H3HMf5P3um8ybxoH3DaTPm+XgdYAur1Q4A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, 17 Mar 2026 at 18:20, Tender Wang <tndrwang(at)gmail(dot)com> wrote:
>
> Tender Wang <tndrwang(at)gmail(dot)com> 于2026年3月17日周二 20:59写道:
> >
> > The error was reported in rebuild_joinclause_attr_needed() when
> > processing Relid = 1(rtindex =1),
> > When processing its joininfo" ON tom1.col_bool IS NOT NULL",
> > (gdb) pgprint rinfo->clause
> > Var [varno=2 varattno=2 vartype=16
> > varreturningtype=VAR_RETURNING_DEFAULT varnosyn=2 varattnosyn=2]
> >
> > The varno=2, rtindex=2(tom1) has been removed. In
> > add_vars_to_attr_needed(), to find the base_rel, but the
> > root->simple_rel_array[2] is NULL.
> > So the error is reporting.
> > It seems the joininfo should be replaced by rtindex = 3, because the
> > rtindex=2 would be removed.
> > --
> (gdb) pgprint rinfo
> RestrictInfo [is_pushed_down=false can_join=false pseudoconstant=false
> has_clone=true is_clone=false leakproof=false
> has_volatile=VOLATILITY_UNKNOWN security_level=0
> num_base_rels=1 rinfo_serial=4 eval_cost={startup = -1,
> per_tuple = 0} norm_selec=-1 outer_selec=-1 outer_is_left=false
> hashjoinoperator=0 left_bucketsize=-1
> right_bucketsize=-1 left_mcvfreq=-1 right_mcvfreq=-1
> left_hasheqoperator=0 right_hasheqoperator=0]
> [clause] Var [varno=2 varattno=2 vartype=16
> varreturningtype=VAR_RETURNING_DEFAULT varnosyn=2 varattnosyn=2]
> [clause_relids] Bitmapset [3]
> [required_relids] Bitmapset [3 1]
> [incompatible_relids] Bitmapset [7 6]
> [outer_relids] Bitmapset [6 5 3]
>
> The above is the joininfo of the rtindex=1(tom0), we can see that the
> required_relids is changed to [3 1], but the clause is still
> rtindex=2(varno=2).
> I guess the current logic in remove_self_join_rel() may forget to
> process the rinfo->clause.
Yes, it looks like your analysis is valid. Will you share a patch for
updating `clause` ?
--
Best regards,
Kirill Reshke
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tender Wang | 2026-03-17 13:30:44 | Re: BUG #19435: Error: "No relation entry for relid 2" Triggered by Complex Join with Self-Referencing Tables |
| Previous Message | Tender Wang | 2026-03-17 13:19:45 | Re: BUG #19435: Error: "No relation entry for relid 2" Triggered by Complex Join with Self-Referencing Tables |