diff options
Diffstat (limited to 'doc/src/sgml/html/protocol-logicalrep-message-formats.html')
-rw-r--r-- | doc/src/sgml/html/protocol-logicalrep-message-formats.html | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/doc/src/sgml/html/protocol-logicalrep-message-formats.html b/doc/src/sgml/html/protocol-logicalrep-message-formats.html new file mode 100644 index 0000000..ea3a293 --- /dev/null +++ b/doc/src/sgml/html/protocol-logicalrep-message-formats.html @@ -0,0 +1,307 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>55.9. Logical Replication Message Formats</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="protocol-error-fields.html" title="55.8. Error and Notice Message Fields" /><link rel="next" href="protocol-changes.html" title="55.10. Summary of Changes since Protocol 2.0" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">55.9. Logical Replication Message Formats</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="protocol-error-fields.html" title="55.8. Error and Notice Message Fields">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="protocol.html" title="Chapter 55. Frontend/Backend Protocol">Up</a></td><th width="60%" align="center">Chapter 55. Frontend/Backend Protocol</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="protocol-changes.html" title="55.10. Summary of Changes since Protocol 2.0">Next</a></td></tr></table><hr /></div><div class="sect1" id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">55.9. Logical Replication Message Formats</h2></div></div></div><p> + This section describes the detailed format of each logical replication + message. These messages are either returned by the replication slot SQL + interface or are sent by a walsender. In the case of a walsender, they are + encapsulated inside replication protocol WAL messages as described in + <a class="xref" href="protocol-replication.html" title="55.4. Streaming Replication Protocol">Section 55.4</a>, and generally obey the same message + flow as physical replication. + </p><div class="variablelist"><dl class="variablelist"><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-BEGIN"><span class="term">Begin</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('B')</span></dt><dd><p> + Identifies the message as a begin message. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The final LSN of the transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Commit timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-MESSAGE"><span class="term">Message</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('M')</span></dt><dd><p> + Identifies the message as a logical decoding message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int8</span></dt><dd><p> + Flags; Either 0 for no flags or 1 if the logical decoding + message is transactional. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the logical decoding message. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The prefix of the logical decoding message. + </p></dd><dt><span class="term">Int32</span></dt><dd><p> + Length of the content. + </p></dd><dt><span class="term">Byte<em class="replaceable"><code>n</code></em></span></dt><dd><p> + The content of the logical decoding message. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-COMMIT"><span class="term">Commit</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('C')</span></dt><dd><p> + Identifies the message as a commit message. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the commit. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Commit timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-ORIGIN"><span class="term">Origin</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('O')</span></dt><dd><p> + Identifies the message as an origin message. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the commit on the origin server. + </p></dd><dt><span class="term">String</span></dt><dd><p> + Name of the origin. + </p></dd></dl></div><p> + Note that there can be multiple Origin messages inside a single transaction. + </p></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-RELATION"><span class="term">Relation</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('R')</span></dt><dd><p> + Identifies the message as a relation message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the relation. + </p></dd><dt><span class="term">String</span></dt><dd><p> + Namespace (empty string for <code class="literal">pg_catalog</code>). + </p></dd><dt><span class="term">String</span></dt><dd><p> + Relation name. + </p></dd><dt><span class="term">Int8</span></dt><dd><p> + Replica identity setting for the relation (same as + <code class="structfield">relreplident</code> in <code class="structname">pg_class</code>). + </p></dd><dt><span class="term">Int16</span></dt><dd><p> + Number of columns. + </p></dd></dl></div><p> + Next, the following message part appears for each column included in + the publication (except generated columns): + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Int8</span></dt><dd><p> + Flags for the column. Currently can be either 0 for no flags + or 1 which marks the column as part of the key. + </p></dd><dt><span class="term">String</span></dt><dd><p> + Name of the column. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the column's data type. + </p></dd><dt><span class="term">Int32</span></dt><dd><p> + Type modifier of the column (<code class="structfield">atttypmod</code>). + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-TYPE"><span class="term">Type</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('Y')</span></dt><dd><p> + Identifies the message as a type message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the data type. + </p></dd><dt><span class="term">String</span></dt><dd><p> + Namespace (empty string for <code class="literal">pg_catalog</code>). + </p></dd><dt><span class="term">String</span></dt><dd><p> + Name of the data type. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT"><span class="term">Insert</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('I')</span></dt><dd><p> + Identifies the message as an insert message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the relation corresponding to the ID in the relation + message. + </p></dd><dt><span class="term">Byte1('N')</span></dt><dd><p> + Identifies the following TupleData message as a new tuple. + </p></dd><dt><span class="term">TupleData</span></dt><dd><p> + TupleData message part representing the contents of new tuple. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-UPDATE"><span class="term">Update</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('U')</span></dt><dd><p> + Identifies the message as an update message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the relation corresponding to the ID in the relation + message. + </p></dd><dt><span class="term">Byte1('K')</span></dt><dd><p> + 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. + </p></dd><dt><span class="term">Byte1('O')</span></dt><dd><p> + 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. + </p></dd><dt><span class="term">TupleData</span></dt><dd><p> + TupleData message part representing the contents of the old tuple + or primary key. Only present if the previous 'O' or 'K' part + is present. + </p></dd><dt><span class="term">Byte1('N')</span></dt><dd><p> + Identifies the following TupleData message as a new tuple. + </p></dd><dt><span class="term">TupleData</span></dt><dd><p> + TupleData message part representing the contents of a new tuple. + </p></dd></dl></div><p> + The Update message may contain either a 'K' message part or an 'O' message part + or neither of them, but never both of them. + </p></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-DELETE"><span class="term">Delete</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('D')</span></dt><dd><p> + Identifies the message as a delete message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the relation corresponding to the ID in the relation + message. + </p></dd><dt><span class="term">Byte1('K')</span></dt><dd><p> + 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. + </p></dd><dt><span class="term">Byte1('O')</span></dt><dd><p> + Identifies the following TupleData message as an old tuple. + This field is present if the table in which the delete + happened has REPLICA IDENTITY set to FULL. + </p></dd><dt><span class="term">TupleData</span></dt><dd><p> + TupleData message part representing the contents of the old tuple + or primary key, depending on the previous field. + </p></dd></dl></div><p> + The Delete message may contain either a 'K' message part or an 'O' message part, + but never both of them. + </p></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-TRUNCATE"><span class="term">Truncate</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('T')</span></dt><dd><p> + Identifies the message as a truncate message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction (only present for streamed transactions). + This field is available since protocol version 2. + </p></dd><dt><span class="term">Int32</span></dt><dd><p> + Number of relations + </p></dd><dt><span class="term">Int8</span></dt><dd><p> + Option bits for <code class="command">TRUNCATE</code>: + 1 for <code class="literal">CASCADE</code>, 2 for <code class="literal">RESTART IDENTITY</code> + </p></dd><dt><span class="term">Int32 (Oid)</span></dt><dd><p> + OID of the relation corresponding to the ID in the relation + message. This field is repeated for each relation. + </p></dd></dl></div></dd></dl></div><p> + The following messages (Stream Start, Stream Stop, Stream Commit, and + Stream Abort) are available since protocol version 2. + </p><div class="variablelist"><dl class="variablelist"><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-STREAM-START"><span class="term">Stream Start</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('S')</span></dt><dd><p> + Identifies the message as a stream start message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">Int8</span></dt><dd><p> + A value of 1 indicates this is the first stream segment for + this XID, 0 for any other stream segment. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-STREAM-STOP"><span class="term">Stream Stop</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('E')</span></dt><dd><p> + Identifies the message as a stream stop message. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-STREAM-COMMIT"><span class="term">Stream Commit</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('c')</span></dt><dd><p> + Identifies the message as a stream commit message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the commit. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Commit timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-STREAM-ABORT"><span class="term">Stream Abort</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('A')</span></dt><dd><p> + Identifies the message as a stream abort message. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the subtransaction (will be same as xid of the transaction for top-level + transactions). + </p></dd></dl></div></dd></dl></div><p> + The following messages (Begin Prepare, Prepare, Commit Prepared, Rollback Prepared, Stream Prepare) + are available since protocol version 3. + </p><div class="variablelist"><dl class="variablelist"><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-BEGIN-PREPARE"><span class="term">Begin Prepare</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('b')</span></dt><dd><p> + Identifies the message as the beginning of a prepared transaction message. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the prepare. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the prepared transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Prepare timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The user defined GID of the prepared transaction. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-PREPARE"><span class="term">Prepare</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('P')</span></dt><dd><p> + Identifies the message as a prepared transaction message. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the prepare. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the prepared transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Prepare timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The user defined GID of the prepared transaction. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-COMMIT-PREPARED"><span class="term">Commit Prepared</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('K')</span></dt><dd><p> + Identifies the message as the commit of a prepared transaction message. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the commit of the prepared transaction. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the commit of the prepared transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Commit timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The user defined GID of the prepared transaction. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-ROLLBACK-PREPARED"><span class="term">Rollback Prepared</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('r')</span></dt><dd><p> + Identifies the message as the rollback of a prepared transaction message. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the prepared transaction. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the rollback of the prepared transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Prepare timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Rollback timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The user defined GID of the prepared transaction. + </p></dd></dl></div></dd><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-STREAM-PREPARE"><span class="term">Stream Prepare</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('p')</span></dt><dd><p> + Identifies the message as a stream prepared transaction message. + </p></dd><dt><span class="term">Int8(0)</span></dt><dd><p> + Flags; currently unused. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The LSN of the prepare. + </p></dd><dt><span class="term">Int64 (XLogRecPtr)</span></dt><dd><p> + The end LSN of the prepared transaction. + </p></dd><dt><span class="term">Int64 (TimestampTz)</span></dt><dd><p> + Prepare timestamp of the transaction. The value is in number + of microseconds since PostgreSQL epoch (2000-01-01). + </p></dd><dt><span class="term">Int32 (TransactionId)</span></dt><dd><p> + Xid of the transaction. + </p></dd><dt><span class="term">String</span></dt><dd><p> + The user defined GID of the prepared transaction. + </p></dd></dl></div></dd></dl></div><p> + The following message parts are shared by the above messages. + </p><div class="variablelist"><dl class="variablelist"><dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-TUPLEDATA"><span class="term">TupleData</span></dt><dd><div class="variablelist"><dl class="variablelist"><dt><span class="term">Int16</span></dt><dd><p> + Number of columns. + </p></dd></dl></div><p> + Next, one of the following submessages appears for each column (except generated columns): + + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('n')</span></dt><dd><p> + Identifies the data as NULL value. + </p></dd></dl></div><p> + Or + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('u')</span></dt><dd><p> + Identifies unchanged TOASTed value (the actual value is not + sent). + </p></dd></dl></div><p> + Or + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('t')</span></dt><dd><p> + Identifies the data as text formatted value. + </p></dd></dl></div><p> + Or + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Byte1('b')</span></dt><dd><p> + Identifies the data as binary formatted value. + </p></dd><dt><span class="term">Int32</span></dt><dd><p> + Length of the column value. + </p></dd><dt><span class="term">Byte<em class="replaceable"><code>n</code></em></span></dt><dd><p> + The value of the column, either in binary or in text format. + (As specified in the preceding format byte). + <em class="replaceable"><code>n</code></em> is the above length. + </p></dd></dl></div><p> + </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="protocol-error-fields.html" title="55.8. Error and Notice Message Fields">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="protocol.html" title="Chapter 55. Frontend/Backend Protocol">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="protocol-changes.html" title="55.10. Summary of Changes since Protocol 2.0">Next</a></td></tr><tr><td width="40%" align="left" valign="top">55.8. Error and Notice Message Fields </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 55.10. Summary of Changes since Protocol 2.0</td></tr></table></div></body></html>
\ No newline at end of file |