|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * Transaction aborts can now occur two ways:
|
@@ -749,6 +749,7 @@ AtCommit_Memory()
|
749 | 749 | * Release all transaction-local memory.
|
750 | 750 | * ----------------
|
751 | 751 | */
|
| 752 | + Assert(TopTransactionContext != NULL); |
752 | 753 | MemoryContextDelete(TopTransactionContext);
|
753 | 754 | TopTransactionContext = NULL;
|
754 | 755 | TransactionCommandContext = NULL;
|
@@ -825,17 +826,26 @@ AtAbort_Memory()
|
825 | 826 | {
|
826 | 827 | /* ----------------
|
827 | 828 | * 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. |
829 | 832 | * ----------------
|
830 | 833 | */
|
831 |
| - MemoryContextSwitchTo(TransactionCommandContext); |
| 834 | + if (TransactionCommandContext != NULL) |
| 835 | + { |
| 836 | + MemoryContextSwitchTo(TransactionCommandContext); |
832 | 837 |
|
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 | + } |
839 | 849 | }
|
840 | 850 |
|
841 | 851 |
|
@@ -863,7 +873,8 @@ AtCleanup_Memory()
|
863 | 873 | * Release all transaction-local memory.
|
864 | 874 | * ----------------
|
865 | 875 | */
|
866 |
| - MemoryContextDelete(TopTransactionContext); |
| 876 | + if (TopTransactionContext != NULL) |
| 877 | + MemoryContextDelete(TopTransactionContext); |
867 | 878 | TopTransactionContext = NULL;
|
868 | 879 | TransactionCommandContext = NULL;
|
869 | 880 | }
|
|
0 commit comments