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

Commita844c29

Browse files
committed
Prevent memory leaks in parseRelOptions().
parseRelOptions() tended to leak memory in the caller's context. Mostof the time this doesn't really matter since the caller's context isat most query-lifespan, and the function won't be invoked very many times.However, when testing with CLOBBER_CACHE_RECURSIVELY, the same relcacheentry can get rebuilt a *lot* of times in one query, leading to significantintraquery memory bloat if it has any reloptions. Noted whileinvestigating a related report from Tomas Vondra.In passing, get rid of some Asserts that are redundant with the onedone by deconstruct_array().As with other patches to avoid leaks in CLOBBER_CACHE testing, it doesn'treally seem worth back-patching this.
1 parentab8c84d commita844c29

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

‎src/backend/access/common/reloptions.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,6 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace,
620620
intnoldoptions;
621621
inti;
622622

623-
Assert(ARR_ELEMTYPE(array)==TEXTOID);
624-
625623
deconstruct_array(array,TEXTOID,-1, false,'i',
626624
&oldoptions,NULL,&noldoptions);
627625

@@ -777,8 +775,6 @@ untransformRelOptions(Datum options)
777775

778776
array=DatumGetArrayTypeP(options);
779777

780-
Assert(ARR_ELEMTYPE(array)==TEXTOID);
781-
782778
deconstruct_array(array,TEXTOID,-1, false,'i',
783779
&optiondatums,NULL,&noptions);
784780

@@ -912,14 +908,10 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
912908
/* Done if no options */
913909
if (PointerIsValid(DatumGetPointer(options)))
914910
{
915-
ArrayType*array;
911+
ArrayType*array=DatumGetArrayTypeP(options);
916912
Datum*optiondatums;
917913
intnoptions;
918914

919-
array=DatumGetArrayTypeP(options);
920-
921-
Assert(ARR_ELEMTYPE(array)==TEXTOID);
922-
923915
deconstruct_array(array,TEXTOID,-1, false,'i',
924916
&optiondatums,NULL,&noptions);
925917

@@ -959,6 +951,11 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
959951
errmsg("unrecognized parameter \"%s\"",s)));
960952
}
961953
}
954+
955+
/* It's worth avoiding memory leaks in this function */
956+
pfree(optiondatums);
957+
if (((void*)array)!=DatumGetPointer(options))
958+
pfree(array);
962959
}
963960

964961
*numrelopts=numoptions;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp