8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.146 2003/04/26 20:22:59 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.147 2003/05/02 20:54:33 tgl Exp $
12
12
*
13
13
* NOTES
14
14
* Transaction aborts can now occur two ways:
49
49
* * CleanupTransaction() executes when we finally see a user COMMIT
50
50
* or ROLLBACK command; it cleans things up and gets us out of
51
51
* the transaction internally. In particular, we mustn't destroy
52
- * TransactionCommandContext until this point.
52
+ * TopTransactionContext until this point.
53
53
*
54
54
* NOTES
55
55
* The essential aspects of the transaction system are:
@@ -456,13 +456,12 @@ static void
456
456
AtStart_Memory (void )
457
457
{
458
458
/*
459
- * We shouldn't have any transaction contexts already.
459
+ * We shouldn't have a transaction context already.
460
460
*/
461
461
Assert (TopTransactionContext == NULL );
462
- Assert (TransactionCommandContext == NULL );
463
462
464
463
/*
465
- * Create a toplevel context for the transaction.
464
+ * Create a toplevel context for the transaction, and make it active .
466
465
*/
467
466
TopTransactionContext =
468
467
AllocSetContextCreate (TopMemoryContext ,
@@ -471,16 +470,7 @@ AtStart_Memory(void)
471
470
ALLOCSET_DEFAULT_INITSIZE ,
472
471
ALLOCSET_DEFAULT_MAXSIZE );
473
472
474
- /*
475
- * Create a statement-level context and make it active.
476
- */
477
- TransactionCommandContext =
478
- AllocSetContextCreate (TopTransactionContext ,
479
- "TransactionCommandContext" ,
480
- ALLOCSET_DEFAULT_MINSIZE ,
481
- ALLOCSET_DEFAULT_INITSIZE ,
482
- ALLOCSET_DEFAULT_MAXSIZE );
483
- MemoryContextSwitchTo (TransactionCommandContext );
473
+ MemoryContextSwitchTo (TopTransactionContext );
484
474
}
485
475
486
476
@@ -659,7 +649,6 @@ AtCommit_Memory(void)
659
649
Assert (TopTransactionContext != NULL );
660
650
MemoryContextDelete (TopTransactionContext );
661
651
TopTransactionContext = NULL ;
662
- TransactionCommandContext = NULL ;
663
652
}
664
653
665
654
/* ----------------------------------------------------------------
@@ -769,19 +758,18 @@ AtAbort_Memory(void)
769
758
{
770
759
/*
771
760
* Make sure we are in a valid context (not a child of
772
- * TransactionCommandContext ...). Note that it is possible for this
761
+ * TopTransactionContext ...). Note that it is possible for this
773
762
* code to be called when we aren't in a transaction at all; go
774
763
* directly to TopMemoryContext in that case.
775
764
*/
776
- if (TransactionCommandContext != NULL )
765
+ if (TopTransactionContext != NULL )
777
766
{
778
- MemoryContextSwitchTo (TransactionCommandContext );
767
+ MemoryContextSwitchTo (TopTransactionContext );
779
768
780
769
/*
781
- * We do not want to destroy transaction contexts yet, but it
782
- * should be OK to delete any command-local memory.
770
+ * We do not want to destroy the transaction's global state yet,
771
+ * so we can't free any memory here .
783
772
*/
784
- MemoryContextResetAndDeleteChildren (TransactionCommandContext );
785
773
}
786
774
else
787
775
MemoryContextSwitchTo (TopMemoryContext );
@@ -812,7 +800,6 @@ AtCleanup_Memory(void)
812
800
if (TopTransactionContext != NULL )
813
801
MemoryContextDelete (TopTransactionContext );
814
802
TopTransactionContext = NULL ;
815
- TransactionCommandContext = NULL ;
816
803
}
817
804
818
805
@@ -926,7 +913,7 @@ CommitTransaction(void)
926
913
* access, and in fact could still cause an error...)
927
914
*/
928
915
929
- AtEOXact_portals (true );
916
+ AtCommit_Portals ( );
930
917
931
918
/* handle commit for large objects [ PA, 7/17/98 ] */
932
919
/* XXX probably this does not belong here */
@@ -1057,7 +1044,7 @@ AbortTransaction(void)
1057
1044
* do abort processing
1058
1045
*/
1059
1046
DeferredTriggerAbortXact ();
1060
- AtEOXact_portals (false );
1047
+ AtAbort_Portals ( );
1061
1048
lo_commit (false); /* 'false' means it's abort */
1062
1049
AtAbort_Notify ();
1063
1050
AtEOXact_UpdatePasswordFile (false);
@@ -1126,7 +1113,8 @@ CleanupTransaction(void)
1126
1113
/*
1127
1114
* do abort cleanup processing
1128
1115
*/
1129
- AtCleanup_Memory ();
1116
+ AtCleanup_Portals (); /* now safe to release portal memory */
1117
+ AtCleanup_Memory (); /* and transaction memory */
1130
1118
1131
1119
/*
1132
1120
* done with abort processing, set current transaction state back to
@@ -1220,11 +1208,11 @@ StartTransactionCommand(bool preventChain)
1220
1208
}
1221
1209
1222
1210
/*
1223
- * We must switch to TransactionCommandContext before returning. This
1211
+ * We must switch to TopTransactionContext before returning. This
1224
1212
* is already done if we called StartTransaction, otherwise not.
1225
1213
*/
1226
- Assert (TransactionCommandContext != NULL );
1227
- MemoryContextSwitchTo (TransactionCommandContext );
1214
+ Assert (TopTransactionContext != NULL );
1215
+ MemoryContextSwitchTo (TopTransactionContext );
1228
1216
}
1229
1217
1230
1218
/*
@@ -1266,7 +1254,6 @@ CommitTransactionCommand(bool forceCommit)
1266
1254
Assert (s -> blockState == TBLOCK_INPROGRESS );
1267
1255
/* This code must match the TBLOCK_INPROGRESS case below: */
1268
1256
CommandCounterIncrement ();
1269
- MemoryContextResetAndDeleteChildren (TransactionCommandContext );
1270
1257
}
1271
1258
break ;
1272
1259
@@ -1283,15 +1270,10 @@ CommitTransactionCommand(bool forceCommit)
1283
1270
/*
1284
1271
* This is the case when we have finished executing a command
1285
1272
* someplace within a transaction block. We increment the
1286
- * command counter and return. Someday we may free resources
1287
- * local to the command.
1288
- *
1289
- * That someday is today, at least for memory allocated in
1290
- * TransactionCommandContext. - vadim 03/25/97
1273
+ * command counter and return.
1291
1274
*/
1292
1275
case TBLOCK_INPROGRESS :
1293
1276
CommandCounterIncrement ();
1294
- MemoryContextResetAndDeleteChildren (TransactionCommandContext );
1295
1277
break ;
1296
1278
1297
1279
/*
0 commit comments