1/*-------------------------------------------------------------------------
2 * origin.h
3 * Exports from replication/logical/origin.c
4 *
5 * Copyright (c) 2013-2019, PostgreSQL Global Development Group
6 *
7 * src/include/replication/origin.h
8 *-------------------------------------------------------------------------
9 */
10#ifndef PG_ORIGIN_H
11#define PG_ORIGIN_H
12
13#include "fmgr.h"
14#include "access/xlog.h"
15#include "access/xlogdefs.h"
16#include "access/xlogreader.h"
17#include "catalog/pg_replication_origin.h"
18
19typedef struct xl_replorigin_set
20{
21 XLogRecPtr remote_lsn;
22 RepOriginId node_id;
23 bool force;
24} xl_replorigin_set;
25
26typedef struct xl_replorigin_drop
27{
28 RepOriginId node_id;
29} xl_replorigin_drop;
30
31#define XLOG_REPLORIGIN_SET 0x00
32#define XLOG_REPLORIGIN_DROP 0x10
33
34#define InvalidRepOriginId 0
35#define DoNotReplicateId PG_UINT16_MAX
36
37extern PGDLLIMPORT RepOriginId replorigin_session_origin;
38extern PGDLLIMPORT XLogRecPtr replorigin_session_origin_lsn;
39extern PGDLLIMPORT TimestampTz replorigin_session_origin_timestamp;
40
41/* API for querying & manipulating replication origins */
42extern RepOriginId replorigin_by_name(char *name, bool missing_ok);
43extern RepOriginId replorigin_create(char *name);
44extern void replorigin_drop(RepOriginId roident, bool nowait);
45extern bool replorigin_by_oid(RepOriginId roident, bool missing_ok,
46 char **roname);
47
48/* API for querying & manipulating replication progress tracking */
49extern void replorigin_advance(RepOriginId node,
50 XLogRecPtr remote_commit,
51 XLogRecPtr local_commit,
52 bool go_backward, bool wal_log);
53extern XLogRecPtr replorigin_get_progress(RepOriginId node, bool flush);
54
55extern void replorigin_session_advance(XLogRecPtr remote_commit,
56 XLogRecPtr local_commit);
57extern void replorigin_session_setup(RepOriginId node);
58extern void replorigin_session_reset(void);
59extern XLogRecPtr replorigin_session_get_progress(bool flush);
60
61/* Checkpoint/Startup integration */
62extern void CheckPointReplicationOrigin(void);
63extern void StartupReplicationOrigin(void);
64
65/* WAL logging */
66void replorigin_redo(XLogReaderState *record);
67void replorigin_desc(StringInfo buf, XLogReaderState *record);
68const char *replorigin_identify(uint8 info);
69
70/* shared memory allocation */
71extern Size ReplicationOriginShmemSize(void);
72extern void ReplicationOriginShmemInit(void);
73
74#endif /* PG_ORIGIN_H */
75