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

Commit5bc0d31

Browse files
committed
Repair incorrect cleanup of heap memory allocation during
transaction abort --- before it only worked if there was exactly one levelof allocation context stacked in the blank portal. Now it does the rightthing for any depth, including zero...
1 parent8b8db01 commit5bc0d31

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.50 1999/09/05 17:12:34 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.51 1999/09/09 16:25:35 tgl Exp $
1111
*
1212
* NOTES
1313
*Transaction aborts can now occur two ways:
@@ -694,19 +694,13 @@ static void
694694
AtCommit_Memory()
695695
{
696696
Portalportal;
697-
MemoryContextportalContext;
698697

699698
/* ----------------
700-
*Release memory in the blank portal.
701-
*Since EndPortalAllocMode implicitly works on the current context,
702-
*first make real sure that the blank portal is the selected context.
703-
*(This is probably not necessary, but seems like a good idea...)
699+
*Release all heap memory in the blank portal.
704700
* ----------------
705701
*/
706702
portal=GetPortalByName(NULL);
707-
portalContext= (MemoryContext)PortalGetHeapMemory(portal);
708-
MemoryContextSwitchTo(portalContext);
709-
EndPortalAllocMode();
703+
PortalResetHeapMemory(portal);
710704

711705
/* ----------------
712706
*Now that we're "out" of a transaction, have the
@@ -784,19 +778,13 @@ static void
784778
AtAbort_Memory()
785779
{
786780
Portalportal;
787-
MemoryContextportalContext;
788781

789782
/* ----------------
790-
*Release memory in the blank portal.
791-
*Since EndPortalAllocMode implicitly works on the current context,
792-
*first make real sure that the blank portal is the selected context.
793-
*(This is ESSENTIAL in case we aborted from someplace where it wasn't.)
783+
*Release all heap memory in the blank portal.
794784
* ----------------
795785
*/
796786
portal=GetPortalByName(NULL);
797-
portalContext= (MemoryContext)PortalGetHeapMemory(portal);
798-
MemoryContextSwitchTo(portalContext);
799-
EndPortalAllocMode();
787+
PortalResetHeapMemory(portal);
800788

801789
/* ----------------
802790
*Now that we're "out" of a transaction, have the

‎src/backend/utils/mmgr/portalmem.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.28 1999/07/17 20:18:15 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.29 1999/09/09 16:25:29 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -83,7 +83,6 @@
8383
staticvoidCollectNamedPortals(Portal*portalP,intdestroy);
8484
staticPortalPortalHeapMemoryGetPortal(PortalHeapMemorycontext);
8585
staticPortalVariableMemoryPortalHeapMemoryGetVariableMemory(PortalHeapMemorycontext);
86-
staticvoidPortalResetHeapMemory(Portalportal);
8786
staticPortalPortalVariableMemoryGetPortal(PortalVariableMemorycontext);
8887

8988
/* ----------------
@@ -838,7 +837,7 @@ PortalDestroy(Portal *portalP)
838837
*BadArg if mode is invalid.
839838
* ----------------
840839
*/
841-
staticvoid
840+
void
842841
PortalResetHeapMemory(Portalportal)
843842
{
844843
PortalHeapMemorycontext;

‎src/include/utils/portal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: portal.h,v 1.17 1999/07/15 23:04:23momjian Exp $
9+
* $Id: portal.h,v 1.18 1999/09/09 16:25:23tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -75,6 +75,7 @@ extern Portal CreatePortal(char *name);
7575
externvoidPortalDestroy(Portal*portalP);
7676
externvoidStartPortalAllocMode(AllocModemode,Sizelimit);
7777
externvoidEndPortalAllocMode(void);
78+
externvoidPortalResetHeapMemory(Portalportal);
7879
externPortalVariableMemoryPortalGetVariableMemory(Portalportal);
7980
externPortalHeapMemoryPortalGetHeapMemory(Portalportal);
8081

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp