Re: pgsql: Teach expr_is_nonnullable() to handle more expression types

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgsql: Teach expr_is_nonnullable() to handle more expression types
Date: 2026-10-08 13:49:26
Message-ID: CA+TgmoY3hO1228Vj4-at9PDT_iBRzrRGAbNSkXQbvmmKtxjvMQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Tue, Oct 6, 2026 at 9:30 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I think we can just remove the T_DistinctExpr case from
> expr_is_nonnullable(). An alternative is that we keep it, but only
> when the operator is a btree equality operator, as such an operator
> must not return NULL for non-null inputs. This keeps the optimization
> for nearly all real-world cases.

I'm not sure. expr_is_nonnullable() doesn't look like an appealing
place to do being catalog lookups. I see that var_is_nonnullable()
does do catalog lookups when source == NOTNULL_SOURCE_CATALOG, which
strikes me as not great (and why does it test has_subclass() before
rte->relkind?!). But I'd be inclined to use a conditional rule only if
we can base it on information that we already have cached in some
planner data structure, and not if we'd have to look it up in the
catalog.

--
Robert Haas
Databricks

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-10-08 13:50:50 Re: REPACK (CONCURRENTLY) can't complete after ~105M concurrent updates/deletes
Previous Message Zhijie Hou 2026-10-08 13:45:50 Re: Incorrect CONTEXT reported for errors from parallel apply worker in logical replication

Browse pgsql-committers by date

  From Date Subject
Previous Message Peter Eisentraut 2026-10-08 09:11:06 pgsql: Fix warning message translatability