CommandComplete
CommandComplete 是后端协议消息,表示命令执行完成。
当前查看 PostgreSQL 18.6。
说明
CommandComplete 是后端协议消息,表示命令执行完成。
- 方向
- 后端 → 前端
- 首个线上协议字段
- Byte1('C')
- 字段条目
- 3
- 手册中的交互阶段
- 简单查询;扩展查询;COPY 操作
用法
CommandComplete (B)消息边界与重复字段
下方完整定义保留重复项、计数与条件字段。表格行号表示文档中的字段定义,并非固定字节偏移量。整数编码与交互流程以同版本协议章节为准。
按手册顺序排列的线上协议字段
| 位置 | 格式 | 含义 |
|---|---|---|
| 1 | Byte1('C') | 将该消息标识为命令完成响应。 |
| 2 | Int32 | 消息内容的长度(以字节为单位),包括其自身。 |
| 3 | 字符串 | 命令标签,通常是标识已完成 SQL 命令的一个单词。对于 INSERT,标签为 INSERT oid rows,rows 是插入行数。oid 过去在 rows 为 1 且目标表具有 OID 时表示所插入行的对象 ID;由于 OID 系统列已不再受支持,oid 始终为 0。对于 DELETE,标签为 DELETE rows,rows 是删除行数。对于 UPDATE,标签为 UPDATE rows,rows 是更新行数。对于 MERGE,标签为 MERGE rows,rows 是插入、更新或删除的行数。对于 SELECT 或 CREATE TABLE AS,标签为 SELECT rows,rows 是检索行数。对于 MOVE,标签为 MOVE rows,rows 是游标位置移动的行数。对于 FETCH,标签为 FETCH rows,rows 是从游标检索的行数。对于 COPY,标签为 COPY rows,rows 是复制行数;行数仅在 PostgreSQL 8.2 及以后版本中出现。 |
手册定义
-
- Byte1('C')
-
将该消息标识为命令完成响应。
- Int32
-
消息内容的长度(以字节为单位),包括其自身。
- 字符串
-
命令标签。通常是一个单词,用来标识已完成的 SQL 命令。
INSERT 命令的标记为 INSERT oid rows,其中 rows 为插入行数。过去,若 rows 为 1 且目标表具有 OID,oid 表示插入行的对象 ID;但现在已不再支持 OID 系统列,因此 oid 始终为 0。
对于
DELETE命令,标签是DELETE,其中rowsrows表示删除的行数。对于
UPDATE命令,标签是UPDATE,其中rowsrows是更新的行数。对于
MERGE命令,标签是MERGE,其中rowsrows是插入、更新或删除的行数。对于
SELECT或CREATE TABLE AS命令,标签是SELECT,其中rowsrows是检索到的行数。对于
MOVE命令,标签是MOVE,其中rowsrows表示游标位置改变的行数。对于
FETCH命令,标签是FETCH,其中rowsrows是从游标中检索出的行数。对于
COPY命令,标签为COPY,其中rowsrows是复制的行数。(注意:行数仅出现在 PostgreSQL 8.2 及更高版本中。)
相关条目
文档与源码
来源构建
- 版本
- 18.6
- 构建
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- 来源指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f
版本比较
PostgreSQL 14 → 15: 属性变化。
以下差异保留原始字段名与英文源描述。
--- PostgreSQL 14
+++ PostgreSQL 15
@@ -10,7 +10,7 @@
"format": "Int32"
},
{
- "description": "The command tag. This is usually a single word that identifies which SQL command was completed. For an INSERT command, the tag is INSERT oid rows , where rows is the number of rows inserted. oid used to be the object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; therefore oid is always 0. For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted. For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated. For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved. For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by. For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor. For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)",
+ "description": "The command tag. This is usually a single word that identifies which SQL command was completed. For an INSERT command, the tag is INSERT oid rows , where rows is the number of rows inserted. oid used to be the object ID of the inserted row if rows was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; therefore oid is always 0. For a DELETE command, the tag is DELETE rows where rows is the number of rows deleted. For an UPDATE command, the tag is UPDATE rows where rows is the number of rows updated. For a MERGE command, the tag is MERGE rows where rows is the number of rows inserted, updated, or deleted. For a SELECT or CREATE TABLE AS command, the tag is SELECT rows where rows is the number of rows retrieved. For a MOVE command, the tag is MOVE rows where rows is the number of rows the cursor's position has been changed by. For a FETCH command, the tag is FETCH rows where rows is the number of rows that have been retrieved from the cursor. For a COPY command, the tag is COPY rows where rows is the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)",
"format": "String"
}
]
比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。
相关条目
导出 JSON · 返回协议消息 · 收录范围为 PostgreSQL 10 至 20;最早采样版本不一定是实际引入版本。