Re: Is it safe to cache data by GiST consistent function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Is it safe to cache data by GiST consistent function
Дата
Msg-id 2048131.1712154421@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [MASSMAIL]Is it safe to cache data by GiST consistent function  (Michał Kłeczek <michal@kleczek.org>)
Ответы Re: Is it safe to cache data by GiST consistent function  (Michał Kłeczek <michal@kleczek.org>)
Список pgsql-hackers
=?utf-8?Q?Micha=C5=82_K=C5=82eczek?= <michal@kleczek.org> writes:
> When implementing a GiST consistent function I found the need to cache pre-processed query across invocations.
> I am not sure if it is safe to do (or I need to perform some steps to make sure cached info is not leaked between
rescans).

AFAIK it works.  I don't see any of the in-core ones doing so,
but at least range_gist_consistent and multirange_gist_consistent
are missing a bet by repeating their cache search every time.

> The comment in gistrescan says:

>         /*
>          * If this isn't the first time through, preserve the fn_extra
>          * pointers, so that if the consistentFns are using them to cache
>          * data, that data is not leaked across a rescan.
>          */

> which seems to me self-contradictory as fn_extra is preserved between rescans (so leaks are indeed possible).

I think you're reading it wrong.  If we cleared fn_extra during
rescan, access to the old extra value would be lost so a new one
would have to be created, leaking the old value for the rest of
the query.

            regards, tom lane



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

Предыдущее
От: "Tristan Partin"
Дата:
Сообщение: Re: psql not responding to SIGINT upon db reconnection
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql not responding to SIGINT upon db reconnection