{"Entry":{"collection":"protocol","key":"logical-begin-prepare","name":"Begin Prepare (logical replication)","aliases":["Begin Prepare"],"metadata":{"aliases":["Begin Prepare"],"category":"Logical replication formats","content_hash":"f477550596cdfe70a3781e3e66179e4f7b58b6db6084b3775221e9ad1ee38f68","imported_at":"2026-09-30T00:40:44.607864+08:00","name":"Begin Prepare (logical replication)","name_zh":"","slug":"logical-begin-prepare","summary":"Logical replication Begin Prepare format. Identifies the message as the beginning of a prepared transaction message."}},"Definition":{"Collection":"protocol","Key":"logical-begin-prepare","SourceDatabase":"center","Version":"18","SourceTable":"protocol_message","SourceKey":"logical-begin-prepare","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"comparison_data":{"fields":[{"description":"Identifies the message as the beginning of a prepared transaction message.","format":"Byte1('b')"},{"description":"The LSN of the prepare.","format":"Int64 (XLogRecPtr)"},{"description":"The end LSN of the prepared transaction.","format":"Int64 (XLogRecPtr)"},{"description":"Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).","format":"Int64 (TimestampTz)"},{"description":"Xid of the transaction.","format":"Int32 (TransactionId)"},{"description":"The user defined GID of the prepared transaction.","format":"String"}],"layer":"logical replication"},"comparison_hash":"ebbadffad274f32ca3ebb47547183a539df75076cba41b6df18e3b0e4c152c22","description":["Logical replication Begin Prepare format. Identifies the message as the beginning of a prepared transaction message."],"facts":[{"label":"Layer","value":"Logical replication payload; distinct from the frontend/backend message envelope"},{"label":"First field","value":"Byte1('b')"}],"fields":[{"description":"Identifies the message as the beginning of a prepared transaction message.","format":"Byte1('b')"},{"description":"The LSN of the prepare.","format":"Int64 (XLogRecPtr)"},{"description":"The end LSN of the prepared transaction.","format":"Int64 (XLogRecPtr)"},{"description":"Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).","format":"Int64 (TimestampTz)"},{"description":"Xid of the transaction.","format":"Int32 (TransactionId)"},{"description":"The user defined GID of the prepared transaction.","format":"String"}],"manual_html":"\u003cdl\u003e\u003cdd\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eByte1('b')\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIdentifies the message as the beginning of a prepared transaction message.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe LSN of the prepare.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe end LSN of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (TimestampTz)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt32 (TransactionId)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eXid of the transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eString\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user defined GID of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e","manual_path":"/docs/18/protocol-logicalrep-message-formats.html","related":[{"label":"Streaming replication protocol","url":"/docs/18/protocol-replication.html"},{"label":"Logical Decoding Plugins","url":"/wiki/decode/?v=18"}],"release":{"channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[{"paragraphs":["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 Section 54.4 , and generally obey the same message flow as physical replication. The following messages (Stream Start, Stream Stop, Stream Commit, and Stream Abort) are available since protocol version 2. The following messages (Begin Prepare, Prepare, Commit Prepared, Rollback Prepared, Stream Prepare) are available since protocol version 3. The following message parts are shared by the above messages."],"title":"Protocol context"}],"signature":"Begin Prepare","sources":[{"label":"PostgreSQL 18 English manual","path":"protocol-logicalrep-message-formats.html","sha256":"e976b008206820fbeb1eba226e69bb7c00af157372c3545375d1b5053c76d0ad","url":"/docs/18/protocol-logicalrep-message-formats.html#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-BEGIN-PREPARE"}],"tables":[{"columns":[{"key":"c0","label":"Position"},{"key":"c1","label":"Format"},{"key":"c2","label":"Meaning"}],"key":"fields","rows":[{"c0":"1","c1":"Byte1('b')","c2":"Identifies the message as the beginning of a prepared transaction message."},{"c0":"2","c1":"Int64 (XLogRecPtr)","c2":"The LSN of the prepare."},{"c0":"3","c1":"Int64 (XLogRecPtr)","c2":"The end LSN of the prepared transaction."},{"c0":"4","c1":"Int64 (TimestampTz)","c2":"Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01)."},{"c0":"5","c1":"Int32 (TransactionId)","c2":"Xid of the transaction."},{"c0":"6","c1":"String","c2":"The user defined GID of the prepared transaction."}],"title":"Fields in documented order"}]},"ManualEvidence":{"manual_path":"/docs/18/protocol-logicalrep-message-formats.html","release":{"channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"PostgreSQL 18 English manual","path":"protocol-logicalrep-message-formats.html","sha256":"e976b008206820fbeb1eba226e69bb7c00af157372c3545375d1b5053c76d0ad","url":"/docs/18/protocol-logicalrep-message-formats.html#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-BEGIN-PREPARE"}]},"MeasuredEvidence":{}},"Text":{"Collection":"protocol","Key":"logical-begin-prepare","SourceDatabase":"center","Version":"18","Locale":"en","Title":"Begin Prepare (logical replication)","Summary":"Logical replication Begin Prepare format. Identifies the message as the beginning of a prepared transaction message.","BodyHTML":"\u003cdl\u003e\u003cdd\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003eByte1(\u0026#39;b\u0026#39;)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIdentifies the message as the beginning of a prepared transaction message.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe LSN of the prepare.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe end LSN of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003eInt64 (TimestampTz)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003eInt32 (TransactionId)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eXid of the transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003eString\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user defined GID of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"d15d379516b55dd2491dbe42cc796361514c5ee93dd20c1ef94730b455d00207","Payload":{"description":["Logical replication Begin Prepare format. Identifies the message as the beginning of a prepared transaction message."],"manual_html":"\u003cdl\u003e\u003cdd\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eByte1('b')\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIdentifies the message as the beginning of a prepared transaction message.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe LSN of the prepare.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (XLogRecPtr)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe end LSN of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt64 (TimestampTz)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eInt32 (TransactionId)\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eXid of the transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003eString\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe user defined GID of the prepared transaction.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e","related":[{"label":"Streaming replication protocol","url":"/docs/18/protocol-replication.html"},{"label":"Logical Decoding Plugins","url":"/wiki/decode/?v=18"}],"sections":[{"paragraphs":["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 Section 54.4 , and generally obey the same message flow as physical replication. The following messages (Stream Start, Stream Stop, Stream Commit, and Stream Abort) are available since protocol version 2. The following messages (Begin Prepare, Prepare, Commit Prepared, Rollback Prepared, Stream Prepare) are available since protocol version 3. The following message parts are shared by the above messages."],"title":"Protocol context"}],"tables":[{"columns":[{"key":"c0","label":"Position"},{"key":"c1","label":"Format"},{"key":"c2","label":"Meaning"}],"key":"fields","rows":[{"c0":"1","c1":"Byte1('b')","c2":"Identifies the message as the beginning of a prepared transaction message."},{"c0":"2","c1":"Int64 (XLogRecPtr)","c2":"The LSN of the prepare."},{"c0":"3","c1":"Int64 (XLogRecPtr)","c2":"The end LSN of the prepared transaction."},{"c0":"4","c1":"Int64 (TimestampTz)","c2":"Prepare timestamp of the transaction. The value is in number of microseconds since PostgreSQL epoch (2000-01-01)."},{"c0":"5","c1":"Int32 (TransactionId)","c2":"Xid of the transaction."},{"c0":"6","c1":"String","c2":"The user defined GID of the prepared transaction."}],"title":"Fields in documented order"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
