SQL: table function support

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема SQL: table function support
Дата
Msg-id 162867790806030403r221a6ae3s657f78ad2da9237f@mail.gmail.com
обсуждение исходный текст
Ответы Re: SQL: table function support
Список pgsql-patches
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

Вложения

В списке pgsql-patches по дате отправления:

Предыдущее
От: Jan Urbański
Дата:
Сообщение: Re: extend VacAttrStats to allow stavalues of different types
Следующее
От: "Heikki Linnakangas"
Дата:
Сообщение: Re: Free Space Map rewrite