Re: COALESCE with single argument looks like identity function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Maksim Milyutin <maksim(dot)milyutin(at)tantorlabs(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: COALESCE with single argument looks like identity function
Date: 2025-04-11 14:00:59
Message-ID: 834617.1744380059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Maksim Milyutin <maksim(dot)milyutin(at)tantorlabs(dot)ru> writes:
> I've noticed that COALESCE function doesn't converge to argument
> expression if it is alone in argument list of COALESCE as part
> simplification routine for expressions in planner. This might suppress
> further useful transformations when non-strict ops are required from
> some expression like converging OUTER JOIN to INNER one with WHERE qual
> containing COALESCE over single column from inner side.

Seems like a reasonable idea --- it's probably a rare case, but the
check is cheap enough. I'd add some comments though.

Please add this to the open commitfest so we don't lose track of it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-04-11 14:07:32 Re: disallow ALTER VIEW SET DEFAULT when the corresponding base relation column is a generated column
Previous Message Andres Freund 2025-04-11 13:47:59 Re: Regression test fails when 1) old PG is installed and 2) meson/ninja build is used