On Thu, Jul 13, 2023 at 06:28:39PM +0200, Matthias van de Meent wrote: > There are similar pfree calls in the _int_gist.c file's g_int_compress > function, which made me think we do need to clean up after use, but > indeed these pfrees are useless (or even harmful if bug #17888 can be > trusted)
Indeed, all these are in a GiST temporary context. So you'd mean something like the attached perhaps, for both the decompress and compress paths? -- Michael
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index 98145fe370..9b71cb6c91 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -201,11 +201,7 @@ g_int_compress(PG_FUNCTION_ARGS)
r = DatumGetArrayTypeP(entry->key);
CHECKARRVALID(r);
if (ARRISEMPTY(r))
- {
- if (r != (ArrayType *) DatumGetPointer(entry->key))
- pfree(r);
PG_RETURN_POINTER(entry);
- }
if ((len = ARRNELEMS(r)) >= 2 * num_ranges)
{ /* compress */
@@ -346,8 +342,6 @@ g_int_decompress(PG_FUNCTION_ARGS)
if ((!i) || *(dr - 1) != j)
*dr++ = j;
- if (in != (ArrayType *) DatumGetPointer(entry->key))
- pfree(in);
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, false);
signature.asc
Description: PGP signature
