Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit043ce02

Browse files
committed
[PGPRO-4074] missing_ok for FinishPreparedTransaction.
tags: multimaster(cherry picked from commit 9307fdc35017d846face8fcbd2210a15eaa965cb)
1 parent008afc4 commit043ce02

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

‎src/backend/access/transam/twophase.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ MarkAsPrepared(GlobalTransaction gxact, bool lock_held)
555555
*Locate the prepared transaction and mark it busy for COMMIT or PREPARE.
556556
*/
557557
staticGlobalTransaction
558-
LockGXact(constchar*gid,Oiduser)
558+
LockGXact(constchar*gid,Oiduser,boolmissing_ok)
559559
{
560560
inti;
561561

@@ -615,7 +615,8 @@ LockGXact(const char *gid, Oid user)
615615

616616
LWLockRelease(TwoPhaseStateLock);
617617

618-
ereport(ERROR,
618+
if (!missing_ok)
619+
ereport(ERROR,
619620
(errcode(ERRCODE_UNDEFINED_OBJECT),
620621
errmsg("prepared transaction with identifier \"%s\" does not exist",
621622
gid)));
@@ -1400,7 +1401,7 @@ StandbyTransactionIdIsPrepared(TransactionId xid)
14001401
* FinishPreparedTransaction: execute COMMIT PREPARED or ROLLBACK PREPARED
14011402
*/
14021403
void
1403-
FinishPreparedTransaction(constchar*gid,boolisCommit)
1404+
FinishPreparedTransaction(constchar*gid,boolisCommit,boolmissing_ok)
14041405
{
14051406
GlobalTransactiongxact;
14061407
PGPROC*proc;
@@ -1420,8 +1421,16 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
14201421
/*
14211422
* Validate the GID, and lock the GXACT to ensure that two backends do not
14221423
* try to commit the same GID at once.
1424+
*
1425+
* missing_ok is multimaster support
14231426
*/
1424-
gxact=LockGXact(gid,GetUserId());
1427+
gxact=LockGXact(gid,GetUserId(),missing_ok);
1428+
if (gxact==NULL)
1429+
{
1430+
Assert(missing_ok);
1431+
return;
1432+
}
1433+
14251434
proc=&ProcGlobal->allProcs[gxact->pgprocno];
14261435
pgxact=&ProcGlobal->allPgXact[gxact->pgprocno];
14271436
xid=pgxact->xid;

‎src/backend/tcop/utility.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,12 @@ standard_ProcessUtility(PlannedStmt *pstmt,
635635

636636
caseTRANS_STMT_COMMIT_PREPARED:
637637
PreventInTransactionBlock(isTopLevel,"COMMIT PREPARED");
638-
FinishPreparedTransaction(stmt->gid, true);
638+
FinishPreparedTransaction(stmt->gid, true, false);
639639
break;
640640

641641
caseTRANS_STMT_ROLLBACK_PREPARED:
642642
PreventInTransactionBlock(isTopLevel,"ROLLBACK PREPARED");
643-
FinishPreparedTransaction(stmt->gid, false);
643+
FinishPreparedTransaction(stmt->gid, false, false);
644644
break;
645645

646646
caseTRANS_STMT_ROLLBACK:

‎src/include/access/twophase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ extern void RecoverPreparedTransactions(void);
5252

5353
externvoidCheckPointTwoPhase(XLogRecPtrredo_horizon);
5454

55-
externvoidFinishPreparedTransaction(constchar*gid,boolisCommit);
55+
externvoidFinishPreparedTransaction(constchar*gid,boolisCommit,
56+
boolmissing_ok);
5657

5758
externvoidPrepareRedoAdd(char*buf,XLogRecPtrstart_lsn,
5859
XLogRecPtrend_lsn,RepOriginIdorigin_id);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp