Commit 57eeb0d3 authored by Tom Lane's avatar Tom Lane

New memmgr logic in xact.c failed if AbortTransaction() is called when

there is no open transaction.
parent e2252604
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.68 2000/06/28 03:31:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.69 2000/07/02 02:28:38 tgl Exp $
* *
* NOTES * NOTES
* Transaction aborts can now occur two ways: * Transaction aborts can now occur two ways:
...@@ -749,6 +749,7 @@ AtCommit_Memory() ...@@ -749,6 +749,7 @@ AtCommit_Memory()
* Release all transaction-local memory. * Release all transaction-local memory.
* ---------------- * ----------------
*/ */
Assert(TopTransactionContext != NULL);
MemoryContextDelete(TopTransactionContext); MemoryContextDelete(TopTransactionContext);
TopTransactionContext = NULL; TopTransactionContext = NULL;
TransactionCommandContext = NULL; TransactionCommandContext = NULL;
...@@ -825,9 +826,13 @@ AtAbort_Memory() ...@@ -825,9 +826,13 @@ AtAbort_Memory()
{ {
/* ---------------- /* ----------------
* Make sure we are in a valid context (not a child of * Make sure we are in a valid context (not a child of
* TransactionCommandContext...) * TransactionCommandContext...). Note that it is possible
* for this code to be called when we aren't in a transaction
* at all; go directly to TopMemoryContext in that case.
* ---------------- * ----------------
*/ */
if (TransactionCommandContext != NULL)
{
MemoryContextSwitchTo(TransactionCommandContext); MemoryContextSwitchTo(TransactionCommandContext);
/* ---------------- /* ----------------
...@@ -836,6 +841,11 @@ AtAbort_Memory() ...@@ -836,6 +841,11 @@ AtAbort_Memory()
* ---------------- * ----------------
*/ */
MemoryContextResetAndDeleteChildren(TransactionCommandContext); MemoryContextResetAndDeleteChildren(TransactionCommandContext);
}
else
{
MemoryContextSwitchTo(TopMemoryContext);
}
} }
...@@ -863,6 +873,7 @@ AtCleanup_Memory() ...@@ -863,6 +873,7 @@ AtCleanup_Memory()
* Release all transaction-local memory. * Release all transaction-local memory.
* ---------------- * ----------------
*/ */
if (TopTransactionContext != NULL)
MemoryContextDelete(TopTransactionContext); MemoryContextDelete(TopTransactionContext);
TopTransactionContext = NULL; TopTransactionContext = NULL;
TransactionCommandContext = NULL; TransactionCommandContext = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment