On Thu, May 18, 2023 at 3:34 AM Tom Lane <t...@sss.pgh.pa.us> wrote:

> After some poking at it I hit on what seems like a really simple
> solution: we should be checking syn_righthand not min_righthand
> to see whether a Var should be considered nullable by a given OJ.
> Maybe that's still not quite right, but it seems like it might be
> right given that the last fix reaffirmed our conviction that Vars
> should be marked according to the syntactic structure.


I thought about this solution before but proved it was not right in
https://www.postgresql.org/message-id/CAMbWs48fObJJ%3DYVb4ip8tnwxwixUNKUThfnA1eGfPzJxJRRgZQ%40mail.gmail.com

I checked the query shown there and it still fails with v3 patch.

explain (costs off)
select * from t1
    left join (select t2.x from t2
                      left join t3 on t2.x where t3.x is null) s
    left join t4 on s.x
on s.x = t1.x;
server closed the connection unexpectedly

The failure happens when we are forming the join of (t1/t2) to t3.
Consider qual 't3.x is null'.  It's a non-clone filter clause so
clause_is_computable_at is supposed to think it's applicable here.  We
have an Assert for that.  However, when checking outer join t1/t2, which
has been performed but is not listed in the qual's nullingrels,
clause_is_computable_at would think it'd null vars of the qual if we
check syn_righthand not min_righthand, and get a conclusion that the
qual is not applicable here.  This is how the Assert is triggered.

Thanks
Richard

Reply via email to