1/*
2 * commit_ts.h
3 *
4 * PostgreSQL commit timestamp manager
5 *
6 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/access/commit_ts.h
10 */
11#ifndef COMMIT_TS_H
12#define COMMIT_TS_H
13
14#include "access/xlog.h"
15#include "datatype/timestamp.h"
16#include "replication/origin.h"
17#include "utils/guc.h"
18
19
20extern PGDLLIMPORT bool track_commit_timestamp;
21
22extern bool check_track_commit_timestamp(bool *newval, void **extra,
23 GucSource source);
24
25extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
26 TransactionId *subxids, TimestampTz timestamp,
27 RepOriginId nodeid, bool write_xlog);
28extern bool TransactionIdGetCommitTsData(TransactionId xid,
29 TimestampTz *ts, RepOriginId *nodeid);
30extern TransactionId GetLatestCommitTsData(TimestampTz *ts,
31 RepOriginId *nodeid);
32
33extern Size CommitTsShmemBuffers(void);
34extern Size CommitTsShmemSize(void);
35extern void CommitTsShmemInit(void);
36extern void BootStrapCommitTs(void);
37extern void StartupCommitTs(void);
38extern void CommitTsParameterChange(bool xlrecvalue, bool pgcontrolvalue);
39extern void CompleteCommitTsInitialization(void);
40extern void ShutdownCommitTs(void);
41extern void CheckPointCommitTs(void);
42extern void ExtendCommitTs(TransactionId newestXact);
43extern void TruncateCommitTs(TransactionId oldestXact);
44extern void SetCommitTsLimit(TransactionId oldestXact,
45 TransactionId newestXact);
46extern void AdvanceOldestCommitTsXid(TransactionId oldestXact);
47
48/* XLOG stuff */
49#define COMMIT_TS_ZEROPAGE 0x00
50#define COMMIT_TS_TRUNCATE 0x10
51#define COMMIT_TS_SETTS 0x20
52
53typedef struct xl_commit_ts_set
54{
55 TimestampTz timestamp;
56 RepOriginId nodeid;
57 TransactionId mainxid;
58 /* subxact Xids follow */
59} xl_commit_ts_set;
60
61#define SizeOfCommitTsSet (offsetof(xl_commit_ts_set, mainxid) + \
62 sizeof(TransactionId))
63
64typedef struct xl_commit_ts_truncate
65{
66 int pageno;
67 TransactionId oldestXid;
68} xl_commit_ts_truncate;
69
70#define SizeOfCommitTsTruncate (offsetof(xl_commit_ts_truncate, oldestXid) + \
71 sizeof(TransactionId))
72
73extern void commit_ts_redo(XLogReaderState *record);
74extern void commit_ts_desc(StringInfo buf, XLogReaderState *record);
75extern const char *commit_ts_identify(uint8 info);
76
77#endif /* COMMIT_TS_H */
78