Re: Assert failure of the cross-check for nullingrels

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assert failure of the cross-check for nullingrels
Date: 2023-05-20 15:24:30
Message-ID: 841511.1684596270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> I tried with v4 patch and find that, as you predicted, it might reject
> all the clones in some cases. Check the query below
> ...
> So the qual 't3.a = t4.a' is missing in this plan shape.

I poked into that more closely and realized that the reason that
clause_is_computable_at() misbehaves is that both clones of the
"t3.a = t4.a" qual have the same clause_relids: (4 5 6) which is
t3, the left join to t3, and t4. This is unsurprising because
the difference in these clones is whether they are expected to be
evaluated above or below outer join 3 (the left join to t2), and
t2 doesn't appear in the qual. (It does appear in "t2.b = t4.b",
which is why there's no similar misbehavior for that qual.)

If they have the same clause_relids, then clearly in its current
form clause_is_computable_at() cannot distinguish them. So what
I now think we should do is have clause_is_computable_at() examine
their required_relids instead. Those will be different, by
construction in deconstruct_distribute_oj_quals(), ensuring that
we select only one of the group of clones.

BTW, while I've not tried it, I suspect your v2 patch also fails
on this example for the same reason: it cannot distinguish the
clones of this qual.

regards, tom lane

Attachment Content-Type Size
v5-0001-fix-clause_is_computable_at.patch text/x-diff 5.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2023-05-20 16:00:01 Re: pgbench: using prepared BEGIN statement in a pipeline could cause an error
Previous Message Andrew Dunstan 2023-05-20 14:01:44 Re: New COPY options: DELIMITER NONE and QUOTE NONE