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 | |
19 | typedef struct xl_replorigin_set |
20 | { |
21 | XLogRecPtr remote_lsn; |
22 | RepOriginId node_id; |
23 | bool force; |
24 | } xl_replorigin_set; |
25 | |
26 | typedef 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 | |
37 | extern PGDLLIMPORT RepOriginId replorigin_session_origin; |
38 | extern PGDLLIMPORT XLogRecPtr replorigin_session_origin_lsn; |
39 | extern PGDLLIMPORT TimestampTz replorigin_session_origin_timestamp; |
40 | |
41 | /* API for querying & manipulating replication origins */ |
42 | extern RepOriginId replorigin_by_name(char *name, bool missing_ok); |
43 | extern RepOriginId replorigin_create(char *name); |
44 | extern void replorigin_drop(RepOriginId roident, bool nowait); |
45 | extern bool replorigin_by_oid(RepOriginId roident, bool missing_ok, |
46 | char **roname); |
47 | |
48 | /* API for querying & manipulating replication progress tracking */ |
49 | extern void replorigin_advance(RepOriginId node, |
50 | XLogRecPtr remote_commit, |
51 | XLogRecPtr local_commit, |
52 | bool go_backward, bool wal_log); |
53 | extern XLogRecPtr replorigin_get_progress(RepOriginId node, bool flush); |
54 | |
55 | extern void replorigin_session_advance(XLogRecPtr remote_commit, |
56 | XLogRecPtr local_commit); |
57 | extern void replorigin_session_setup(RepOriginId node); |
58 | extern void replorigin_session_reset(void); |
59 | extern XLogRecPtr replorigin_session_get_progress(bool flush); |
60 | |
61 | /* Checkpoint/Startup integration */ |
62 | extern void CheckPointReplicationOrigin(void); |
63 | extern void StartupReplicationOrigin(void); |
64 | |
65 | /* WAL logging */ |
66 | void replorigin_redo(XLogReaderState *record); |
67 | void replorigin_desc(StringInfo buf, XLogReaderState *record); |
68 | const char *replorigin_identify(uint8 info); |
69 | |
70 | /* shared memory allocation */ |
71 | extern Size ReplicationOriginShmemSize(void); |
72 | extern void ReplicationOriginShmemInit(void); |
73 | |
74 | #endif /* PG_ORIGIN_H */ |
75 | |