Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nigel Horne <njh@xxxxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux