| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | francois(dot)jehl(at)pigment(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |
| Date: | 2026-04-20 02:51:02 |
| Message-ID: | CAMbWs4_nNfYktwQu4vNbienz+6oKXeE1Vzq9K_qH9F19MaJoMQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Mon, Apr 20, 2026 at 11:32 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> > On Mon, Apr 20, 2026 at 10:26 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> Thanks for looking at it! There is a loose end still bothering me:
> >> if you remove the lower "WHERE t.id = ..." clause, or change it to be
> >> something other than an equality constraint on t.id, the bug doesn't
> >> manifest. The reason for that is un-obvious.
> > The reason seems to be that the equality constraint is a restriction
> > clause for the inner relation 't', and is needed to determine that the
> > relation has a matching unique index and is therefore distinct. If we
> > remove it, or change it to something that isn't mergejoinable, we
> > won't be able to prove the inner side of the left join is distinct,
> > and thus won't be able to remove that left join.
> Hmm. The bug also goes away if "t" doesn't have a unique/pkey
> constraint, and I find that easy to understand: we can't apply outer
> join removal unless rel_supports_distinctness/rel_is_distinct_for
> succeed, so that this buggy code in remove_rel_from_restrictinfo
> is not reached. But that logic doesn't consider WHERE constraints
> AFAICS. So I think there is some other code path involved.
Hmm, relation_has_unique_index_for does consider the lower "WHERE t.id
= ..." clause, as that clause is a restriction clause for "t", and
relation_has_unique_index_for automatically adds any usable
restriction clauses for the rel.
- Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-04-20 08:29:00 | Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34 <JSON value constructor> |
| Previous Message | Tom Lane | 2026-04-20 02:32:24 | Re: BUG #19460: FULL JOIN rewriting issue on empty queries |