Appetite for syntactic sugar to match result set columns to UDT fields?

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Philip Warner <pjw@rhyme.com.au>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-05T05:50:11Z
Lists: pgsql-hackers
On Thursday, September 4, 2025, Philip Warner <pjw@rhyme.com.au> wrote:

> *The Solution*
>
> Some syntax like:
>
>     SELECT CAST((F1=> value1, F2 => value2) AS FOO BY NAME)
>
> or
>
>     SELECT FOO(F1 => VALUE1, F2=> value2);
>
> or some other well-defined and non-conflicting syntax.
>

Don’t really see the point of new syntax here - both things you wrote are
already effectively syntactically valid if a user-defined function exists;
and it’s a cleaner interface.  Plus, the serialized form of a composite
doesn’t include field names so giving those names special treatment
elsewhere feels excessive.

Expanding cast with custom features seems particularly undesirable.

David J.