Wiki / Protocol Messages / Backend messages
CommandComplete
CommandComplete is a backend protocol message. Identifies the message as a command-completed response.
Reading PostgreSQL 18.6.
Description
CommandComplete is a backend protocol message. Identifies the message as a command-completed response.
- Direction
- Backend → frontend
- First wire field
- Byte1('C')
- Field entries
- 3
- Documented flow contexts
- Simple Query; Extended Query; COPY Operations
Usage
CommandComplete (B)Framing and repetition
The complete definition below retains repetition, counts and conditional fields. A numbered table row is a documented field definition, not a fixed byte offset. Integer encodings and flow rules follow the same-version protocol chapter.
Wire fields in documented order
| Position | Format | Meaning |
|---|---|---|
| 1 | Byte1('C') | Identifies the message as a command-completed response. |
| 2 | Int32 | Length of message contents in bytes, including self. |
| 3 | String | 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.) |
Manual definition
-
- Byte1('C')
-
Identifies the message as a command-completed response.
- Int32
-
Length of message contents in bytes, including self.
- String
-
The command tag. This is usually a single word that identifies which SQL command was completed.
For an
INSERTcommand, the tag isINSERT, whereoidrowsrowsis the number of rows inserted.oidused to be the object ID of the inserted row ifrowswas 1 and the target table had OIDs, but OIDs system columns are not supported anymore; thereforeoidis always 0.For a
DELETEcommand, the tag isDELETEwhererowsrowsis the number of rows deleted.For an
UPDATEcommand, the tag isUPDATEwhererowsrowsis the number of rows updated.For a
MERGEcommand, the tag isMERGEwhererowsrowsis the number of rows inserted, updated, or deleted.For a
SELECTorCREATE TABLE AScommand, the tag isSELECTwhererowsrowsis the number of rows retrieved.For a
MOVEcommand, the tag isMOVEwhererowsrowsis the number of rows the cursor's position has been changed by.For a
FETCHcommand, the tag isFETCHwhererowsrowsis the number of rows that have been retrieved from the cursor.For a
COPYcommand, the tag isCOPYwhererowsrowsis the number of rows copied. (Note: the row count appears only in PostgreSQL 8.2 and later.)
Related entries
Documentation and source
Source build
- Version
- 18.6
- Build
- https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
- Source fingerprint
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f
Compare versions
PostgreSQL 14 → 15: changed.
--- 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"
}
]
Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.
Related entries
Export JSON · Back to Protocol Messages · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.