Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8aac975

Browse files
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.com
1 parent40b3af7 commit8aac975

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

‎contrib/intarray/_intbig_gist.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ g_intbig_compress(PG_FUNCTION_ARGS)
178178
entry->rel,entry->page,
179179
entry->offset, false);
180180

181-
if (in!=DatumGetArrayTypeP(entry->key))
182-
pfree(in);
183-
184181
PG_RETURN_POINTER(retval);
185182
}
186183
elseif (!ISALLTRUE(DatumGetPointer(entry->key)))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp