@@ -207,6 +207,7 @@ static TransactionStateData TopTransactionStateData = {
207
207
0 ,/* subtransaction id */
208
208
NULL ,/* savepoint name */
209
209
0 ,/* savepoint level */
210
+ NULL ,/* savepoint context */
210
211
TRANS_DEFAULT ,/* transaction state */
211
212
TBLOCK_DEFAULT ,/* transaction block state from the client
212
213
* perspective */
@@ -4096,7 +4097,6 @@ DefineSavepoint(char *name)
4096
4097
*/
4097
4098
if (name )
4098
4099
s -> name = MemoryContextStrdup (TopTransactionContext ,name );
4099
- s -> savepointContext = TM -> CreateSavepointContext ();
4100
4100
break ;
4101
4101
4102
4102
/* These cases are invalid. */
@@ -5085,6 +5085,7 @@ PushTransaction(void)
5085
5085
GetUserIdAndSecContext (& s -> prevUser ,& s -> prevSecContext );
5086
5086
s -> prevXactReadOnly = XactReadOnly ;
5087
5087
s -> parallelModeLevel = 0 ;
5088
+ s -> savepointContext = TM -> CreateSavepointContext ();
5088
5089
5089
5090
CurrentTransactionState = s ;
5090
5091
@@ -5115,7 +5116,9 @@ PopTransaction(void)
5115
5116
if (s -> parent == NULL )
5116
5117
elog (FATAL ,"PopTransaction with no parent" );
5117
5118
5119
+ TM -> ReleaseSavepointContext (s -> savepointContext );
5118
5120
CurrentTransactionState = s -> parent ;
5121
+ TM -> RestoreSavepointContext (CurrentTransactionState -> savepointContext );
5119
5122
5120
5123
/* Let's just make sure CurTransactionContext is good */
5121
5124
CurTransactionContext = s -> parent -> curTransactionContext ;