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