create table foo(a int, b int);
postgres=# create function rfoo() returns setof foo as $$ begin return
query select foo from foo; end; $$ language plpgsql;
Time: 25.606 ms
postgres=# select rfoo();
ERROR: structure of query does not match function result type
DETAIL: Number of returned columns (1) does not match expected column
Any reason why the above shouldn't work? Why does 'return query'
assume that returned composite types are expanded?