1 /*-------------------------------------------------------------------------
4 * Two-phase-commit related declarations.
7 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/access/twophase.h
12 *-------------------------------------------------------------------------
17 #include "access/xact.h"
18 #include "access/xlogdefs.h"
19 #include "datatype/timestamp.h"
20 #include "storage/lock.h"
23 * GlobalTransactionData is defined in twophase.c; other places have no
24 * business knowing the internal definition.
26 typedef struct GlobalTransactionData
*GlobalTransaction
;
29 extern PGDLLIMPORT
int max_prepared_xacts
;
31 extern Size
TwoPhaseShmemSize(void);
32 extern void TwoPhaseShmemInit(void);
34 extern void AtAbort_Twophase(void);
35 extern void PostPrepare_Twophase(void);
37 extern PGPROC
*TwoPhaseGetDummyProc(TransactionId xid
, bool lock_held
);
38 extern BackendId
TwoPhaseGetDummyBackendId(TransactionId xid
, bool lock_held
);
40 extern GlobalTransaction
MarkAsPreparing(TransactionId xid
, const char *gid
,
41 TimestampTz prepared_at
,
42 Oid owner
, Oid databaseid
);
44 extern void StartPrepare(GlobalTransaction gxact
);
45 extern void EndPrepare(GlobalTransaction gxact
);
46 extern bool StandbyTransactionIdIsPrepared(TransactionId xid
);
48 extern TransactionId
PrescanPreparedTransactions(TransactionId
**xids_p
,
50 extern void StandbyRecoverPreparedTransactions(void);
51 extern void RecoverPreparedTransactions(void);
53 extern void CheckPointTwoPhase(XLogRecPtr redo_horizon
);
55 extern void FinishPreparedTransaction(const char *gid
, bool isCommit
);
57 extern void PrepareRedoAdd(char *buf
, XLogRecPtr start_lsn
,
58 XLogRecPtr end_lsn
, RepOriginId origin_id
);
59 extern void PrepareRedoRemove(TransactionId xid
, bool giveWarning
);
60 extern void restoreTwoPhaseData(void);
61 extern bool LookupGXact(const char *gid
, XLogRecPtr prepare_at_lsn
,
62 TimestampTz origin_prepare_timestamp
);
63 #endif /* TWOPHASE_H */