Re: Question about savepoint level? - Mailing list pgsql-hackers
From | Japin Li |
---|---|
Subject | Re: Question about savepoint level? |
Date | |
Msg-id | MEYP282MB1669BBCE684BB68B35DFD38AB62E9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM Whole thread Raw |
In response to | Question about savepoint level? (Japin Li <japinli@hotmail.com>) |
Responses |
Re: Question about savepoint level?
|
List | pgsql-hackers |
On Mon, 24 Oct 2022 at 12:19, Japin Li <japinli@hotmail.com> wrote: > Hi, hackers > > The TransactionStateData has savepointLevel field, however, I do not understand > what is savepoint level, it seems all savepoints have the same savepointLevel, > I want to know how the savepoint level changes. I try to remove the savepointLevel, and it seems harmless. Any thoughts? -- Regrads, Japin Li. ChengDu WenWu Information Technology Co.,Ltd. From 1e5c015efc44bcf2bc93365e99740deb618eebfe Mon Sep 17 00:00:00 2001 From: Japin Li <japinli@hotmail.com> Date: Mon, 24 Oct 2022 14:54:03 +0800 Subject: [PATCH v1] Remove useless savepoint level --- src/backend/access/transam/xact.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index fd5103a78e..e8a90a3a30 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -190,7 +190,6 @@ typedef struct TransactionStateData FullTransactionId fullTransactionId; /* my FullTransactionId */ SubTransactionId subTransactionId; /* my subxact ID */ char *name; /* savepoint name, if any */ - int savepointLevel; /* savepoint level */ TransState state; /* low-level state */ TBlockState blockState; /* high-level state */ int nestingLevel; /* transaction nesting depth */ @@ -3234,12 +3233,10 @@ CommitTransactionCommand(void) case TBLOCK_SUBRESTART: { char *name; - int savepointLevel; /* save name and keep Cleanup from freeing it */ name = s->name; s->name = NULL; - savepointLevel = s->savepointLevel; AbortSubTransaction(); CleanupSubTransaction(); @@ -3247,7 +3244,6 @@ CommitTransactionCommand(void) DefineSavepoint(NULL); s = CurrentTransactionState; /* changed by push */ s->name = name; - s->savepointLevel = savepointLevel; /* This is the same as TBLOCK_SUBBEGIN case */ AssertState(s->blockState == TBLOCK_SUBBEGIN); @@ -3263,19 +3259,16 @@ CommitTransactionCommand(void) case TBLOCK_SUBABORT_RESTART: { char *name; - int savepointLevel; /* save name and keep Cleanup from freeing it */ name = s->name; s->name = NULL; - savepointLevel = s->savepointLevel; CleanupSubTransaction(); DefineSavepoint(NULL); s = CurrentTransactionState; /* changed by push */ s->name = name; - s->savepointLevel = savepointLevel; /* This is the same as TBLOCK_SUBBEGIN case */ AssertState(s->blockState == TBLOCK_SUBBEGIN); @@ -4352,11 +4345,6 @@ ReleaseSavepoint(const char *name) (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("savepoint \"%s\" does not exist", name))); - /* disallow crossing savepoint level boundaries */ - if (target->savepointLevel != s->savepointLevel) - ereport(ERROR, - (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), - errmsg("savepoint \"%s\" does not exist within current savepoint level", name))); /* * Mark "commit pending" all subtransactions up to the target @@ -4461,11 +4449,6 @@ RollbackToSavepoint(const char *name) (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), errmsg("savepoint \"%s\" does not exist", name))); - /* disallow crossing savepoint level boundaries */ - if (target->savepointLevel != s->savepointLevel) - ereport(ERROR, - (errcode(ERRCODE_S_E_INVALID_SPECIFICATION), - errmsg("savepoint \"%s\" does not exist within current savepoint level", name))); /* * Mark "abort pending" all subtransactions up to the target @@ -5253,7 +5236,6 @@ PushTransaction(void) s->parent = p; s->nestingLevel = p->nestingLevel + 1; s->gucNestLevel = NewGUCNestLevel(); - s->savepointLevel = p->savepointLevel; s->state = TRANS_DEFAULT; s->blockState = TBLOCK_SUBBEGIN; GetUserIdAndSecContext(&s->prevUser, &s->prevSecContext); -- 2.25.1
pgsql-hackers by date: