Re: Range types

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: Range types
Дата
Msg-id 87ws0mym7y.fsf@hi-media-techno.com
обсуждение исходный текст
Ответ на Re: Range types  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Range types
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:
> Dimitri Fontaine <dfontaine@hi-media.com> writes:
>> Tom Lane <tgl@sss.pgh.pa.us> writes:
>>>     foreach p2_member in unnest(p2) loop
>>>         p1 := array(select period_except(p1_member, p2_member)
>>>                 from unnest(p1) p1_member);
>>>     end loop;
>>> 
>>> But maybe it can be done in a single SQL command.
>
>> Yeah, as soon as you have LATERAL, I think. Without it there's no way to
>> compose SRF in SQL, AFAIK.
>
> Hm, how would you do it with LATERAL?  The problem is not so much
> composition as the need for a variable number of rounds of
> composition.

Let's have a try at it:

select p2_member, array_accum(p1) from unnest(p2) as p2_member      lateral (select period_except(p1_member, p2_member)
               from unnest(p1) p1_member) as x(p1);
 

I'm not sure I understand how the explicit looping over unnest(p2) is different
from using lateral, or even if that's what you're talking about when
mentioning variable number of rounds.

Regards,
-- 
dim


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

Предыдущее
От: Fujii Masao
Дата:
Сообщение: Re: Streaming replication and non-blocking I/O
Следующее
От: Fujii Masao
Дата:
Сообщение: How should the notice message from the primary be handled in the standby?