Re: Appetite for syntactic sugar to match result set columns to UDT fields? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Appetite for syntactic sugar to match result set columns to UDT fields?
Date
Msg-id 1364243.1757081290@sss.pgh.pa.us
Whole thread Raw
In response to Re: Appetite for syntactic sugar to match result set columns to UDT fields?  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: Appetite for syntactic sugar to match result set columns to UDT fields?
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
> I'd like a formulation like: 
>         Select Row(T1.T1F7 as F1, T2.T2F3 as F2, Tp.Fq as Fn)::FOO By Name
> Or 
>         Select FOO(F1:=T1.T1F7, F2:=T2.T2F3, Fn:=Tp.Fq)

> Basically: it's some form of UDT constructor with named parameters,
> whether by cast, pseudo function call or some other mechanism. 

Well, you can build a real function call that does that:

CREATE FUNCTION FOO(F1 int, F2 int, ...) RETURNS FOO AS ...;

SELECT FOO(F1 => T1.T1F7, F2 => T2.T2F3, ...) FROM ...;

Admittedly you have to get the ROW() constructor right in the
body of function FOO, but then you've got it.  This approach
also lets you insert appropriate default values for unspecified
columns, which is a feature we surely wouldn't build in if this
were wired-in syntax.

            regards, tom lane



pgsql-hackers by date:

Previous
From: David Geier
Date:
Subject: Re: Use merge-based matching for MCVs in eqjoinsel
Next
From: Pierrick
Date:
Subject: Only one version can be installed when using extension_control_path