Skip to content

Commit e826954

Browse files
committed
Fix bugs in save/restore/release savepoint mechanism
1 parent 6f0ebdc commit e826954

File tree

1 file changed

+4
-1
lines changed
  • src/backend/access/transam

1 file changed

+4
-1
lines changed

src/backend/access/transam/xact.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ static TransactionStateData TopTransactionStateData = {
207207
0, /* subtransaction id */
208208
NULL, /* savepoint name */
209209
0, /* savepoint level */
210+
NULL, /* savepoint context */
210211
TRANS_DEFAULT, /* transaction state */
211212
TBLOCK_DEFAULT, /* transaction block state from the client
212213
* perspective */
@@ -4096,7 +4097,6 @@ DefineSavepoint(char *name)
40964097
*/
40974098
if (name)
40984099
s->name = MemoryContextStrdup(TopTransactionContext, name);
4099-
s->savepointContext = TM->CreateSavepointContext();
41004100
break;
41014101

41024102
/* These cases are invalid. */
@@ -5085,6 +5085,7 @@ PushTransaction(void)
50855085
GetUserIdAndSecContext(&s->prevUser, &s->prevSecContext);
50865086
s->prevXactReadOnly = XactReadOnly;
50875087
s->parallelModeLevel = 0;
5088+
s->savepointContext = TM->CreateSavepointContext();
50885089

50895090
CurrentTransactionState = s;
50905091

@@ -5115,7 +5116,9 @@ PopTransaction(void)
51155116
if (s->parent == NULL)
51165117
elog(FATAL, "PopTransaction with no parent");
51175118

5119+
TM->ReleaseSavepointContext(s->savepointContext);
51185120
CurrentTransactionState = s->parent;
5121+
TM->RestoreSavepointContext(CurrentTransactionState->savepointContext);
51195122

51205123
/* Let's just make sure CurTransactionContext is good */
51215124
CurTransactionContext = s->parent->curTransactionContext;

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