mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
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
This commit is contained in:
@@ -33,6 +33,33 @@
|
||||
#define LOGICALREP_PROTO_STREAM_VERSION_NUM 2
|
||||
#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.
|
||||
|
||||
Reference in New Issue
Block a user