Re: http://www.postgresql.org/docs/8.0/static/xfunc-sql.html

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: http://www.postgresql.org/docs/8.0/static/xfunc-sql.html
Дата
Msg-id 15565.1124719782@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re:  (Nigel Horne <njh@bandsman.co.uk>)
Список pgsql-general
Nigel Horne <njh@bandsman.co.uk> writes:
> It strikes me that there are two problems with this approach:

> 1) It stores the return values in the database, that seems a waste
> 2) It's slightly more complicated in that I have to delete the
> return values from the previous call before inserting the return
> values from this call, making it even more complex and slow.

You've misunderstood this completely.  We are not storing anything
essential in the table, we're just using its rowtype to describe the
function's composite-type result.

Personally I would have written the example using a composite type
to make this more clear:

CREATE TYPE test_func_type AS (id int, name text);

CREATE FUNCTION test_func() RETURNS SETOF test_func_type AS $$
  SELECT 1, 'me' UNION ALL SELECT 2, 'you'
$$ LANGUAGE sql;

select * from test_func();
 id | name
----+------
  1 | me
  2 | you
(2 rows)

            regards, tom lane

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: SQL error - please help.
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: indexes are farked