forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8aac975
committed
Remove unnecessary pfree() in g_intbig_compress().
GiST compress functions (like all GiST opclass functions) aresupposed to be called in short-lived memory contexts, so thatminor memory leaks in them are not of concern, and indeedexplicit pfree's are likely slightly counterproductive.But this one in g_intbig_compress() is more thanslightly counterproductive, because it's guarded by"if (in != DatumGetArrayTypeP(entry->key))" which meansthat if this test succeeds, we've detoasted the datum twice.(And to add insult to injury, the extra detoast result isleaked.) Let's just drop the whole stanza, relying on theGiST 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 soI left it alone. Perhaps there is a case for removingunnecessary pfree's more widely, but I'm not sure if it'sworth the code churn.The potential extra decompress seems expensive enough tojustify calling this a (minor) performance bug andback-patching.Konstantin Knizhnik, Matthias van de Meent, Tom LaneDiscussion:https://postgr.es/m/CAEze2Wi86=DxErfvf+SCB2UKmU2amKOF60BKuJOX=w-RojRn0A@mail.gmail.com1 parent40b3af7 commit8aac975
1 file changed
+0
-3
lines changedLines changed: 0 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
178 | 178 |
| |
179 | 179 |
| |
180 | 180 |
| |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 | 181 |
| |
185 | 182 |
| |
186 | 183 |
| |
|
0 commit comments
Comments
(0)