Is it safe to cache data by GiST consistent function

From: Michał Kłeczek <michal(at)kleczek(dot)org>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Is it safe to cache data by GiST consistent function
Date: 2024-04-03 06:43:17
Message-ID: 3F12E994-B9E7-4308-9E18-5F01E28F55AC@kleczek.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

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).

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).

Am I missing something?

Thanks,
Michal

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-04-03 06:50:19 Re: Introduce XID age and inactive timeout based replication slot invalidation
Previous Message Michael Paquier 2024-04-03 06:18:10 Re: Confusing #if nesting in hmac_openssl.c