This section describes the detailed format of each logical replication message. These messages are returned either by the replication slot SQL interface or are sent by a walsender. In case of a walsender they are encapsulated inside the replication protocol WAL messages as described in Section 53.4 and generally obey same message flow as physical replication.
Identifies the message as a begin message.
The final LSN of the transaction.
Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).
Xid of the transaction.
Identifies the message as a commit message.
Flags; currently unused (must be 0).
The LSN of the commit.
The end LSN of the transaction.
Commit timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).
Identifies the message as an origin message.
The LSN of the commit on the origin server.
Name of the origin.
Note that there can be multiple Origin messages inside a single transaction.
Identifies the message as a relation message.
ID of the relation.
Namespace (empty string for pg_catalog
).
Relation name.
Replica identity setting for the relation (same as
relreplident
in pg_class
).
Number of columns.
Next, the following message part appears for each column:
Flags for the column. Currently can be either 0 for no flags or 1 which marks the column as part of the key.
Name of the column.
ID of the column's data type.
Type modifier of the column (atttypmod
).
Identifies the message as a type message.
ID of the data type.
Namespace (empty string for pg_catalog
).
Name of the data type.
Identifies the message as an insert message.
ID of the relation corresponding to the ID in the relation message.
Identifies the following TupleData message as a new tuple.
TupleData message part representing the contents of new tuple.
Identifies the message as an update message.
ID of the relation corresponding to the ID in the relation message.
Identifies the following TupleData submessage as a key. This field is optional and is only present if the update changed data in any of the column(s) that are part of the REPLICA IDENTITY index.
Identifies the following TupleData submessage as an old tuple. This field is optional and is only present if table in which the update happened has REPLICA IDENTITY set to FULL.
TupleData message part representing the contents of the old tuple or primary key. Only present if the previous 'O' or 'K' part is present.
Identifies the following TupleData message as a new tuple.
TupleData message part representing the contents of a new tuple.
The Update message may contain either a 'K' message part or an 'O' message part or neither of them, but never both of them.
Identifies the message as a delete message.
ID of the relation corresponding to the ID in the relation message.
Identifies the following TupleData submessage as a key. This field is present if the table in which the delete has happened uses an index as REPLICA IDENTITY.
Identifies the following TupleData message as a old tuple. This field is present if the table in which the delete has happened has REPLICA IDENTITY set to FULL.
TupleData message part representing the contents of the old tuple or primary key, depending on the previous field.
The Delete message may contain either a 'K' message part or an 'O' message part, but never both of them.
Identifies the message as a truncate message.
Number of relations
Option bits for TRUNCATE
:
1 for CASCADE
, 2 for RESTART IDENTITY
ID of the relation corresponding to the ID in the relation message. This field is repeated for each relation.
The following message parts are shared by the above messages.
Number of columns.
Next, one of the following submessages appears for each column:
Identifies the data as NULL value.
Or
Identifies unchanged TOASTed value (the actual value is not sent).
Or
Identifies the data as text formatted value.
Length of the column value.
n
The value of the column, in text format. (A future release
might support additional formats.)
n
is the above length.