Re: BUG #17781: Assert in setrefs.c

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Robins Tharakan <tharakan@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2023-02-08T17:11:52Z
Lists: pgsql-bugs
Richard Guo <guofenglinux@gmail.com> writes:
> Hmm. I begin to wonder if it's better to use phinfo->ph_eval_at instead
> in build_joinrel_tlist when we check whether the PHV actually comes from
> the nullable side of an outer join.

I wondered about that too, but I think phrels is probably preferable,
because it is fundamentally a syntactic attribute and what we are
after here is matching the syntactic structure.  I could be convinced
that that's wrong, but I'd want to see an actual counterexample.

> Even so it seems we still need to update phv->phrels in
> remove_rel_from_query when we remove a left join.  Otherwise it'd be
> weird to observe that phrels contains some already-removed relids.

Agreed, that's a good catch.  As the comment for remove_rel_from_query
says,

 * We are not terribly thorough here.

It's not surprising that the requirements for it advance over time.

(At one point I wrote some code that taught it to clean out the
removed relids from EquivalenceClasses, which doesn't need
to happen right now because we don't ever put outer-join quals
into EquivalenceClasses.  I don't think I included that in any
of the published versions of the patch series, but it's going to
need to reappear eventually.)

			regards, tom lane



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Further fixes in qual nullingrel adjustment for outer join commutation.

  2. Further tighten nullingrel marking rules in build_joinrel_tlist().

  3. remove_rel_from_query() must clean up PlaceHolderVar.phrels fields.

  4. Rethink nullingrel marking rules in build_joinrel_tlist().

  5. Make Vars be outer-join-aware.