Re: Convert NOT IN sublinks to anti-joins when safe - Mailing list pgsql-hackers

From Richard Guo
Subject Re: Convert NOT IN sublinks to anti-joins when safe
Date
Msg-id CAMbWs48K=K06kQ3FVn6mzsk5pgEbFdUJkShY_xwN4ANj+Zwp0A@mail.gmail.com
Whole thread
In response to Re: Convert NOT IN sublinks to anti-joins when safe  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-hackers
On Sun, Mar 8, 2026 at 5:16 PM Richard Guo <guofenglinux@gmail.com> wrote:
> Attached is an updated version of the patch that replaces foreach with
> foreach_ptr or foreach_node accordingly.  Nothing else has changed.
>
> I plan to do one more round of self-review on this.  Unless there are
> any further thoughts or concerns, I'm hoping to commit this in a week
> or two.  Please let me know if anyone spots anything else I might have
> missed.

I just finished a final self-review and noticed a subtle issue in
query_outputs_are_not_nullable().  When preparing a target expression
for the non-nullability check, the previous code flattened join
aliases Vars before grouping Vars.  However, because the parser
processes FROM/JOIN clauses before the GROUP BY clause, a grouping Var
can actually wrap a join alias Var, not the reverse.  So we should
flatten grouping Vars first.

Attached is an updated patch that fixes that issue.  I plan to commit
this in a week or two, barring any objections.

- Richard

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: Emitting JSON to file using COPY TO
Next
From: Henson Choi
Date:
Subject: Re: Row pattern recognition