1/*-------------------------------------------------------------------------
2 *
3 * twophase.h
4 * Two-phase-commit related declarations.
5 *
6 *
7 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/access/twophase.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef TWOPHASE_H
15#define TWOPHASE_H
16
17#include "access/xlogdefs.h"
18#include "access/xact.h"
19#include "datatype/timestamp.h"
20#include "storage/lock.h"
21
22/*
23 * GlobalTransactionData is defined in twophase.c; other places have no
24 * business knowing the internal definition.
25 */
26typedef struct GlobalTransactionData *GlobalTransaction;
27
28/* GUC variable */
29extern PGDLLIMPORT int max_prepared_xacts;
30
31extern Size TwoPhaseShmemSize(void);
32extern void TwoPhaseShmemInit(void);
33
34extern void AtAbort_Twophase(void);
35extern void PostPrepare_Twophase(void);
36
37extern PGPROC *TwoPhaseGetDummyProc(TransactionId xid, bool lock_held);
38extern BackendId TwoPhaseGetDummyBackendId(TransactionId xid, bool lock_held);
39
40extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid,
41 TimestampTz prepared_at,
42 Oid owner, Oid databaseid);
43
44extern void StartPrepare(GlobalTransaction gxact);
45extern void EndPrepare(GlobalTransaction gxact);
46extern bool StandbyTransactionIdIsPrepared(TransactionId xid);
47
48extern TransactionId PrescanPreparedTransactions(TransactionId **xids_p,
49 int *nxids_p);
50extern void ParsePrepareRecord(uint8 info, char *xlrec,
51 xl_xact_parsed_prepare *parsed);
52extern void StandbyRecoverPreparedTransactions(void);
53extern void RecoverPreparedTransactions(void);
54
55extern void CheckPointTwoPhase(XLogRecPtr redo_horizon);
56
57extern void FinishPreparedTransaction(const char *gid, bool isCommit);
58
59extern void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn,
60 XLogRecPtr end_lsn, RepOriginId origin_id);
61extern void PrepareRedoRemove(TransactionId xid, bool giveWarning);
62extern void restoreTwoPhaseData(void);
63#endif /* TWOPHASE_H */
64