Hello
this patch add support of table functions syntax like ANSI SQL 2003.
CREATE OR REPLACE FUNCTION foo_sql(integer)
RETURNS TABLE(a integer, b integer, c integer) AS $$
SELECT i, i+1, i+2
FROM generate_series(1, $1) g(i);
$$ LANGUAGE sql;
CREATE OR REPLACE FUNCTION foo_plpgsql1(m integer)
RETURNS TABLE(a integer, b integer, c integer) AS $$
DECLARE r record;
BEGIN
FOR i IN 1..m LOOP
r = ROW(i, i+1, i+2);
RETURN NEXT r;
END LOOP;
RETURN;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION foo_plpgsql2(m integer)
RETURNS TABLE(a integer, b integer, c integer) AS $$
DECLARE r record;
BEGIN
RETURN QUERY
SELECT i, i+1, i+2
FROM generate_series(1, m) g(i);
RETURN;
END;
$$ LANGUAGE plpgsql;
There are one significant difference to SRF with OUT variables.
Attributies declared in TABLE clause doesn't create local variables.
It's in conformance with SQL/PSM.
Regards
Pavel Stehule