postgresql/contrib/intarray
Tom Lane 9f70f6d4c5 Remove unnecessary pfree() in g_intbig_compress().
GiST compress functions (like all GiST opclass functions) are
supposed to be called in short-lived memory contexts, so that
minor memory leaks in them are not of concern, and indeed
explicit pfree's are likely slightly counterproductive.
But this one in g_intbig_compress() is more than
slightly counterproductive, because it's guarded by
"if (in != DatumGetArrayTypeP(entry->key))" which means
that if this test succeeds, we've detoasted the datum twice.
(And to add insult to injury, the extra detoast result is
leaked.)  Let's just drop the whole stanza, relying on the
GiST temporary context mechanism to clean up in good time.

The analogous bit in g_int_compress() is
       if (r != (ArrayType *) DatumGetPointer(entry->key))
           pfree(r);
which doesn't have the gratuitous-detoast problem so
I left it alone.  Perhaps there is a case for removing
unnecessary pfree's more widely, but I'm not sure if it's
worth the code churn.

The potential extra decompress seems expensive enough to
justify calling this a (minor) performance bug and
back-patching.

Konstantin Knizhnik, Matthias van de Meent, Tom Lane

Discussion: https://postgr.es/m/CAEze2Wi86=DxErfvf+SCB2UKmU2amKOF60BKuJOX=w-RojRn0A@mail.gmail.com
2023-07-13 13:08:40 -04:00
..
bench Don't fall off the end of perl functions 2018-05-27 09:08:42 -04:00
data 1. Fixed error with empty array ( '{}' ), 2001-08-04 19:35:32 +00:00
expected intarray: Prevent out-of-bound memory reads with gist__int_ops 2023-06-15 13:45:44 +09:00
sql intarray: Prevent out-of-bound memory reads with gist__int_ops 2023-06-15 13:45:44 +09:00
.gitignore Support "make check" in contrib 2011-04-25 22:27:11 +03:00
Makefile Handle contrib's GIN/GIST support function signature changes honestly. 2016-06-09 16:44:25 -04:00
_int.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
_int_bool.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
_int_gin.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
_int_gist.c intarray: Prevent out-of-bound memory reads with gist__int_ops 2023-06-15 13:45:44 +09:00
_int_op.c Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
_int_selfuncs.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
_int_tool.c Fix intarray's GiST opclasses to not fail for empty arrays with <@. 2019-08-06 18:04:51 -04:00
_intbig_gist.c Remove unnecessary pfree() in g_intbig_compress(). 2023-07-13 13:08:40 -04:00
intarray--1.0--1.1.sql Add selectivity estimation functions for intarray operators. 2015-07-21 20:59:24 +03:00
intarray--1.1--1.2.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:43 -04:00
intarray--1.2.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
intarray--unpackaged--1.0.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:43 -04:00
intarray.control Handle contrib's GIN/GIST support function signature changes honestly. 2016-06-09 16:44:25 -04:00