Re: SELECT syntax synopsis: column_definition? - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT syntax synopsis: column_definition?
Date
Msg-id 2399.1187760788@sss.pgh.pa.us
Whole thread Raw
In response to Re: SELECT syntax synopsis: column_definition?  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-sql
Gregory Stark <stark@enterprisedb.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


pgsql-sql by date:

Previous
From: novice
Date:
Subject: raw data into table process
Next
From: roopa perumalraja
Date:
Subject: Solution to retrieve first and last row for each minute