Re: idea: allow AS label inside ROW constructor

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: idea: allow AS label inside ROW constructor
Date: 2014-10-22 16:35:19
Message-ID: CAHyXU0zkTTa27g+UDvvjg1DsdeE0YhtiRz0cDA4=wgb1Co5f1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 22, 2014 at 11:21 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Hi
>
> with new functions row_to_json(b), there is more often usage of ROW
> constructor. Using names in fields is relative difficult. Because ROW has
> special clause in parser, I am thinking so we can enable labeling inside ROW
> constructor
>
> so instead currently supported:
>
> select row_to_json(r) from (select 10 as a, 20 as b) r;
>
> users can to write:
>
> select row_to_json(row(10 as a,20 as b));
>
> labeling will be enabled "only" inside ROW constructor. I don't propose
> enable it everywhere.
>
> What do you think about it?

It's a neat idea -- maybe a better alternative to what I was thinking
here: http://postgresql.1045698.n5.nabble.com/Support-UPDATE-table-SET-tp5823073p5823944.html

Some questions:
*) What would the parser transformation resolve to
*) Are we ok with SQL standard
*) Do you think this (or some similar variant) would work?

select row_to_json(row(foo.*)) from foo;

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2014-10-22 16:44:39 Re: Question about RI checks
Previous Message Pavel Stehule 2014-10-22 16:34:04 Re: idea: allow AS label inside ROW constructor