diff options
author | Tom Lane | 1999-09-09 16:25:35 +0000 |
---|---|---|
committer | Tom Lane | 1999-09-09 16:25:35 +0000 |
commit | 5bc0d31ae8c84fc43210c66338c5e2f492b52e6b (patch) | |
tree | 76e4e78c25424e850b2ea7e6e48a891b1b86a432 | |
parent | 8b8db01517bd688e35a70eb3a34fb0ce3c977085 (diff) |
Repair incorrect cleanup of heap memory allocation during
transaction abort --- before it only worked if there was exactly one level
of allocation context stacked in the blank portal. Now it does the right
thing for any depth, including zero...
-rw-r--r-- | src/backend/access/transam/xact.c | 22 | ||||
-rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 5 | ||||
-rw-r--r-- | src/include/utils/portal.h | 3 |
3 files changed, 9 insertions, 21 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index c9e16daa0d7..b6e19d614e2 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.50 1999/09/05 17:12:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.51 1999/09/09 16:25:35 tgl Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -694,19 +694,13 @@ static void AtCommit_Memory() { Portal portal; - MemoryContext portalContext; /* ---------------- - * Release memory in the blank portal. - * Since EndPortalAllocMode implicitly works on the current context, - * first make real sure that the blank portal is the selected context. - * (This is probably not necessary, but seems like a good idea...) + * Release all heap memory in the blank portal. * ---------------- */ portal = GetPortalByName(NULL); - portalContext = (MemoryContext) PortalGetHeapMemory(portal); - MemoryContextSwitchTo(portalContext); - EndPortalAllocMode(); + PortalResetHeapMemory(portal); /* ---------------- * Now that we're "out" of a transaction, have the @@ -784,19 +778,13 @@ static void AtAbort_Memory() { Portal portal; - MemoryContext portalContext; /* ---------------- - * Release memory in the blank portal. - * Since EndPortalAllocMode implicitly works on the current context, - * first make real sure that the blank portal is the selected context. - * (This is ESSENTIAL in case we aborted from someplace where it wasn't.) + * Release all heap memory in the blank portal. * ---------------- */ portal = GetPortalByName(NULL); - portalContext = (MemoryContext) PortalGetHeapMemory(portal); - MemoryContextSwitchTo(portalContext); - EndPortalAllocMode(); + PortalResetHeapMemory(portal); /* ---------------- * Now that we're "out" of a transaction, have the diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index a49dca40b6a..d625d25d5bd 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.28 1999/07/17 20:18:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.29 1999/09/09 16:25:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -83,7 +83,6 @@ static void CollectNamedPortals(Portal *portalP, int destroy); static Portal PortalHeapMemoryGetPortal(PortalHeapMemory context); static PortalVariableMemory PortalHeapMemoryGetVariableMemory(PortalHeapMemory context); -static void PortalResetHeapMemory(Portal portal); static Portal PortalVariableMemoryGetPortal(PortalVariableMemory context); /* ---------------- @@ -838,7 +837,7 @@ PortalDestroy(Portal *portalP) * BadArg if mode is invalid. * ---------------- */ -static void +void PortalResetHeapMemory(Portal portal) { PortalHeapMemory context; diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index cfaea911a52..c299f9a6d53 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.17 1999/07/15 23:04:23 momjian Exp $ + * $Id: portal.h,v 1.18 1999/09/09 16:25:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -75,6 +75,7 @@ extern Portal CreatePortal(char *name); extern void PortalDestroy(Portal *portalP); extern void StartPortalAllocMode(AllocMode mode, Size limit); extern void EndPortalAllocMode(void); +extern void PortalResetHeapMemory(Portal portal); extern PortalVariableMemory PortalGetVariableMemory(Portal portal); extern PortalHeapMemory PortalGetHeapMemory(Portal portal); |