Re: assertion failure with unique index + partitioning + join

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Kuzmenkov <akuzmenkov(at)tigerdata(dot)com>
Subject: Re: assertion failure with unique index + partitioning + join
Date: 2026-06-17 02:00:35
Message-ID: CAHewXNkWgnxMaZyYjEWXVTDYdQi-JdTBOTEu4W6NkrYgskyYZw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Richard Guo <guofenglinux(at)gmail(dot)com> 于2026年6月16日周二 16:27写道:
> I think we can fix it by stripping the removed relids from the PHVs in
> surviving rels' baserestrictinfo and in EquivalenceClass member
> expressions. See attached.

I spent some time reviewing the patch in detail.
A couple of minor suggestions:
In remove_rel_from_eclass(), we have
...
if (!IsA(em->em_expr, Var))
em->em_expr = (Expr *)
remove_rel_from_phvs((Node *) em->em_expr, relid, ojrelid);
...
"where s.id = 1" in the test case, the Const node seems to be able to skip, too.

Other than the minor suggestions above, the patch looks good to me.

I have another question, although it's unrelated to this bug.
The logic in remove_rel_from_query() makes me a bit uneasy. It
currently has to handle both self-join and outer-join cases,
and it seems possible that inner-join-specific handling could end up
being added there in the future as well.
The function appears to be taking on multiple distinct
responsibilities, which makes the overall design feel somewhat
awkward.

Perhaps this could be improved as part of your future inner-join removal patch.

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-06-17 02:18:42 Re: Fast-path FK checks reject valid inserts for domain-typed FK columns
Previous Message Peter Smith 2026-06-17 01:53:40 Re: Support EXCEPT for TABLES IN SCHEMA publications