Delete (logical replication)
逻辑复制 Delete 格式,表示删除消息。
当前查看 PostgreSQL 18.6。
说明
逻辑复制 Delete 格式,表示删除消息。
- 层次
- 逻辑复制载荷,与前后端消息封装分开。
- 首个字段
- Byte1('D')
用法
Delete协议上下文
本节说明各逻辑复制消息的详细格式。这些消息由复制槽 SQL 接口返回,或由 walsender 发送。由 walsender 发送时,它们被封装在复制协议的 WAL 消息中(参见第 54.4 节),消息流程通常与物理复制相同。Stream Start、Stream Stop、Stream Commit 和 Stream Abort 从协议版本 2 起可用。Begin Prepare、Prepare、Commit Prepared、Rollback Prepared 和 Stream Prepare 从协议版本 3 起可用。以下消息部分为上述消息所共用。
按手册顺序排列的字段
| 位置 | 格式 | 含义 |
|---|---|---|
| 1 | Byte1('D') | 将该消息标识为 Delete 消息。 |
| 2 | Int32 (TransactionId) | 事务的 XID,仅在流式传输事务中出现。此字段从协议版本 2 起可用。 |
| 3 | Int32 (Oid) | 关系的 OID,与 Relation 消息中的 ID 对应。 |
| 4 | Byte1('K') | 将后续 TupleData 子消息标识为键。如果发生删除的表使用索引作为 REPLICA IDENTITY,则出现此字段。 |
| 5 | Byte1('O') | 将后续 TupleData 消息标识为旧元组。如果发生删除的表将 REPLICA IDENTITY 设为 FULL,则出现此字段。 |
| 6 | TupleData | 表示旧元组或主键内容的 TupleData 消息部分,具体取决于前一个字段。 |
手册定义
-
- Byte1('D')
-
将该消息标识为 Delete 消息。
- Int32 (TransactionId)
-
事务的 XID,仅在流式传输事务中出现。此字段从协议版本 2 起可用。
- Int32 (Oid)
-
关系的 OID,与 Relation 消息中的 ID 对应。
- Byte1('K')
-
将后续 TupleData 子消息标识为键。如果发生删除的表使用索引作为 REPLICA IDENTITY,则出现此字段。
- Byte1('O')
-
将后续 TupleData 消息标识为旧元组。如果发生删除的表将 REPLICA IDENTITY 设为 FULL,则出现此字段。
- TupleData
-
表示旧元组或主键内容的 TupleData 消息部分,具体取决于前一个字段。
Delete 消息可以包含 'K' 消息部分或 'O' 消息部分,但绝不会同时包含两者。
相关条目
文档与源码
来源构建
- 版本
- 18.6
- 构建
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- 来源指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f
版本比较
PostgreSQL 14 → 15: 属性变化。
以下差异保留原始字段名与英文源描述。
--- PostgreSQL 14
+++ PostgreSQL 15
@@ -6,11 +6,11 @@
},
{
"description": "Xid of the transaction (only present for streamed transactions). This field is available since protocol version 2.",
- "format": "Int32"
+ "format": "Int32 (TransactionId)"
},
{
- "description": "ID of the relation corresponding to the ID in the relation message.",
- "format": "Int32"
+ "description": "OID of the relation corresponding to the ID in the relation message.",
+ "format": "Int32 (Oid)"
},
{
"description": "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.",
比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。
相关条目
Begin (logical replication)Begin Prepare (logical replication)Commit (logical replication)Commit Prepared (logical replication)Insert (logical replication)Message (logical replication)Origin (logical replication)Prepare (logical replication)Relation (logical replication)Rollback Prepared (logical replication)Stream Abort (logical replication)Stream Commit (logical replication)
导出 JSON · 返回协议消息 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。