Re: A bug in make_outerjoininfo

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: A bug in make_outerjoininfo
Date: 2023-02-07 23:33:45
Message-ID: 3385719.1675812825@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Richard Guo <guofenglinux(at)gmail(dot)com> writes:
>> In b448f1c8 remove_useless_result_rtes will remove useless FromExprs and
>> merge its quals up to parent. This makes flag 'delay_upper_joins' not
>> necessary any more if the clauses between the two outer joins come from
>> FromExprs. However, if the clauses between the two outer joins come
>> from JoinExpr of an inner join, it seems we have holes in preserving
>> ordering.

> Hmm ... we'll preserve the ordering all right, but if we set commute_below
> or commute_above_x bits that don't match reality then we'll have trouble
> later with mis-marked varnullingrels, the same as we saw in b2d0e13a0.
> I don't think you need a JoinExpr, an intermediate multi-member FromExpr
> should have the same effect.

BTW, the presented test case doesn't fail anymore after the fix
for bug #17781. That's because build_joinrel_tlist() doesn't use
commute_above_l anymore at all, and is a bit more wary in its use of
commute_above_r. I'm not sure that that completely eliminates this
problem, but it at least makes it a lot harder to reach.

We might want to see if we can devise a new example (or wait for
Robins to break it ;-)) before expending a lot of effort on making
the commute_xxx bits more precise.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2023-02-08 00:20:34 Re: make_ctags: use -I option to ignore pg_node_attr macro
Previous Message Tom Lane 2023-02-07 22:32:07 Re: Generating code for query jumbling through gen_node_support.pl