Skip to content

Commit 57eeb0d

Browse files
committed
New memmgr logic in xact.c failed if AbortTransaction() is called when
there is no open transaction.
1 parent e225260 commit 57eeb0d

File tree

1 file changed

+21
-10
lines changed
  • src/backend/access/transam

1 file changed

+21
-10
lines changed

src/backend/access/transam/xact.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.68 2000/06/28 03:31:05 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.69 2000/07/02 02:28:38 tgl Exp $
1212
*
1313
* NOTES
1414
* Transaction aborts can now occur two ways:
@@ -749,6 +749,7 @@ AtCommit_Memory()
749749
* Release all transaction-local memory.
750750
* ----------------
751751
*/
752+
Assert(TopTransactionContext != NULL);
752753
MemoryContextDelete(TopTransactionContext);
753754
TopTransactionContext = NULL;
754755
TransactionCommandContext = NULL;
@@ -825,17 +826,26 @@ AtAbort_Memory()
825826
{
826827
/* ----------------
827828
* Make sure we are in a valid context (not a child of
828-
* TransactionCommandContext...)
829+
* TransactionCommandContext...). Note that it is possible
830+
* for this code to be called when we aren't in a transaction
831+
* at all; go directly to TopMemoryContext in that case.
829832
* ----------------
830833
*/
831-
MemoryContextSwitchTo(TransactionCommandContext);
834+
if (TransactionCommandContext != NULL)
835+
{
836+
MemoryContextSwitchTo(TransactionCommandContext);
832837

833-
/* ----------------
834-
* We do not want to destroy transaction contexts yet,
835-
* but it should be OK to delete any command-local memory.
836-
* ----------------
837-
*/
838-
MemoryContextResetAndDeleteChildren(TransactionCommandContext);
838+
/* ----------------
839+
* We do not want to destroy transaction contexts yet,
840+
* but it should be OK to delete any command-local memory.
841+
* ----------------
842+
*/
843+
MemoryContextResetAndDeleteChildren(TransactionCommandContext);
844+
}
845+
else
846+
{
847+
MemoryContextSwitchTo(TopMemoryContext);
848+
}
839849
}
840850

841851

@@ -863,7 +873,8 @@ AtCleanup_Memory()
863873
* Release all transaction-local memory.
864874
* ----------------
865875
*/
866-
MemoryContextDelete(TopTransactionContext);
876+
if (TopTransactionContext != NULL)
877+
MemoryContextDelete(TopTransactionContext);
867878
TopTransactionContext = NULL;
868879
TransactionCommandContext = NULL;
869880
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy