Recursive calls to functions that return sets

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Recursive calls to functions that return sets
Дата
Msg-id 44215FDF.6020806@tada.se
обсуждение исходный текст
Ответы Re: Recursive calls to functions that return sets  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-hackers
Imagine the following scenario:

Function 'A' returns SETOF 'x'. It will issue a query using SPI that 
calls function 'B'. This function returns SETOF 'y'.
Each tuple of 'x' is formed from some data in 'y'.
There will be millions of tuples so building a set of 'y' in memory is 
not an option.

What would the recommended use of MemoryContexts in an SRF function be 
in order to make this work? The SPI_connect must be issued during the 
SRF_IS_FIRST_CALL() phase. The Portal that it creates must remain alive 
until it's time for the SRF_RETURN_DONE(). What would the recommended 
approach be to accomplish this efficiently (and without introducing a 
major memory leak)?

The problem I'm trying to solve is a generic one. It's very possible 
that the recursion is is of arbitrary depth.

Regards,
Thomas Hallgren



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

Предыдущее
От: "Jonah H. Harris"
Дата:
Сообщение: Request from Tom--offlist
Следующее
От: Mark Wong
Дата:
Сообщение: Re: Patch Submission Guidelines