gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.8KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * logicalproto.h
  4. * logical replication protocol
  5. *
  6. * Copyright (c) 2015-2019, 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. #include "replication/reorderbuffer.h"
  16. #include "utils/rel.h"
  17. /*
  18. * Protocol capabilities
  19. *
  20. * LOGICAL_PROTO_VERSION_NUM is our native protocol and the greatest version
  21. * we can support. PGLOGICAL_PROTO_MIN_VERSION_NUM is the oldest version we
  22. * have backwards compatibility for. The client requests protocol version at
  23. * connect time.
  24. */
  25. #define LOGICALREP_PROTO_MIN_VERSION_NUM 1
  26. #define LOGICALREP_PROTO_VERSION_NUM 1
  27. /* Tuple coming via logical replication. */
  28. typedef struct LogicalRepTupleData
  29. {
  30. /* column values in text format, or NULL for a null value: */
  31. char *values[MaxTupleAttributeNumber];
  32. /* markers for changed/unchanged column values: */
  33. bool changed[MaxTupleAttributeNumber];
  34. } LogicalRepTupleData;
  35. typedef uint32 LogicalRepRelId;
  36. /* Relation information */
  37. typedef struct LogicalRepRelation
  38. {
  39. /* Info coming from the remote side. */
  40. LogicalRepRelId remoteid; /* unique id of the relation */
  41. char *nspname; /* schema name */
  42. char *relname; /* relation name */
  43. int natts; /* number of columns */
  44. char **attnames; /* column names */
  45. Oid *atttyps; /* column types */
  46. char replident; /* replica identity */
  47. Bitmapset *attkeys; /* Bitmap of key columns */
  48. } LogicalRepRelation;
  49. /* Type mapping info */
  50. typedef struct LogicalRepTyp
  51. {
  52. Oid remoteid; /* unique id of the remote type */
  53. char *nspname; /* schema name of remote type */
  54. char *typname; /* name of the remote type */
  55. } LogicalRepTyp;
  56. /* Transaction info */
  57. typedef struct LogicalRepBeginData
  58. {
  59. XLogRecPtr final_lsn;
  60. TimestampTz committime;
  61. TransactionId xid;
  62. } LogicalRepBeginData;
  63. typedef struct LogicalRepCommitData
  64. {
  65. XLogRecPtr commit_lsn;
  66. XLogRecPtr end_lsn;
  67. TimestampTz committime;
  68. } LogicalRepCommitData;
  69. extern void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn);
  70. extern void logicalrep_read_begin(StringInfo in,
  71. LogicalRepBeginData *begin_data);
  72. extern void logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn,
  73. XLogRecPtr commit_lsn);
  74. extern void logicalrep_read_commit(StringInfo in,
  75. LogicalRepCommitData *commit_data);
  76. extern void logicalrep_write_origin(StringInfo out, const char *origin,
  77. XLogRecPtr origin_lsn);
  78. extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn);
  79. extern void logicalrep_write_insert(StringInfo out, Relation rel,
  80. HeapTuple newtuple);
  81. extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup);
  82. extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
  83. HeapTuple newtuple);
  84. extern LogicalRepRelId logicalrep_read_update(StringInfo in,
  85. bool *has_oldtuple, LogicalRepTupleData *oldtup,
  86. LogicalRepTupleData *newtup);
  87. extern void logicalrep_write_delete(StringInfo out, Relation rel,
  88. HeapTuple oldtuple);
  89. extern LogicalRepRelId logicalrep_read_delete(StringInfo in,
  90. LogicalRepTupleData *oldtup);
  91. extern void logicalrep_write_truncate(StringInfo out, int nrelids, Oid relids[],
  92. bool cascade, bool restart_seqs);
  93. extern List *logicalrep_read_truncate(StringInfo in,
  94. bool *cascade, bool *restart_seqs);
  95. extern void logicalrep_write_rel(StringInfo out, Relation rel);
  96. extern LogicalRepRelation *logicalrep_read_rel(StringInfo in);
  97. extern void logicalrep_write_typ(StringInfo out, Oid typoid);
  98. extern void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp);
  99. #endif /* LOGICALREP_PROTO_H */
上海开阖软件有限公司 沪ICP备12045867号-1