diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-05-13 00:34:57 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-05-13 00:34:57 +0000 |
commit | 0b885e2397c695b6cf7db8c4f93f5272706e1672 (patch) | |
tree | 9f8331c869811fcb986da9ad64a97cc087c34627 /src | |
parent | eb4d9f45efdf6e80fb44209b59131391683e6275 (diff) | |
download | postgresql-0b885e2397c695b6cf7db8c4f93f5272706e1672.tar.gz postgresql-0b885e2397c695b6cf7db8c4f93f5272706e1672.zip |
Release allocated memory during AtAbort_Memory.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xact.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 60341ad1b74..f125baed6db 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.34 1999/05/09 00:52:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.35 1999/05/13 00:34:57 tgl Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -690,13 +690,27 @@ AtCommit_Locks() static void AtCommit_Memory() { + Portal portal; + MemoryContext portalContext; + /* ---------------- - * now that we're "out" of a transaction, have the + * 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...) + * ---------------- + */ + portal = GetPortalByName(NULL); + portalContext = (MemoryContext) PortalGetHeapMemory(portal); + MemoryContextSwitchTo(portalContext); + EndPortalAllocMode(); + + /* ---------------- + * Now that we're "out" of a transaction, have the * system allocate things in the top memory context instead * of the blank portal memory context. * ---------------- */ - EndPortalAllocMode(); MemoryContextSwitchTo(TopMemoryContext); } @@ -770,10 +784,25 @@ AtAbort_Locks() 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.) + * ---------------- + */ + portal = GetPortalByName(NULL); + portalContext = (MemoryContext) PortalGetHeapMemory(portal); + MemoryContextSwitchTo(portalContext); + EndPortalAllocMode(); + /* ---------------- - * after doing an abort transaction, make certain the - * system uses the top memory context rather then the - * portal memory context (until the next transaction). + * Now that we're "out" of a transaction, have the + * system allocate things in the top memory context instead + * of the blank portal memory context. * ---------------- */ MemoryContextSwitchTo(TopMemoryContext); |