| Server IP : 172.67.134.114 / Your IP : 162.159.115.42 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-docs/html/ |
Upload File : |
<?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>52.9. Logical Replication Message Formats</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="[email protected]" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="protocol-error-fields.html" title="52.8. Error and Notice Message Fields" /><link rel="next" href="protocol-changes.html" title="52.10. Summary of Changes since Protocol 2.0" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.9. Logical Replication Message Formats</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="protocol-error-fields.html" title="52.8. Error and Notice Message Fields">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Up</a></td><th width="60%" align="center">Chapter 52. Frontend/Backend Protocol</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="protocol-changes.html" title="52.10. Summary of Changes since Protocol 2.0">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.9. Logical Replication Message Formats</h2></div></div></div><p>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 <a class="xref" href="protocol-replication.html" title="52.4. Streaming Replication Protocol">Section 52.4</a>
and generally obey same message flow as physical replication.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">Begin</span></dt><dd><p>
</p><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</span></dt><dd><p> The final LSN of the transaction.</p></dd><dt><span class="term"> Int64</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</span></dt><dd><p> Xid of the transaction.</p></dd></dl></div></dd><dt><span class="term">Commit</span></dt><dd><p>
</p><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</span></dt><dd><p> Flags; currently unused (must be 0).</p></dd><dt><span class="term"> Int64</span></dt><dd><p> The LSN of the commit.</p></dd><dt><span class="term"> Int64</span></dt><dd><p> The end LSN of the transaction.</p></dd><dt><span class="term"> Int64</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><span class="term">Origin</span></dt><dd><p>
</p><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</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><span class="term">Relation</span></dt><dd><p>
</p><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</span></dt><dd><p> ID 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:
</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</span></dt><dd><p> ID 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><span class="term">Type</span></dt><dd><p>
</p><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</span></dt><dd><p> ID 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><span class="term">Insert</span></dt><dd><p>
</p><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</span></dt><dd><p> ID 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><span class="term">Update</span></dt><dd><p>
</p><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</span></dt><dd><p> ID 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><span class="term">Delete</span></dt><dd><p>
</p><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</span></dt><dd><p> ID 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></dl></div><p>
The following message parts are shared by the above messages.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">TupleData</span></dt><dd><p>
</p><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:
</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><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, in text format. (A future release
might support additional formats.)
<em class="replaceable"><code>n</code></em> is the above length.
</p></dd></dl></div></dd></dl></div></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="protocol-error-fields.html" title="52.8. Error and Notice Message Fields">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="protocol-changes.html" title="52.10. Summary of Changes since Protocol 2.0">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.8. Error and Notice Message Fields </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 52.10. Summary of Changes since Protocol 2.0</td></tr></table></div></body></html>