PostgreSQL Source Code  git master
logicalproto.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * logicalproto.h
4  * logical replication protocol
5  *
6  * Copyright (c) 2015-2018, PostgreSQL Global Development Group
7  *
8  * IDENTIFICATION
9  * src/include/replication/logicalproto.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef LOGICAL_PROTO_H
14 #define LOGICAL_PROTO_H
15 
17 #include "utils/rel.h"
18 
19 /*
20  * Protocol capabilities
21  *
22  * LOGICAL_PROTO_VERSION_NUM is our native protocol and the greatest version
23  * we can support. PGLOGICAL_PROTO_MIN_VERSION_NUM is the oldest version we
24  * have backwards compatibility for. The client requests protocol version at
25  * connect time.
26  */
27 #define LOGICALREP_PROTO_MIN_VERSION_NUM 1
28 #define LOGICALREP_PROTO_VERSION_NUM 1
29 
30 /* Tuple coming via logical replication. */
31 typedef struct LogicalRepTupleData
32 {
33  /* column values in text format, or NULL for a null value: */
35  /* markers for changed/unchanged column values: */
38 
40 
41 /* Relation information */
42 typedef struct LogicalRepRelation
43 {
44  /* Info coming from the remote side. */
45  LogicalRepRelId remoteid; /* unique id of the relation */
46  char *nspname; /* schema name */
47  char *relname; /* relation name */
48  int natts; /* number of columns */
49  char **attnames; /* column names */
50  Oid *atttyps; /* column types */
51  char replident; /* replica identity */
52  Bitmapset *attkeys; /* Bitmap of key columns */
54 
55 /* Type mapping info */
56 typedef struct LogicalRepTyp
57 {
58  Oid remoteid; /* unique id of the remote type */
59  char *nspname; /* schema name of remote type */
60  char *typname; /* name of the remote type */
62 
63 /* Transaction info */
64 typedef struct LogicalRepBeginData
65 {
70 
71 typedef struct LogicalRepCommitData
72 {
77 
79 extern void logicalrep_read_begin(StringInfo in,
80  LogicalRepBeginData *begin_data);
82  XLogRecPtr commit_lsn);
83 extern void logicalrep_read_commit(StringInfo in,
84  LogicalRepCommitData *commit_data);
85 extern void logicalrep_write_origin(StringInfo out, const char *origin,
86  XLogRecPtr origin_lsn);
87 extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn);
88 extern void logicalrep_write_insert(StringInfo out, Relation rel,
89  HeapTuple newtuple);
91 extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
92  HeapTuple newtuple);
94  bool *has_oldtuple, LogicalRepTupleData *oldtup,
95  LogicalRepTupleData *newtup);
96 extern void logicalrep_write_delete(StringInfo out, Relation rel,
97  HeapTuple oldtuple);
99  LogicalRepTupleData *oldtup);
100 extern void logicalrep_write_truncate(StringInfo out, int nrelids, Oid relids[],
101  bool cascade, bool restart_seqs);
103  bool *cascade, bool *restart_seqs);
104 extern void logicalrep_write_rel(StringInfo out, Relation rel);
106 extern void logicalrep_write_typ(StringInfo out, Oid typoid);
107 extern void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp);
108 
109 #endif /* LOGICALREP_PROTO_H */
TransactionId xid
Definition: logicalproto.h:68
char * typname
Definition: logicalproto.h:60
void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple, HeapTuple newtuple)
Definition: proto.c:185
uint32 TransactionId
Definition: c.h:474
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
void logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
Definition: proto.c:75
int64 TimestampTz
Definition: timestamp.h:39
void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp)
Definition: proto.c:431
unsigned int Oid
Definition: postgres_ext.h:31
void logicalrep_write_rel(StringInfo out, Relation rel)
Definition: proto.c:354
void logicalrep_write_typ(StringInfo out, Oid typoid)
Definition: proto.c:404
Bitmapset * attkeys
Definition: logicalproto.h:52
LogicalRepRelId remoteid
Definition: logicalproto.h:45
struct LogicalRepCommitData LogicalRepCommitData
List * logicalrep_read_truncate(StringInfo in, bool *cascade, bool *restart_seqs)
Definition: proto.c:329
void logicalrep_write_origin(StringInfo out, const char *origin, XLogRecPtr origin_lsn)
Definition: proto.c:113
char * logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn)
Definition: proto.c:129
bool changed[MaxTupleAttributeNumber]
Definition: logicalproto.h:36
unsigned int uint32
Definition: c.h:325
LogicalRepRelation * logicalrep_read_rel(StringInfo in)
Definition: proto.c:379
struct LogicalRepTyp LogicalRepTyp
struct LogicalRepRelation LogicalRepRelation
XLogRecPtr final_lsn
Definition: logicalproto.h:66
void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn)
Definition: proto.c:46
LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup)
Definition: proto.c:163
struct LogicalRepTupleData LogicalRepTupleData
void logicalrep_write_truncate(StringInfo out, int nrelids, Oid relids[], bool cascade, bool restart_seqs)
Definition: proto.c:302
struct LogicalRepBeginData LogicalRepBeginData
void logicalrep_write_delete(StringInfo out, Relation rel, HeapTuple oldtuple)
Definition: proto.c:255
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void logicalrep_read_commit(StringInfo in, LogicalRepCommitData *commit_data)
Definition: proto.c:95
LogicalRepRelId logicalrep_read_update(StringInfo in, bool *has_oldtuple, LogicalRepTupleData *oldtup, LogicalRepTupleData *newtup)
Definition: proto.c:214
char * values[MaxTupleAttributeNumber]
Definition: logicalproto.h:34
void logicalrep_read_begin(StringInfo in, LogicalRepBeginData *begin_data)
Definition: proto.c:60
LogicalRepRelId logicalrep_read_delete(StringInfo in, LogicalRepTupleData *oldtup)
Definition: proto.c:280
TimestampTz committime
Definition: logicalproto.h:67
XLogRecPtr commit_lsn
Definition: logicalproto.h:73
Definition: pg_list.h:45
TimestampTz committime
Definition: logicalproto.h:75
char * nspname
Definition: logicalproto.h:59
uint32 LogicalRepRelId
Definition: logicalproto.h:39
void logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
Definition: proto.c:142