diff options
author | Amit Kapila <akapila@postgresql.org> | 2020-11-02 08:18:18 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2020-11-02 08:18:18 +0530 |
commit | 644f0d7cc9c2cb270746f2024c706554e0fbec82 (patch) | |
tree | f92a2763d4fcb5e17a1706437bc264445cdad750 /src/include/replication/logicalproto.h | |
parent | a929e17e5a8c9b751b66002c8a89fdebdacfe194 (diff) | |
download | postgresql-644f0d7cc9c2cb270746f2024c706554e0fbec82.tar.gz postgresql-644f0d7cc9c2cb270746f2024c706554e0fbec82.zip |
Use Enum for top level logical replication message types.
Logical replication protocol uses a single byte character to identify a
message type in logical replication protocol. The code uses string
literals for the same. Use Enum so that
1. All the string literals used can be found at a single place. This
makes it easy to add more types without the risk of conflicts.
2. It's easy to locate the code handling a given message type.
3. When used with switch statements, it is easy to identify the missing
cases using -Wswitch.
Author: Ashutosh Bapat
Reviewed-by: Kyotaro Horiguchi, Andres Freund, Peter Smith and Amit Kapila
Discussion: https://postgr.es/m/CAExHW5uPzQ7L0oAd_ENyvaiYMOPgkrAoJpE+ZY5-obdcVT6NPg@mail.gmail.com
Diffstat (limited to 'src/include/replication/logicalproto.h')
-rw-r--r-- | src/include/replication/logicalproto.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h index 0c2cda264e1..cca13dae964 100644 --- a/src/include/replication/logicalproto.h +++ b/src/include/replication/logicalproto.h @@ -34,6 +34,33 @@ #define LOGICALREP_PROTO_MAX_VERSION_NUM LOGICALREP_PROTO_STREAM_VERSION_NUM /* + * Logical message types + * + * Used by logical replication wire protocol. + * + * Note: though this is an enum, the values are used to identify message types + * in logical replication protocol, which uses a single byte to identify a + * message type. Hence the values should be single byte wide and preferrably + * human readable characters. + */ +typedef enum LogicalRepMsgType +{ + LOGICAL_REP_MSG_BEGIN = 'B', + LOGICAL_REP_MSG_COMMIT = 'C', + LOGICAL_REP_MSG_ORIGIN = 'O', + LOGICAL_REP_MSG_INSERT = 'I', + LOGICAL_REP_MSG_UPDATE = 'U', + LOGICAL_REP_MSG_DELETE = 'D', + LOGICAL_REP_MSG_TRUNCATE = 'T', + LOGICAL_REP_MSG_RELATION = 'R', + LOGICAL_REP_MSG_TYPE = 'Y', + LOGICAL_REP_MSG_STREAM_START = 'S', + LOGICAL_REP_MSG_STREAM_END = 'E', + LOGICAL_REP_MSG_STREAM_COMMIT = 'c', + LOGICAL_REP_MSG_STREAM_ABORT = 'A' +} LogicalRepMsgType; + +/* * This struct stores a tuple received via logical replication. * Keep in mind that the columns correspond to the *remote* table. */ |