Re: Some optimizations for COALESCE expressions during constant folding

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-25T12:59:07Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Teach expr_is_nonnullable() to handle more expression types

  2. Optimize ROW(...) IS [NOT] NULL using non-nullable fields

  3. Simplify COALESCE expressions using non-nullable arguments

Richard Guo <guofenglinux@gmail.com> writes:

> +					ListCell   *lc;
> +
> +					foreach(lc, coalesceexpr->args)
> +					{
> +						Node	   *coalescearg = (Node *) lfirst(lc);

I have no comment on the rest of the patch, but this could be simplifed
using the foreach_ptr macro:

	foreach_ptr(Node, coalescearg, coalesceexpr->args)
	{

- ilmari