This section describes the detailed format of each message. Each can be sent by either a frontend (F), a backend (B), or both (F & B).
Identifies the message as an ASCII data row. (A prior RowDescription message defines the number of fields in the row and their data types.)
A bit map with one bit for each field in the row. The 1st field corresponds to bit 7 (MSB) of the 1st byte, the 2nd field corresponds to bit 6 of the 1st byte, the 8th field corresponds to bit 0 (LSB) of the 1st byte, the 9th field corresponds to bit 7 of the 2nd byte, and so on. Each bit is set if the value of the corresponding field is not NULL. If the number of fields is not a multiple of 8, the remainder of the last byte in the bit map is wasted.
Then, for each field with a non-NULL value, there is the following:
Specifies the size of the value of the field, including this size.
Specifies the value of the field itself in ASCII characters. n is the above size minus 4. There is no trailing zero-byte in the field data; the front end must add one if it wants one.
Identifies the message as an authentication request.
Specifies that the authentication was successful.
Identifies the message as an authentication request.
Specifies that Kerberos V4 authentication is required.
Identifies the message as an authentication request.
Specifies that Kerberos V5 authentication is required.
Identifies the message as an authentication request.
Specifies that a cleartext password is required.
Identifies the message as an authentication request.
Specifies that a crypt()-encrypted password is required.
The salt to use when encrypting the password.
Identifies the message as an authentication request.
Specifies that an MD5-encrypted password is required.
The salt to use when encrypting the password.
Identifies the message as an authentication request.
Specifies that an SCM credentials message is required.
Identifies the message as cancellation key data. The frontend must save these values if it wishes to be able to issue CancelRequest messages later.
The process ID of this backend.
The secret key of this backend.
Identifies the message as a binary data row. (A prior RowDescription message defines the number of fields in the row and their data types.)
A bit map with one bit for each field in the row. The 1st field corresponds to bit 7 (MSB) of the 1st byte, the 2nd field corresponds to bit 6 of the 1st byte, the 8th field corresponds to bit 0 (LSB) of the 1st byte, the 9th field corresponds to bit 7 of the 2nd byte, and so on. Each bit is set if the value of the corresponding field is not NULL. If the number of fields is not a multiple of 8, the remainder of the last byte in the bit map is wasted.
Then, for each field with a non-NULL value, there is the following:
Specifies the size of the value of the field, excluding this size.
Specifies the value of the field itself in binary format. n is the above size.
The size of the packet in bytes.
The cancel request code. The value is chosen to contain 1234 in the most significant 16 bits, and 5678 in the least 16 significant bits. (To avoid confusion, this code must not be the same as any protocol version number.)
The process ID of the target backend.
The secret key for the target backend.
Identifies the message as a completed response.
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, and oid is the object ID of the inserted row if rows is 1, otherwise oid is 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.
This is a stream of rows where each row is terminated by a Byte1('\n'). This is then followed by the sequence Byte1('\\'), Byte1('.'), Byte1('\n').
Identifies the message as a Start Copy In response. The frontend must now send a CopyDataRows message.
Identifies the message as a Start Copy Out response. This message will be followed by a CopyDataRows message.
Identifies the message as a cursor response.
The name of the cursor. This will be "blank" if the cursor is implicit.
Identifies the message as a response to an empty query string.
Unused.
Identifies the message as an error.
The error message itself.
Identifies the message as a function call.
Unused.
Specifies the object ID of the function to call.
Specifies the number of arguments being supplied to the function.
Then, for each argument, there is the following:
Specifies the size of the value of the argument, excluding this size.
Specifies the value of the field itself in binary format. n is the above size.
Identifies the message as a function call result.
Specifies that a nonempty result was returned.
Specifies the size of the value of the result, excluding this size.
Specifies the value of the result itself in binary format. n is the above size.
Unused. (Strictly speaking, FunctionResultResponse and FunctionVoidResponse are the same thing but with some optional parts to the message.)
Identifies the message as a function call result.
Specifies that an empty result was returned.
Identifies the message as a notice.
The notice message itself.
Identifies the message as a notification response.
The process ID of the notifying backend process.
The name of the condition that the notify has been raised on.
The size of the packet in bytes.
The password (encrypted, if requested).
Identifies the message as a query.
The query string itself.
Identifies the message type. ReadyForQuery is sent whenever the backend is ready for a new query cycle.
Identifies the message as a row description.
Specifies the number of fields in a row (may be zero).
Then, for each field, there is the following:
Specifies the field name.
Specifies the object ID of the field type.
Specifies the type size.
Specifies the type modifier.
The size of the packet in bytes.
The SSL request code. The value is chosen to contain 1234 in the most significant 16 bits, and 5679 in the least 16 significant bits. (To avoid confusion, this code must not be the same as any protocol version number.)
The size of the packet in bytes.
The protocol version number. The most significant 16 bits are the major version number. The least 16 significant bits are the minor version number.
The database name, defaults to the user name if empty.
The user name.
Any additional command line arguments to be passed to the backend child process by the server.
Unused.
The optional tty the backend should use for debugging messages. (Currently, this field is unsupported and ignored.)
Identifies the message as a termination.