Re: SELECT syntax synopsis: column_definition?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Michael Glaesemann" <grzm(at)seespotcode(dot)net>, "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>, "SQL Postgresql List" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SELECT syntax synopsis: column_definition?
Date: 2007-08-22 05:33:08
Message-ID: 2399.1187760788@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> I haven't quite figured out how this is useful though. It probably makes more
> sense if you use plpgsql but I still don't quite see what the use case is.

IIRC, the case that actually convinced people to allow it was dblink.
You want to be able to do something like

select *
from dblink('select a,b,c from remote_table') as (a int, b text, c float8);

The declaration of dblink can't be any more specific than "RETURNS SETOF
RECORD", so there's no help to be had there. The only way to explain to
the parser what your dblink call is going to return is something like
the above. And the parser does need to know it, so it knows what to
expand "*" to (or more generally, to do things like joins involving the
rowset result).

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message roopa perumalraja 2007-08-22 07:25:47 Solution to retrieve first and last row for each minute
Previous Message Trinath Somanchi 2007-08-22 04:59:59 Pgcluster 1.7 Fail safe !!!