Re: What is this doing? SELECT (a,b,c) FROM mytable ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ljb <ljb9832(at)pobox(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What is this doing? SELECT (a,b,c) FROM mytable ...
Date: 2011-04-23 03:05:08
Message-ID: 942.1303527908@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ljb <ljb9832(at)pobox(dot)com> writes:
> What syntax or operator did I (accidentally) invoke by putting parentheses
> around my column list?
> SELECT (a, b, c) FROM mytable...
> It gets me a single result column with comma-separated values in
> parentheses (see 2nd SELECT below). I can't find an explanation in the
> PostgreSQL manual. It doesn't seem to be an array, a subquery, row
> constructor, etc. What sort of thing is it?

Yeah, it's a ROW() constructor. According to the SQL spec you're
allowed to omit the "ROW" keyword. Not one of their better ideas
IMO, especially in a syntax that generally prefers wordiness.

It is documented, very briefly, under 4.2.13 Row Constructors:

The key word ROW is optional when there is more than one
expression in the list.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-04-23 03:11:56 Re: Should I free this memory?
Previous Message ljb 2011-04-23 01:46:19 What is this doing? SELECT (a,b,c) FROM mytable ...