TODO item: Accept aliases for values in ROW(...) constructor

Lists: pgsql-hackers
From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: TODO item: Accept aliases for values in ROW(...) constructor
Date: 2014-11-25 01:32:05
Message-ID: 5473DC15.9060504@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all

Especially with the introduction of json support, but also in the past
with hstore and other things, I've sometimes found myself wishing I
could provide aliases in an anonymous row constructor, e.g.

ROW(x AS something, y AS somethingelse)

The same thing can be done using a scalar subquery wrapping a
subquery-in-FROM returning a single row, but it's pretty ugly:

(SELECT r FROM (SELECT x AS something, y AS somethingelse) r)

That's what I've done to produce json a lot, though, and will need to
continue to do so until 9.4's json_build_object etc are in the wild.

While that'll solve the need for json, I'm sure others will come up. So
in case someone feels like exploring the parser a little, does it seem
reasonable to add ROW(...) with aliases to the TODO?

Or, alternately, and perhaps more generally useful, allow rowtype
specifications for anonymous records outside function-call context, like:

ROW(x1,y1) AS r(x integer, y integer)

Related:

http://stackoverflow.com/q/13227142/398670

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Accept aliases for values in ROW(...) constructor
Date: 2014-11-25 01:33:55
Message-ID: 5473DC83.6080903@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> ROW(x AS something, y AS somethingelse)

Apologies, it looks like Pavel already bought this up:

http://www.postgresql.org/message-id/CAFj8pRB1T1W6g0sppn-jEtyzJPLUUz_FxtNbme5Okd3XxVFx_w@mail.gmail.com

and I missed it.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TODO item: Accept aliases for values in ROW(...) constructor
Date: 2014-11-30 19:17:28
Message-ID: CAFj8pRAx7pVQFwuUnVJ=4iag67z8c1KwXS2kQkup8h0MdX=VQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Craig

Is there agreement on proposed syntax ROW(x AS something, y AS
somethingelse) ?

I can start work on this topic this week.

Regards

Pavel

2014-11-25 2:33 GMT+01:00 Craig Ringer <craig(at)2ndquadrant(dot)com>:
>
>
> > ROW(x AS something, y AS somethingelse)
>
> Apologies, it looks like Pavel already bought this up:
>
>
http://www.postgresql.org/message-id/CAFj8pRB1T1W6g0sppn-jEtyzJPLUUz_FxtNbme5Okd3XxVFx_w@mail.gmail.com
>
> and I missed it.
>
> --
> Craig Ringer http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers