Create a function thatreturns a tablewith a column"col1":
CREATE OR REPLACE FUNCTION myfunc() RETURNS TABLE(col1 text) AS $BODY$ SELECT 'aaa'::text; $BODY$ LANGUAGE sql STABLE;
After creating a look at the source code of the function in the object browser:
CREATE OR REPLACE FUNCTION myfunc() RETURNS SETOF text AS $BODY$ SELECT 'aaa'::text; $BODY$ LANGUAGE sql STABLE COST 100 ROWS 1000;
The type of result ofthe functionis shown as "SETOF text" instead "TABLE(col1 text)", column name "col1" is lost. Despite this, thename of the column "col1" is presentin the results:
SELECT * FROM myfunc();
col1 !
text ! ----------+-
aaa |
Сommand-line utility "psql" returns (\df+) correct value of function type.