YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/postgres/src/include/replication/logicalproto.h
Line
Count
Source (jump to first uncovered line)
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
16
#include "replication/reorderbuffer.h"
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
0
#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: */
34
  char     *values[MaxTupleAttributeNumber];
35
  /* markers for changed/unchanged column values: */
36
  bool    changed[MaxTupleAttributeNumber];
37
} LogicalRepTupleData;
38
39
typedef uint32 LogicalRepRelId;
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 */
53
} LogicalRepRelation;
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 */
61
} LogicalRepTyp;
62
63
/* Transaction info */
64
typedef struct LogicalRepBeginData
65
{
66
  XLogRecPtr  final_lsn;
67
  TimestampTz committime;
68
  TransactionId xid;
69
} LogicalRepBeginData;
70
71
typedef struct LogicalRepCommitData
72
{
73
  XLogRecPtr  commit_lsn;
74
  XLogRecPtr  end_lsn;
75
  TimestampTz committime;
76
} LogicalRepCommitData;
77
78
extern void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn);
79
extern void logicalrep_read_begin(StringInfo in,
80
            LogicalRepBeginData *begin_data);
81
extern void logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn,
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);
90
extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup);
91
extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
92
            HeapTuple newtuple);
93
extern LogicalRepRelId logicalrep_read_update(StringInfo in,
94
             bool *has_oldtuple, LogicalRepTupleData *oldtup,
95
             LogicalRepTupleData *newtup);
96
extern void logicalrep_write_delete(StringInfo out, Relation rel,
97
            HeapTuple oldtuple);
98
extern LogicalRepRelId logicalrep_read_delete(StringInfo in,
99
             LogicalRepTupleData *oldtup);
100
extern void logicalrep_write_truncate(StringInfo out, int nrelids, Oid relids[],
101
              bool cascade, bool restart_seqs);
102
extern List *logicalrep_read_truncate(StringInfo in,
103
             bool *cascade, bool *restart_seqs);
104
extern void logicalrep_write_rel(StringInfo out, Relation rel);
105
extern LogicalRepRelation *logicalrep_read_rel(StringInfo in);
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 */