Re: Some optimizations for COALESCE expressions during constant folding

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Some optimizations for COALESCE expressions during constant folding
Date: 2025-11-25 13:16:12
Message-ID: CAApHDvpgz-epR785EudN+BGGXC0K1tGOLacVmFNvBA-up6HVKg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 Nov 2025 at 02:10, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Tue, 25 Nov 2025 at 23:51, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> > (I'm wondering whether it'd be better to consolidate the
> > non-null check for Const, Var, and CoalesceExpr into one helper
> > function to simplify the code in eval_const_expressions.)
>
> uhh, of course it is. That's what I did in [1] for Consts and expand
> expr_is_nonnullable() to support COALESCE exprs then modify
> eval_const_expressions_mutator() to use that rather than using
> var_is_nonnullable(). That way we'll not need to modify the constant
> folding code every time we think of something new that we can prove
> can't be NULL.

That one failed the copy/edit pass. Here's another try at getting my
point across:

uhh, of course it is. That's what I did in [1] for Consts. Doing it
this way means we'll not need to modify the constant folding code (or
whichever other code wants to know when an Expr can't be NULL) every
time we think of something new that we can prove can't be NULL.

David

[1] https://www.postgresql.org/message-id/attachment/184166/v3-0001-Have-the-planner-replace-COUNT-ANY-with-COUNT-whe.patch

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Viktor Holmberg 2025-11-25 13:24:17 Re: ON CONFLICT DO SELECT (take 3)
Previous Message 河田達也 2025-11-25 13:11:12 Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE