Re: Wrong results: NOT IN to anti-join with an upper-level Var in the sub-select's output

From: Rui Zhao <zhaorui126(at)gmail(dot)com>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: Wrong results: NOT IN to anti-join with an upper-level Var in the sub-select's output
Date: 2026-07-31 15:26:24
Message-ID: CAHWVJhFDgAjcJscH5E2zCF1814eidMS_1xiJy7R-RMG7hHBF_w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tender,

Thanks for looking. Moved the comment ahead of the test and left the one
inside the if alone, as you suggested; v2 attached. make check is still green
and the test still fails without the code change.

Just to be clear about what the check costs us: nothing that works today.
expr_is_nonnullable() already declines upper-level Vars, so the only way the
fallback was reaching one was by matching it against a local Var of an
unrelated relation -- there was never a correct conversion there to lose. And
proving an upper-level output non-null would take the outer query's range
table, which query_outputs_are_not_nullable() isn't given, so that would want a
different mechanism rather than a relaxation of this test.

Thanks,
Rui

Attachment Content-Type Size
v2-0001-Don-t-prove-a-sub-select-s-upper-level-output-Var.patch application/octet-stream 5.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Rui Zhao 2026-07-31 15:16:22 Re: Prove a NOT IN's left-hand expressions non-nullable from quals