Re: COALESCE with single argument looks like identity function

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Maksim Milyutin <maksim.milyutin@tantorlabs.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-03T21:45:42Z
Lists: pgsql-hackers
Maksim Milyutin <maksim.milyutin@tantorlabs.ru> writes:
> Updated patchset is attached

Pushed with minor adjustments.  Mainly, I didn't entirely trust
your substitutions of, eg, "COALESCE(q1)" to "COALESCE(q1, 0)".
That would produce a different result if q1 were NULL.  I'm not
sure that that actually occurs in these regression tests, or
that it would affect the intent of the tests anyway.  But we can
avoid having to think hard about that question by instead writing
"COALESCE(q1, q1)" and so on.  That does provably give the same
result as before.

			regards, tom lane



Commits

  1. Simplify COALESCE() with one surviving argument.