diff options
Diffstat (limited to 'src/include/access')
-rw-r--r-- | src/include/access/commit_ts.h | 14 | ||||
-rw-r--r-- | src/include/access/rmgrlist.h | 1 | ||||
-rw-r--r-- | src/include/access/xact.h | 11 | ||||
-rw-r--r-- | src/include/access/xlog.h | 1 | ||||
-rw-r--r-- | src/include/access/xlog_internal.h | 2 | ||||
-rw-r--r-- | src/include/access/xlogdefs.h | 6 | ||||
-rw-r--r-- | src/include/access/xloginsert.h | 1 | ||||
-rw-r--r-- | src/include/access/xlogreader.h | 3 | ||||
-rw-r--r-- | src/include/access/xlogrecord.h | 1 |
9 files changed, 30 insertions, 10 deletions
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h index 93d1217f766..ad44db357aa 100644 --- a/src/include/access/commit_ts.h +++ b/src/include/access/commit_ts.h @@ -13,6 +13,7 @@ #include "access/xlog.h" #include "datatype/timestamp.h" +#include "replication/origin.h" #include "utils/guc.h" @@ -21,18 +22,13 @@ extern PGDLLIMPORT bool track_commit_timestamp; extern bool check_track_commit_timestamp(bool *newval, void **extra, GucSource source); -typedef uint32 CommitTsNodeId; -#define InvalidCommitTsNodeId 0 - -extern void CommitTsSetDefaultNodeId(CommitTsNodeId nodeid); -extern CommitTsNodeId CommitTsGetDefaultNodeId(void); extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids, TransactionId *subxids, TimestampTz timestamp, - CommitTsNodeId nodeid, bool do_xlog); + RepOriginId nodeid, bool do_xlog); extern bool TransactionIdGetCommitTsData(TransactionId xid, - TimestampTz *ts, CommitTsNodeId *nodeid); + TimestampTz *ts, RepOriginId *nodeid); extern TransactionId GetLatestCommitTsData(TimestampTz *ts, - CommitTsNodeId *nodeid); + RepOriginId *nodeid); extern Size CommitTsShmemBuffers(void); extern Size CommitTsShmemSize(void); @@ -58,7 +54,7 @@ extern void AdvanceOldestCommitTs(TransactionId oldestXact); typedef struct xl_commit_ts_set { TimestampTz timestamp; - CommitTsNodeId nodeid; + RepOriginId nodeid; TransactionId mainxid; /* subxact Xids follow */ } xl_commit_ts_set; diff --git a/src/include/access/rmgrlist.h b/src/include/access/rmgrlist.h index 48f04c61716..47033da017b 100644 --- a/src/include/access/rmgrlist.h +++ b/src/include/access/rmgrlist.h @@ -44,3 +44,4 @@ PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, seq_identify, NULL, NULL) PG_RMGR(RM_SPGIST_ID, "SPGist", spg_redo, spg_desc, spg_identify, spg_xlog_startup, spg_xlog_cleanup) PG_RMGR(RM_BRIN_ID, "BRIN", brin_redo, brin_desc, brin_identify, NULL, NULL) PG_RMGR(RM_COMMIT_TS_ID, "CommitTs", commit_ts_redo, commit_ts_desc, commit_ts_identify, NULL, NULL) +PG_RMGR(RM_REPLORIGIN_ID, "ReplicationOrigin", replorigin_redo, replorigin_desc, replorigin_identify, NULL, NULL) diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 8da6aa952f0..cad1bb1d318 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -131,6 +131,7 @@ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid, #define XACT_XINFO_HAS_RELFILENODES (1U << 2) #define XACT_XINFO_HAS_INVALS (1U << 3) #define XACT_XINFO_HAS_TWOPHASE (1U << 4) +#define XACT_XINFO_HAS_ORIGIN (1U << 5) /* * Also stored in xinfo, these indicating a variety of additional actions that @@ -217,6 +218,12 @@ typedef struct xl_xact_twophase } xl_xact_twophase; #define MinSizeOfXactInvals offsetof(xl_xact_invals, msgs) +typedef struct xl_xact_origin +{ + XLogRecPtr origin_lsn; + TimestampTz origin_timestamp; +} xl_xact_origin; + typedef struct xl_xact_commit { TimestampTz xact_time; /* time of commit */ @@ -227,6 +234,7 @@ typedef struct xl_xact_commit /* xl_xact_relfilenodes follows if XINFO_HAS_RELFILENODES */ /* xl_xact_invals follows if XINFO_HAS_INVALS */ /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */ + /* xl_xact_origin follows if XINFO_HAS_ORIGIN */ } xl_xact_commit; #define MinSizeOfXactCommit (offsetof(xl_xact_commit, xact_time) + sizeof(TimestampTz)) @@ -267,6 +275,9 @@ typedef struct xl_xact_parsed_commit SharedInvalidationMessage *msgs; TransactionId twophase_xid; /* only for 2PC */ + + XLogRecPtr origin_lsn; + TimestampTz origin_timestamp; } xl_xact_parsed_commit; typedef struct xl_xact_parsed_abort diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 2b1f42389cb..f08b6767ed7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -85,6 +85,7 @@ typedef enum } RecoveryTargetType; extern XLogRecPtr XactLastRecEnd; +extern PGDLLIMPORT XLogRecPtr XactLastCommitEnd; extern bool reachedConsistency; diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index deca1de67b0..75cf435e90f 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -31,7 +31,7 @@ /* * Each page of XLOG file has a header like this: */ -#define XLOG_PAGE_MAGIC 0xD083 /* can be used as WAL version indicator */ +#define XLOG_PAGE_MAGIC 0xD085 /* can be used as WAL version indicator */ typedef struct XLogPageHeaderData { diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index 6638c1d4228..18a3e7ca905 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.h @@ -45,6 +45,12 @@ typedef uint64 XLogSegNo; typedef uint32 TimeLineID; /* + * Replication origin id - this is located in this file to avoid having to + * include origin.h in a bunch of xlog related places. + */ +typedef uint16 RepOriginId; + +/* * Because O_DIRECT bypasses the kernel buffers, and because we never * read those buffers except during crash recovery or if wal_level != minimal, * it is a win to use it in all cases where we sync on each write(). We could diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h index 6864c95b2c7..ac609298cc2 100644 --- a/src/include/access/xloginsert.h +++ b/src/include/access/xloginsert.h @@ -39,6 +39,7 @@ /* prototypes for public functions in xloginsert.c: */ extern void XLogBeginInsert(void); +extern void XLogIncludeOrigin(void); extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info); extern void XLogEnsureRecordSpace(int nbuffers, int ndatas); extern void XLogRegisterData(char *data, int len); diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index 609bfe3e40f..5164abec758 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -127,6 +127,8 @@ struct XLogReaderState uint32 main_data_len; /* main data portion's length */ uint32 main_data_bufsz; /* allocated size of the buffer */ + RepOriginId record_origin; + /* information about blocks referenced by the record. */ DecodedBkpBlock blocks[XLR_MAX_BLOCK_ID + 1]; @@ -186,6 +188,7 @@ extern bool DecodeXLogRecord(XLogReaderState *state, XLogRecord *record, #define XLogRecGetInfo(decoder) ((decoder)->decoded_record->xl_info) #define XLogRecGetRmid(decoder) ((decoder)->decoded_record->xl_rmid) #define XLogRecGetXid(decoder) ((decoder)->decoded_record->xl_xid) +#define XLogRecGetOrigin(decoder) ((decoder)->record_origin) #define XLogRecGetData(decoder) ((decoder)->main_data) #define XLogRecGetDataLen(decoder) ((decoder)->main_data_len) #define XLogRecHasAnyBlockRefs(decoder) ((decoder)->max_block_id >= 0) diff --git a/src/include/access/xlogrecord.h b/src/include/access/xlogrecord.h index b487ae0cc8e..7a049f0e979 100644 --- a/src/include/access/xlogrecord.h +++ b/src/include/access/xlogrecord.h @@ -212,5 +212,6 @@ typedef struct XLogRecordDataHeaderLong #define XLR_BLOCK_ID_DATA_SHORT 255 #define XLR_BLOCK_ID_DATA_LONG 254 +#define XLR_BLOCK_ID_ORIGIN 253 #endif /* XLOGRECORD_H */ |