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

Commitee0ef18

Browse files
committed
Fixes: Growing backend when using nested function calls
Submitted by: wieck@sapserv.debis.de
1 parent352e2ae commitee0ef18

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

‎src/backend/utils/cache/catcache.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.1.1.1 1996/07/09 06:22:06 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.1.1.1.2.1 1996/10/24 07:33:52 scrappy Exp $
1111
*
1212
* Notes:
1313
*XXX This needs to use exception.h to handle recovery when
@@ -860,6 +860,13 @@ SearchSysCache(struct catcache *cache,
860860
if ((RelationGetRelationTupleForm(relation))->relhasindex
861861
&& !IsBootstrapProcessingMode())
862862
{
863+
/* ----------
864+
* Switch back to old memory context so memory not freed
865+
* in the scan function will go away at transaction end.
866+
* wieck - 10/18/1996
867+
* ----------
868+
*/
869+
MemoryContextSwitchTo(oldcxt);
863870
Assert(cache->cc_iscanfunc);
864871
switch(cache->cc_nkeys)
865872
{
@@ -868,22 +875,46 @@ SearchSysCache(struct catcache *cache,
868875
case2:ntp=cache->cc_iscanfunc(relation,v1,v2);break;
869876
case1:ntp=cache->cc_iscanfunc(relation,v1);break;
870877
}
878+
/* ----------
879+
* Back to Cache context. If we got a tuple copy it
880+
* into our context.
881+
* wieck - 10/18/1996
882+
* ----------
883+
*/
884+
MemoryContextSwitchTo((MemoryContext)CacheCxt);
885+
if(HeapTupleIsValid(ntp)) {
886+
ntp=heap_copytuple(ntp);
887+
}
871888
}
872889
else
873890
{
874891
HeapScanDescsd;
875892

893+
/* ----------
894+
* As above do the lookup in the callers memory
895+
* context.
896+
* wieck - 10/18/1996
897+
* ----------
898+
*/
899+
MemoryContextSwitchTo(oldcxt);
900+
876901
sd=heap_beginscan(relation,0,NowTimeQual,
877902
cache->cc_nkeys,cache->cc_skey);
878903

879904
ntp=heap_getnext(sd,0,&buffer);
880905

906+
MemoryContextSwitchTo((MemoryContext)CacheCxt);
907+
881908
if (HeapTupleIsValid(ntp)) {
882909
CACHE1_elog(DEBUG,"SearchSysCache: found tuple");
883910
ntp=heap_copytuple(ntp);
884911
}
885912

913+
MemoryContextSwitchTo(oldcxt);
914+
886915
heap_endscan(sd);
916+
917+
MemoryContextSwitchTo((MemoryContext)CacheCxt);
887918
}
888919

889920
DisableCache=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp