Computing (disjoint) union of range

Поиск
Список
Период
Сортировка
От Rémi Cura
Тема Computing (disjoint) union of range
Дата
Msg-id CAJvUf_thbJjNSj9LUjgntzfCsToeSS5cxdV+bfxibN2pUh2M3Q@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Hello Dear list,

this is more a plpgsql dev. issue.

I wrote a plpgsql function to compute union of time range taht works :

[1,4]U[3,8]U[12,14]U[16,18] ---> [1,8]U[12,14]U[16,18]

It works on multiple rows.

My issue is a design issue :
I want to work on set of row and return set of row.
I am aware I could take as input/output array of range but I don't want (memory/casting cost).

Currently the function takes a cursor on a table and output a setof record.

I would like that the function can blend in multiple subqueries smoothly, as

WITH (
first query to get range),
(query computing union
),
(query using computed union
) etc.

Currently I have to execute 2 sql statment :

create cursor on ranges;

WITH (function to compute union)
,
(query...)

The only kind of function taking set of record as input I know of is aggregate function, but it returns only one row and the output of union can take multiple row.

Any insight would be greatly appreciated.

Cheers,

Rémi-C


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Risk of set system wise statement_timeout
Следующее
От: "Andrew G. Saushkin"
Дата:
Сообщение: Qury plan for sql function with security definer