Re: Inconsistent nullingrels due to oversight in deconstruct_distribute_oj_quals

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>, Robins Tharakan <tharakan(at)gmail(dot)com>
Subject: Re: Inconsistent nullingrels due to oversight in deconstruct_distribute_oj_quals
Date: 2023-02-10 18:40:30
Message-ID: 4180876.1676054430@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:
> However, for 'above_sjinfo' case, we should not use
> othersj->syn_righthand, because othersj->syn_righthand contains relids
> in sjinfo's righthand which should not be nulled by othersj after the
> commutation. It seems what we should use here is sjinfo->syn_lefthand.

I had a hard time wrapping my brain around that to start with, but
now I think you're right. othersj is syntactically above the current
join, so its syn_righthand will cover all of the current join, but
we only want to add nulling bits to Vars of the current join's LHS.
(That is, we need to transform Pbc to Pb*c, not Pb*c*.)

I also realized that there was a fairly critical nearby bug:
make_outerjoininfo was failing to check whether the upper join's qual
is actually of the form "Pbc", without any references to the lower join's
LHS. So that led us to setting commute bits in some cases where we
shouldn't, further confusing deconstruct_distribute_oj_quals. (I think
this snuck in because its other code path doesn't need to make such a
check, it being syntactically impossible to have such a reference if
we start from the other form of the identity.)

Fix pushed. This seems to take care of Robins' latest example in
the bug #17781 thread [1], too.

regards, tom lane

[1] https://postgr.es/m/CAEP4nAx9C5gXNBfEA0JBfz7B+5f1Bawt-RWQWyhev-wdps8BZA@mail.gmail.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-02-10 18:51:20 Re: pg_usleep for multisecond delays
Previous Message Nikita Malakhov 2023-02-10 18:22:14 Re: [PATCH] Compression dictionaries for JSONB