PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
logicalproto.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * logicalproto.h
4  * logical replication protocol
5  *
6  * Copyright (c) 2015, 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  char *values[MaxTupleAttributeNumber]; /* value in out function format or NULL if values is NULL */
34  bool changed[MaxTupleAttributeNumber]; /* marker for changed/unchanged values */
36 
38 
39 /* Relation information */
40 typedef struct LogicalRepRelation
41 {
42  /* Info coming from the remote side. */
43  LogicalRepRelId remoteid; /* unique id of the relation */
44  char *nspname; /* schema name */
45  char *relname; /* relation name */
46  int natts; /* number of columns */
47  char **attnames; /* column names */
48  Oid *atttyps; /* column types */
49  char replident; /* replica identity */
50  Bitmapset *attkeys; /* Bitmap of key columns */
52 
53 /* Type mapping info */
54 typedef struct LogicalRepTyp
55 {
56  Oid remoteid; /* unique id of the type */
57  char *nspname; /* schema name */
58  char *typname; /* name of the type */
59  Oid typoid; /* local type Oid */
61 
62 /* Transaction info */
63 typedef struct LogicalRepBeginData
64 {
69 
70 typedef struct LogicalRepCommitData
71 {
76 
78 extern void logicalrep_read_begin(StringInfo in,
79  LogicalRepBeginData *begin_data);
81  XLogRecPtr commit_lsn);
82 extern void logicalrep_read_commit(StringInfo in,
83  LogicalRepCommitData *commit_data);
84 extern void logicalrep_write_origin(StringInfo out, const char *origin,
85  XLogRecPtr origin_lsn);
86 extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn);
87 extern void logicalrep_write_insert(StringInfo out, Relation rel,
88  HeapTuple newtuple);
90 extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
91  HeapTuple newtuple);
93  bool *has_oldtuple, LogicalRepTupleData *oldtup,
94  LogicalRepTupleData *newtup);
95 extern void logicalrep_write_delete(StringInfo out, Relation rel,
96  HeapTuple oldtuple);
98  LogicalRepTupleData *oldtup);
99 extern void logicalrep_write_rel(StringInfo out, Relation rel);
101 extern void logicalrep_write_typ(StringInfo out, Oid typoid);
102 extern void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp);
103 
104 #endif /* LOGICALREP_PROTO_H */
TransactionId xid
Definition: logicalproto.h:67
char * typname
Definition: logicalproto.h:58
void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple, HeapTuple newtuple)
Definition: proto.c:182
uint32 TransactionId
Definition: c.h:394
#define MaxTupleAttributeNumber
Definition: htup_details.h:33
void logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
Definition: proto.c:72
int64 TimestampTz
Definition: timestamp.h:39
void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp)
Definition: proto.c:376
unsigned int Oid
Definition: postgres_ext.h:31
void logicalrep_write_rel(StringInfo out, Relation rel)
Definition: proto.c:299
void logicalrep_write_typ(StringInfo out, Oid typoid)
Definition: proto.c:349
Bitmapset * attkeys
Definition: logicalproto.h:50
LogicalRepRelId remoteid
Definition: logicalproto.h:43
struct LogicalRepCommitData LogicalRepCommitData
void logicalrep_write_origin(StringInfo out, const char *origin, XLogRecPtr origin_lsn)
Definition: proto.c:110
char * logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn)
Definition: proto.c:126
bool changed[MaxTupleAttributeNumber]
Definition: logicalproto.h:34
unsigned int uint32
Definition: c.h:265
LogicalRepRelation * logicalrep_read_rel(StringInfo in)
Definition: proto.c:324
struct LogicalRepTyp LogicalRepTyp
struct LogicalRepRelation LogicalRepRelation
XLogRecPtr final_lsn
Definition: logicalproto.h:65
void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn)
Definition: proto.c:43
LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup)
Definition: proto.c:160
struct LogicalRepTupleData LogicalRepTupleData
struct LogicalRepBeginData LogicalRepBeginData
void logicalrep_write_delete(StringInfo out, Relation rel, HeapTuple oldtuple)
Definition: proto.c:252
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void logicalrep_read_commit(StringInfo in, LogicalRepCommitData *commit_data)
Definition: proto.c:92
LogicalRepRelId logicalrep_read_update(StringInfo in, bool *has_oldtuple, LogicalRepTupleData *oldtup, LogicalRepTupleData *newtup)
Definition: proto.c:211
char * values[MaxTupleAttributeNumber]
Definition: logicalproto.h:33
void logicalrep_read_begin(StringInfo in, LogicalRepBeginData *begin_data)
Definition: proto.c:57
LogicalRepRelId logicalrep_read_delete(StringInfo in, LogicalRepTupleData *oldtup)
Definition: proto.c:277
TimestampTz committime
Definition: logicalproto.h:66
XLogRecPtr commit_lsn
Definition: logicalproto.h:72
TimestampTz committime
Definition: logicalproto.h:74
char * nspname
Definition: logicalproto.h:57
uint32 LogicalRepRelId
Definition: logicalproto.h:37
void logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
Definition: proto.c:139