Re: SETOF

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: SETOF
Дата
Msg-id 8765qy9dzd.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: SETOF  (Christoph Haller <ch@rodos.fzk.de>)
Список pgsql-sql
Christoph Haller <ch@rodos.fzk.de> writes:

> You cannot obtain several columns from SQL functions.
> See the list archives (search for SETOF) for details.
> You have to use e.g. a plpgsql function instead.

How do you do it with a plpgsql function?


FWIW, this is probably the thing I wish for the most often. I can't count how
many times I've wanted to be able to write queries like:

select *,       (select x,y,z    from b where b.id = a.foo)      (select xx,yy,zz from c where c.id = a.bar) from a

As it is I either have to find a way to turn it into a join, which isn't
always possible, or duplicate the subquery which can cause multiple identical
table lookups.

I suppose one alternative would be for postgres to check if there are multiple
subplans to see if the subplan is the same except for the returned columns and
merge them somehow.

That doesn't solve the case of when you want a function that returns two
columns though.

-- 
greg



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

Предыдущее
От: Christoph Haller
Дата:
Сообщение: Re: SETOF
Следующее
От: Christoph Haller
Дата:
Сообщение: Re: SETOF