Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
adf1c52c
Commit
adf1c52c
authored
Jun 22, 2001
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates for new startup sequence, some reformatting
parent
9e39ffe4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
807 additions
and
824 deletions
+807
-824
doc/src/sgml/protocol.sgml
doc/src/sgml/protocol.sgml
+807
-824
No files found.
doc/src/sgml/protocol.sgml
View file @
adf1c52c
<Chapter Id="protocol">
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.18 2001/06/22 23:27:48 petere Exp $ -->
<DocInfo>
<Author>
<chapter id="protocol">
<FirstName>Phil</FirstName>
<title>Frontend/Backend Protocol</title>
<Surname>Thompson</Surname>
</Author>
<note>
<Date>1998-08-08</Date>
<para>
</DocInfo>
Written by Phil Thompson (<email>phil@river-bank.demon.co.uk</email>).
<Title>Frontend/Backend Protocol</Title>
Updates for protocol 2.0 by Tom Lane (<email>tgl@sss.pgh.pa.us</email>).
</para>
<Para>
</note>
<Note>
<Para>
<para>
Written by Phil Thompson (<email>phil@river-bank.demon.co.uk</email>).
<application>PostgreSQL</application> uses a message-based protocol
Updates for protocol 2.0 by Tom Lane (<email>tgl@sss.pgh.pa.us</email>).
for communication between frontends and backends. The protocol is
</Para>
implemented over <acronym>TCP/IP</acronym> and also on Unix domain
</Note>
sockets. <productname>PostgreSQL</productname> 6.3 introduced
</para>
version numbers into the protocol. This was done in such a way as
to still allow connections from earlier versions of frontends, but
<Para>
this document does not cover the protocol used by those earlier
<ProductName>Postgres</ProductName> uses a message-based protocol for communication between frontends
versions.
and backends. The protocol is implemented over <Acronym>TCP/IP</Acronym> and also on Unix sockets.
</para>
<ProductName>Postgres</ProductName> 6.3 introduced version numbers into the protocol.
This was done in such
<para>
a way as to still allow connections from earlier versions of frontends, but
This document describes version 2.0 of the protocol, implemented in
this document does not cover the protocol used by those earlier versions.
<application>PostgreSQL</application> 6.4 and later.
</para>
</para>
<Para>
<para>
This document describes version 2.0 of the protocol, implemented in
Higher level features built on this protocol (for example, how
<ProductName>Postgres</ProductName> 6.4 and later.
<application>libpq</application> passes certain environment
</para>
variables after the connection is established) are covered
elsewhere.
<Para>
</para>
Higher level features built on this protocol (for example, how <FileName>libpq</FileName> passes
certain environment variables after the connection is established)
<sect1 id="protocol-overview">
are covered elsewhere.
<title>Overview</title>
</para>
<para>
<Sect1 id="protocol-overview">
A frontend opens a connection to the server and sends a start-up
<Title>Overview</Title>
packet. This includes the names of the user and the database the
user wants to connect to. The server then uses this, and the
<Para>
information in the <filename>pg_hba.conf</filename> file to
The three major components are the frontend (running on the client) and the
determine what further authentication information it requires the
postmaster and backend (running on the server). The postmaster and backend
frontend to send (if any) and responds to the frontend accordingly.
have different roles but may be implemented by the same executable.
</para>
</para>
<para>
<Para>
The frontend then sends any required authentication information.
A frontend sends a start-up packet to the postmaster. This includes the names
Once the server validates this it responds to the frontend that it
of the user and the database the user wants to connect to. The postmaster then
is authenticated and sends a message indicating successful start-up
uses this, and the information in the <filename>pg_hba.conf</filename>
(normal case) or failure (for example, an invalid database name).
file
</para>
to determine what
further authentication information it requires the frontend to send (if any)
<para>
and responds to the frontend accordingly.
In order to serve multiple clients efficiently, the server would
</para>
normally create a new child process to handle each incoming
connection. However, this is not required. In the current
<Para>
implementation, a new child process is created immediately after an
The frontend then sends any required authentication information. Once the
incoming connection is detected. In earlier versions of PostgreSQL
postmaster validates this it responds to the frontend that it is authenticated
(7.1 and earlier), the child process was created after sending the
and hands over the connection to a backend. The backend then sends a message
authentication confirmation message.
indicating successful start-up (normal case) or failure (for example, an
</para>
invalid database name).
</para>
<para>
When the frontend wishes to disconnect it sends an appropriate packet and
<Para>
closes the connection without waiting for a response for the backend.
Subsequent communications are query and result packets exchanged between the
</para>
frontend and the backend. The postmaster takes no further part in ordinary
query/result communication. (However, the postmaster is involved when the
<para>
frontend wishes to cancel a query currently being executed by its backend.
Packets are sent as a data stream. The first byte determines what
Further details about that appear below.)
should be expected in the rest of the packet. The exceptions are
</para>
packets sent as part of the startup and authentication exchange,
which comprise a packet length followed by the packet itself. The
<Para>
difference is historical.
When the frontend wishes to disconnect it sends an appropriate packet and
</para>
closes the connection without waiting for a response for the backend.
</sect1>
</para>
<sect1 id="protocol-protocol">
<Para>
<title>Protocol</title>
Packets are sent as a data stream. The first byte determines what should be
expected in the rest of the packet. The exception is packets sent from a
<para>
frontend to the postmaster, which comprise a packet length then the packet
This section describes the message flow. There are four different
itself. The difference is historical.
types of flows depending on the state of the connection: start-up,
</para>
query, function call, and termination. There are also special
</sect1>
provisions for notification responses and command cancellation,
which can occur at any time after the start-up phase.
<Sect1 id="protocol-protocol">
</para>
<Title>Protocol</Title>
<sect2>
<Para>
<title>Start-up</Title>
This section describes the message flow. There are four different types of
flows depending on the state of the connection:
<para>
start-up, query, function call, and termination.
Initially, the frontend sends a StartupPacket. The server uses
There are also special provisions for notification responses and command
this info and the contents of the <filename>pg_hba.conf</filename>
cancellation, which can occur at any time after the start-up phase.
file to determine what authentication method the frontend must
</para>
use. The server then responds with one of the following messages:
<variablelist>
<Sect2>
<varlistentry>
<Title>Start-up</Title>
<term>ErrorResponse</term>
<listitem>
<Para>
<para>
Start-up is divided into an authentication phase and a backend start-up phase.
The server then immediately closes the connection.
</para>
</para>
</listitem>
<Para>
</varlistentry>
Initially, the frontend sends a StartupPacket. The postmaster uses this info
and the contents of the pg_hba.conf file to determine what authentication
<varlistentry>
method the frontend must use. The postmaster then responds with one of the
<term>AuthenticationOk</term>
following messages:
<listitem>
</para>
<para>
The authentication exchange is completed.
<Para>
</para>
<VariableList>
</listitem>
<VarListEntry>
</varlistentry>
<Term>
ErrorResponse
<varlistentry>
</Term>
<term>AuthenticationKerberosV4</Term>
<ListItem>
<listitem>
<Para>
<para>
The postmaster then immediately closes the connection.
The frontend must then take part in a Kerberos V4
</Para>
authentication dialog (not described here, part of the
</ListItem>
Kerberos specification) with the server. If this is
</VarListEntry>
successful, the server responds with an AuthenticationOk,
<VarListEntry>
otherwise it responds with an ErrorResponse.
<Term>
</para>
AuthenticationOk
</listitem>
</Term>
</varlistentry>
<ListItem>
<Para>
<varlistentry>
The postmaster then hands over to the backend. The postmaster
<Term>AuthenticationKerberosV5</Term>
takes no further part in the communication.
<ListItem>
</Para>
<Para>
</ListItem>
The frontend must then take part in a Kerberos V5
</VarListEntry>
authentication dialog (not described here, part of the
<VarListEntry>
Kerberos specification) with the server. If this is
<Term>
successful, the server responds with an AuthenticationOk,
AuthenticationKerberosV4
otherwise it responds with an ErrorResponse.
</Term>
</Para>
<ListItem>
</ListItem>
<Para>
</VarListEntry>
The frontend must then take part in a Kerberos V4
authentication dialog (not described here) with the postmaster.
<VarListEntry>
If this is successful, the postmaster responds with an
<Term>AuthenticationUnencryptedPassword</Term>
AuthenticationOk, otherwise it responds with an ErrorResponse.
<ListItem>
</Para>
<Para>
</ListItem>
The frontend must then send an UnencryptedPasswordPacket. If
</VarListEntry>
this is the correct password, the server responds with an
<VarListEntry>
AuthenticationOk, otherwise it responds with an ErrorResponse.
<Term>
</Para>
AuthenticationKerberosV5
</ListItem>
</Term>
</VarListEntry>
<ListItem>
<Para>
<VarListEntry>
The frontend must then take part in a Kerberos V5
<Term>AuthenticationEncryptedPassword</Term>
authentication dialog (not described here) with the postmaster.
<ListItem>
If this is successful, the postmaster responds with an
<Para>
AuthenticationOk, otherwise it responds with an ErrorResponse.
The frontend must then send an EncryptedPasswordPacket. If
</Para>
this is the correct password, the server responds with an
</ListItem>
AuthenticationOk, otherwise it responds with an ErrorResponse.
</VarListEntry>
</Para>
<VarListEntry>
</ListItem>
<Term>
</VarListEntry>
AuthenticationUnencryptedPassword
</Term>
</VariableList>
<ListItem>
</Para>
<Para>
The frontend must then send an UnencryptedPasswordPacket.
<para>
If this is the correct password, the postmaster responds with
If the frontend does not support the authentication method
an AuthenticationOk, otherwise it responds with an
requested by the server, then it should immediately close the
ErrorResponse.
connection.
</Para>
</para>
</ListItem>
</VarListEntry>
<para>
<VarListEntry>
After having received AuthenticationOk, the frontend should wait
<Term>
for further messages from the server. The possible messages from
AuthenticationEncryptedPassword
the backend in this phase are:
</Term>
<ListItem>
<VariableList>
<Para>
<VarListEntry>
The frontend must then send an EncryptedPasswordPacket.
<Term>BackendKeyData</Term>
If this is the correct password, the postmaster responds with
<ListItem>
an AuthenticationOk, otherwise it responds with an
<Para>
ErrorResponse.
This message provides secret-key data that the frontend must
</Para>
save if it wants to be able to issue cancel requests later.
</ListItem>
The frontend should not respond to this message, but should
</VarListEntry>
continue listening for a ReadyForQuery message.
</VariableList>
</Para>
</Para>
</ListItem>
</VarListEntry>
<Para>
If the frontend does not support the authentication method requested by the
<VarListEntry>
postmaster, then it should immediately close the connection.
<Term>ReadyForQuery</Term>
</para>
<ListItem>
<Para>
<Para>
Start-up is completed. The frontend may now issue query or
After sending AuthenticationOk, the postmaster attempts to launch a backend
function call messages.
process. Since this might fail, or the backend might encounter a failure
</Para>
during start-up, the frontend must wait for the backend to acknowledge
</ListItem>
successful start-up. The frontend should send no messages at this point.
</VarListEntry>
The possible messages from the backend during this phase are:
<VarListEntry>
<VariableList>
<Term>ErrorResponse</Term>
<VarListEntry>
<ListItem>
<Term>
<Para>
BackendKeyData
Start-up failed. The connection is closed after sending this
</Term>
message.
<ListItem>
</Para>
<Para>
</ListItem>
This message is issued after successful backend start-up.
</VarListEntry>
It provides secret-key data that the frontend must save
if it wants to be able to issue cancel requests later.
<VarListEntry>
The frontend should not respond to this message, but should
<Term>NoticeResponse</Term>
continue listening for a ReadyForQuery message.
<ListItem>
</Para>
<Para>
</ListItem>
A warning message has been issued. The frontend should
</VarListEntry>
display the message but continue listening for ReadyForQuery
<VarListEntry>
or ErrorResponse.
<Term>
</Para>
ReadyForQuery
</ListItem>
</Term>
</VarListEntry>
<ListItem>
</VariableList>
<Para>
</Para>
Backend start-up is successful. The frontend may now issue
query or function call messages.
<para>
</Para>
The ReadyForQuery message is the same one that the backend will
</ListItem>
issue after each query cycle. Depending on the coding needs of
</VarListEntry>
the frontend, it is reasonable to consider ReadyForQuery as
<VarListEntry>
starting a query cycle (and then BackendKeyData indicates
<Term>
successful conclusion of the start-up phase), or to consider
ErrorResponse
ReadyForQuery as ending the start-up phase and each subsequent
</Term>
query cycle.
<ListItem>
</para>
<Para>
</sect2>
Backend start-up failed. The connection is closed after
sending this message.
<Sect2>
</Para>
<Title>Query</Title>
</ListItem>
</VarListEntry>
<Para>
<VarListEntry>
A Query cycle is initiated by the frontend sending a Query message
<Term>
to the backend. The backend then sends one or more response
NoticeResponse
messages depending on the contents of the query command string,
</Term>
and finally a ReadyForQuery response message. ReadyForQuery
<ListItem>
informs the frontend that it may safely send a new query or
<Para>
function call.
A warning message has been issued. The frontend should
</para>
display the message but continue listening for ReadyForQuery
or ErrorResponse.
<Para>
</Para>
The possible response messages from the backend are:
</ListItem>
</VarListEntry>
<VariableList>
</VariableList>
<VarListEntry>
</Para>
<Term>CompletedResponse</Term>
<ListItem>
<Para>
<Para>
The ReadyForQuery message is the same one that the backend will issue after
An SQL command completed normally.
each query cycle. Depending on the coding needs of the frontend, it is
</Para>
reasonable to consider ReadyForQuery as starting a query cycle (and then
</ListItem>
BackendKeyData indicates successful conclusion of the start-up phase),
</VarListEntry>
or to consider ReadyForQuery as ending the start-up phase and each subsequent
query cycle.
<VarListEntry>
</para>
<Term>CopyInResponse</Term>
</sect2>
<ListItem>
<Para>
<Sect2>
The backend is ready to copy data from the frontend to a
<Title>Query</Title>
table. The frontend should then send a CopyDataRows message.
The backend will then respond with a CompletedResponse message
<Para>
with a tag of <literal>COPY</literal>.
A Query cycle is initiated by the frontend sending a Query message to the
</Para>
backend. The backend then sends one or more response messages depending
</ListItem>
on the contents of the query command string, and finally a ReadyForQuery
</VarListEntry>
response message. ReadyForQuery informs the frontend that it may safely
send a new query or function call.
<VarListEntry>
</para>
<Term>CopyOutResponse</Term>
<ListItem>
<Para>
<Para>
The possible response messages from the backend are:
The backend is ready to copy data from a table to the
frontend. It then sends a CopyDataRows message, and then a
<VariableList>
CompletedResponse message with a tag of <literal>COPY</literal>.
<VarListEntry>
</Para>
<Term>
</ListItem>
CompletedResponse
</VarListEntry>
</Term>
<ListItem>
<VarListEntry>
<Para>
<Term>CursorResponse</Term>
An SQL command completed normally.
<ListItem>
</Para>
<Para>
</ListItem>
The query was either an <literal>INSERT</literal>,
</VarListEntry>
<literal>UPDATE</literal>, <literal>DELETE</literal>,
<VarListEntry>
<literal>FETCH</literal>, or a <literal>SELECT</literal>
<Term>
command. If the transaction has been aborted then the backend
CopyInResponse
sends a CompletedResponse message with a tag of <literal>*ABORT
</Term>
STATE*</literal>. Otherwise the following responses are sent.
<ListItem>
</Para>
<Para>
The backend is ready to copy data from the frontend to a
<Para>
relation. The frontend should then send a CopyDataRows
For an <literal>INSERT</literal> command, the backend then
message. The backend will then respond with a
sends a CompletedResponse message with a tag of
CompletedResponse message with a tag of "COPY".
<literal>INSERT <replaceable>oid</replaceable>
</Para>
<replaceable>rows</replaceable></literal>, where
</ListItem>
<replaceable>rows</replaceable> is the number of rows
</VarListEntry>
inserted, and <replaceable>oid</replaceable> is the object ID
<VarListEntry>
of the inserted row if <Replaceable>rows</Replaceable> is 1,
<Term>
otherwise <Replaceable>oid</Replaceable> is 0.
CopyOutResponse
</Para>
</Term>
<ListItem>
<Para>
<Para>
For a <literal>DELETE</literal> command, the backend then
The backend is ready to copy data from a relation to the
sends a CompletedResponse message with a tag of <literal>DELETE
frontend. It then sends a CopyDataRows message, and then a
<Replaceable>rows</Replaceable></literal> where
CompletedResponse message with a tag of "COPY".
<Replaceable>rows</Replaceable> is the number of rows deleted.
</Para>
</Para>
</ListItem>
</VarListEntry>
<Para>
<VarListEntry>
For an <literal>UPDATE</literal> command, the backend then
<Term>
sends a CompletedResponse message with a tag of <literal>UPDATE
CursorResponse
<Replaceable>rows</Replaceable></literal> where
</Term>
<Replaceable>rows</Replaceable> is the number of rows affected
<ListItem>
by the update.
<Para>
</Para>
The query was either an insert(l), delete(l), update(l),
fetch(l) or a select(l) command.
<Para>
If the transaction has been
For a <literal>FETCH</literal> or <literal>SELECT</literal>
aborted then the backend sends a CompletedResponse message with
command, the backend sends a RowDescription message. This is
a tag of "*ABORT STATE*". Otherwise the following responses
then followed by an AsciiRow or BinaryRow message (depending
are sent.
on whether a binary cursor was specified) for each row being
</Para>
returned to the frontend. Finally, the backend sends a
<Para>
CompletedResponse message with a tag of <literal>SELECT</literal>.
For an insert(l) command, the backend then sends a
</Para>
CompletedResponse message with a tag of "INSERT <Replaceable>oid</Replaceable> <Replaceable>rows</Replaceable>"
</ListItem>
where <Replaceable>rows</Replaceable> is the number of rows inserted, and <Replaceable>oid</Replaceable> is the
</VarListEntry>
object ID of the inserted row if <Replaceable>rows</Replaceable> is 1, otherwise <Replaceable>oid</Replaceable>
is 0.
<VarListEntry>
</Para>
<Term>EmptyQueryResponse</Term>
<Para>
<ListItem>
For a delete(l) command, the backend then sends a
<Para>
CompletedResponse message with a tag of "DELETE <Replaceable>rows</Replaceable>" where
An empty query string was recognized. (The need to specially
<Replaceable>rows</Replaceable> is the number of rows deleted.
distinguish this case is historical.)
</Para>
</Para>
<Para>
</ListItem>
For an update(l) command, the backend then sends a
</VarListEntry>
CompletedResponse message with a tag of "UPDATE <Replaceable>rows</Replaceable>" where
<Replaceable>rows</Replaceable> is the number of rows deleted.
<VarListEntry>
</Para>
<Term>ErrorResponse</Term>
<Para>
<ListItem>
For a fetch(l) or select(l) command, the backend sends a
<Para>
RowDescription message. This is then followed by an AsciiRow
An error has occurred.
or BinaryRow message (depending on whether a binary cursor was
</Para>
specified) for each row being returned to the frontend.
</ListItem>
Finally, the backend sends a CompletedResponse message with a
</VarListEntry>
tag of "SELECT".
</Para>
<VarListEntry>
</ListItem>
<Term>ReadyForQuery</Term>
</VarListEntry>
<ListItem>
<VarListEntry>
<Para>
<Term>
Processing of the query string is complete. A separate
EmptyQueryResponse
message is sent to indicate this because the query string may
</Term>
contain multiple SQL commands. (CompletedResponse marks the
<ListItem>
end of processing one SQL command, not the whole string.)
<Para>
ReadyForQuery will always be sent, whether processing
An empty query string was recognized. (The need to specially
terminates successfully or with an error.
distinguish this case is historical.)
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>NoticeResponse</Term>
ErrorResponse
<ListItem>
</Term>
<Para>
<ListItem>
A warning message has been issued in relation to the query.
<Para>
Notices are in addition to other responses, i.e., the backend
An error has occurred.
will continue processing the command.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<Term>
</VariableList>
ReadyForQuery
</Para>
</Term>
<ListItem>
<para>
<Para>
A frontend must be prepared to accept ErrorResponse and
Processing of the query string is complete. A separate
NoticeResponse messages whenever it is expecting any other type of
message is sent to indicate this because the query string
message.
may contain multiple SQL commands. (CompletedResponse marks
</para>
the end of processing one SQL command, not the whole string.)
ReadyForQuery will always be sent, whether processing
<Para>
terminates successfully or with an error.
Actually, it is possible for NoticeResponse to arrive even when
</Para>
the frontend is not expecting any kind of message, that is, the
</ListItem>
backend is nominally idle. (In particular, the backend can be
</VarListEntry>
commanded to terminate by its parent process. In that case it will
<VarListEntry>
send a NoticeResponse before closing the connection.) It is
<Term>
recommended that the frontend check for such asynchronous notices
NoticeResponse
just before issuing any new command.
</Term>
</para>
<ListItem>
<Para>
<Para>
A warning message has been issued in relation to the query.
Also, if the frontend issues any <literal>LISTEN</literal>
Notices are in addition to other responses, i.e., the backend
commands then it must be prepared to accept NotificationResponse
will continue processing the command.
messages at any time; see below.
</Para>
</para>
</ListItem>
</sect2>
</VarListEntry>
</VariableList>
<Sect2>
</Para>
<Title>Function Call</Title>
<Para>
<Para>
A frontend must be prepared to accept ErrorResponse and NoticeResponse
A Function Call cycle is initiated by the frontend sending a
messages whenever it is expecting any other type of message.
FunctionCall message to the backend. The backend then sends one
</para>
or more response messages depending on the results of the function
call, and finally a ReadyForQuery response message. ReadyForQuery
<Para>
informs the frontend that it may safely send a new query or
Actually, it is possible for NoticeResponse to arrive even when the frontend
function call.
is not expecting any kind of message, that is, the backend is nominally idle.
</para>
(In particular, the backend can be commanded to terminate by its postmaster.
In that case it will send a NoticeResponse before closing the connection.)
<Para>
It is recommended that the frontend check for such asynchronous notices just
The possible response messages from the backend are:
before issuing any new command.
</para>
<VariableList>
<VarListEntry>
<Para>
<Term>ErrorResponse</Term>
Also, if the frontend issues any listen(l) commands then it must be prepared
<ListItem>
to accept NotificationResponse messages at any time; see below.
<Para>
</para>
An error has occurred.
</sect2>
</Para>
</ListItem>
<Sect2>
</VarListEntry>
<Title>Function Call</Title>
<VarListEntry>
<Para>
<Term>FunctionResultResponse</Term>
A Function Call cycle is initiated by the frontend sending a FunctionCall
<ListItem>
message to the backend. The backend then sends one or more response messages
<Para>
depending on the results of the function call, and finally a ReadyForQuery
The function call was executed and returned a result.
response message. ReadyForQuery informs the frontend that it may safely send
</Para>
a new query or function call.
</ListItem>
</para>
</VarListEntry>
<Para>
<VarListEntry>
The possible response messages from the backend are:
<Term>FunctionVoidResponse</Term>
<ListItem>
<VariableList>
<Para>
<VarListEntry>
The function call was executed and returned no result.
<Term>
</Para>
ErrorResponse
</ListItem>
</Term>
</VarListEntry>
<ListItem>
<Para>
<VarListEntry>
An error has occurred.
<Term>ReadyForQuery</Term>
</Para>
<ListItem>
</ListItem>
<Para>
</VarListEntry>
Processing of the function call is complete. ReadyForQuery
<VarListEntry>
will always be sent, whether processing terminates
<Term>
successfully or with an error.
FunctionResultResponse
</Para>
</Term>
</ListItem>
<ListItem>
</VarListEntry>
<Para>
The function call was executed and returned a result.
<VarListEntry>
</Para>
<Term>NoticeResponse</Term>
</ListItem>
<ListItem>
</VarListEntry>
<Para>
<VarListEntry>
A warning message has been issued in relation to the function
<Term>
call. Notices are in addition to other responses, i.e., the
FunctionVoidResponse
backend will continue processing the command.
</Term>
</Para>
<ListItem>
</ListItem>
<Para>
</VarListEntry>
The function call was executed and returned no result.
</VariableList>
</Para>
</Para>
</ListItem>
</VarListEntry>
<para>
<VarListEntry>
A frontend must be prepared to accept ErrorResponse and
<Term>
NoticeResponse messages whenever it is expecting any other type of
ReadyForQuery
message. Also, if it issues any <literal>LISTEN</literal>
</Term>
commands then it must be prepared to accept NotificationResponse
<ListItem>
messages at any time; see below.
<Para>
</para>
Processing of the function call is complete.
</sect2>
ReadyForQuery will always be sent, whether processing
terminates successfully or with an error.
<sect2>
</Para>
<title>Notification Responses</title>
</ListItem>
</VarListEntry>
<Para>
<VarListEntry>
If a frontend issues a <literal>LISTEN</literal> command, then the
<Term>
backend will send a NotificationResponse message (not to be
NoticeResponse
confused with NoticeResponse!) whenever a
</Term>
<literal>NOTIFY</literal> command is executed for the same
<ListItem>
notification name.
<Para>
</para>
A warning message has been issued in relation to the function
call.
<para>
Notices are in addition to other responses, i.e., the backend
Notification responses are permitted at any point in the protocol
will continue processing the command.
(after start-up), except within another backend message. Thus,
</Para>
the frontend must be prepared to recognize a NotificationResponse
</ListItem>
message whenever it is expecting any message. Indeed, it should
</VarListEntry>
be able to handle NotificationResponse messages even when it is
</VariableList>
not engaged in a query.
</Para>
<VariableList>
<Para>
<VarListEntry>
A frontend must be prepared to accept ErrorResponse and NoticeResponse
<Term>NotificationResponse</Term>
messages whenever it is expecting any other type of message. Also,
<ListItem>
if it issues any listen(l) commands then it must be prepared to accept
<Para>
NotificationResponse messages at any time; see below.
A <literal>NOTIFY</literal> command has been executed for a
</para>
name for which a previous <literal>LISTEN</literal> command
</sect2>
was executed. Notifications may be sent at any time.
</Para>
<Sect2>
</ListItem>
<Title>Notification Responses</Title>
</VarListEntry>
</VariableList>
<Para>
</Para>
If a frontend issues a listen(l) command, then the backend will send a
NotificationResponse message (not to be confused with NoticeResponse!)
<para>
whenever a notify(l) command is executed for the same notification name.
It may be worth pointing out that the names used in listen and
</para>
notify commands need not have anything to do with names of
relations (tables) in the SQL database. Notification names are
<Para>
simply arbitrarily chosen condition names.
Notification responses are permitted at any point in the protocol (after
</para>
start-up), except within another backend message. Thus, the frontend
</sect2>
must be prepared to recognize a NotificationResponse message whenever it is
expecting any message. Indeed, it should be able to handle
<Sect2>
NotificationResponse messages even when it is not engaged in a query.
<Title>Cancelling Requests in Progress</Title>
<VariableList>
<Para>
<VarListEntry>
During the processing of a query, the frontend may request
<Term>
cancellation of the query. The cancel request is not sent
NotificationResponse
directly on the open connection to the backend for reasons of
</Term>
implementation efficiency: we don't want to have the backend
<ListItem>
constantly checking for new input from the frontend during query
<Para>
processing. Cancel requests should be relatively infrequent, so
A notify(l) command has been executed for a name for which
we make them slightly cumbersome in order to avoid a penalty in
a previous listen(l) command was executed. Notifications
the normal case.
may be sent at any time.
</para>
</Para>
</ListItem>
<Para>
</VarListEntry>
To issue a cancel request, the frontend opens a new connection to
</VariableList>
the server and sends a CancelRequest message, rather than the
</Para>
StartupPacket message that would ordinarily be sent across a new
connection. The server will process this request and then close
<Para>
the connection. For security reasons, no direct reply is made to
It may be worth pointing out that the names used in listen and notify
the cancel request message.
commands need not have anything to do with names of relations (tables)
</para>
in the SQL database. Notification names are simply arbitrarily chosen
condition names.
<Para>
</para>
A CancelRequest message will be ignored unless it contains the
</sect2>
same key data (PID and secret key) passed to the frontend during
connection start-up. If the request matches the PID and secret
<Sect2>
key for a currently executing backend, the processing of the
<Title>Cancelling Requests in Progress</Title>
current query is aborted. (In the existing implemenation, this is
done by sending a special signal to the backend process that is
<Para>
processing the query.)
During the processing of a query, the frontend may request cancellation of the
</para>
query by sending an appropriate request to the postmaster. The cancel request
is not sent directly to the backend for reasons of implementation efficiency:
<Para>
we don't want to have the backend constantly checking for new input from
The cancellation signal may or may not have any effect --- for
the frontend during query processing. Cancel requests should be relatively
example, if it arrives after the backend has finished processing
infrequent, so we make them slightly cumbersome in order to avoid a penalty
the query, then it will have no effect. If the cancellation is
in the normal case.
effective, it results in the current command being terminated
</para>
early with an error message.
</para>
<Para>
To issue a cancel request, the frontend opens a new connection to the
<Para>
postmaster and sends a CancelRequest message, rather than the StartupPacket
The upshot of all this is that for reasons of both security and
message that would ordinarily be sent across a new connection. The postmaster
efficiency, the frontend has no direct way to tell whether a
will process this request and then close the connection. For security
cancel request has succeeded. It must continue to wait for the
reasons, no direct reply is made to the cancel request message.
backend to respond to the query. Issuing a cancel simply improves
</para>
the odds that the current query will finish soon, and improves the
odds that it will fail with an error message instead of
<Para>
succeeding.
A CancelRequest message will be ignored unless it contains the same key data
</para>
(PID and secret key) passed to the frontend during connection start-up. If the
request matches the PID and secret key for a currently executing backend, the
<Para>
postmaster signals the backend to abort processing of the current query.
Since the cancel request is sent across a new connection to the
</para>
server and not across the regular frontend/backend communication
link, it is possible for the cancel request to be issued by any
<Para>
process, not just the frontend whose query is to be canceled.
The cancellation signal may or may not have any effect --- for example, if it
This may have some benefits of flexibility in building
arrives after the backend has finished processing the query, then it will have
multiple-process applications. It also introduces a security
no effect. If the cancellation is effective, it results in the current
risk, in that unauthorized persons might try to cancel queries.
command being terminated early with an error message.
The security risk is addressed by requiring a dynamically
</para>
generated secret key to be supplied in cancel requests.
</para>
<Para>
</sect2>
The upshot of all this is that for reasons of both security and efficiency,
the frontend has no direct way to tell whether a cancel request has succeeded.
<Sect2>
It must continue to wait for the backend to respond to the query. Issuing a
<Title>Termination</Title>
cancel simply improves the odds that the current query will finish soon,
and improves the odds that it will fail with an error message instead of
<Para>
succeeding.
The normal, graceful termination procedure is that the frontend
</para>
sends a Terminate message and immediately closes the connection.
On receipt of the message, the backend immediately closes the
<Para>
connection and terminates.
Since the cancel request is sent to the postmaster and not across the
</para>
regular frontend/backend communication link, it is possible for the cancel
request to be issued by any process, not just the frontend whose query is
<Para>
to be canceled. This may have some benefits of flexibility in building
An ungraceful termination may occur due to software failure (i.e.,
multiple-process applications. It also introduces a security risk, in that
core dump) at either end. If either frontend or backend sees an
unauthorized persons might try to cancel queries. The security risk is
unexpected closure of the connection, it should clean up and
addressed by requiring a dynamically generated secret key to be supplied
terminate. The frontend has the option of launching a new backend
in cancel requests.
by recontacting the server if it doesn't want to terminate
</para>
itself.
</sect2>
</para>
</sect2>
<Sect2>
</sect1>
<Title>Termination</Title>
<Para>
The normal, graceful termination procedure is that the frontend sends a
Terminate message and immediately closes the connection. On receipt of the
message, the backend immediately closes the connection and terminates.
</para>
<Para>
An ungraceful termination may occur due to software failure (i.e., core dump)
at either end. If either frontend or backend sees an unexpected closure of
the connection, it should clean up and terminate. The frontend has the option
of launching a new backend by recontacting the postmaster, if it doesn't want
to terminate itself.
</para>
</sect2>
</sect1>
<Sect1 id="protocol-message-types">
<Sect1 id="protocol-message-types">
<Title>Message Data Types</Title>
<Title>Message Data Types</Title>
...
@@ -629,41 +612,41 @@ This section describes the base data types used in messages.
...
@@ -629,41 +612,41 @@ This section describes the base data types used in messages.
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int<Replaceable>n</Replaceable>(<Replaceable>i</Replaceable>)
Int<Replaceable>n</Replaceable>(<Replaceable>i</Replaceable>)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
An <Replaceable>n</Replaceable> bit integer in network byte order.
An <Replaceable>n</Replaceable> bit integer in network byte order.
If <Replaceable>i</Replaceable> is specified it
If <Replaceable>i</Replaceable> is specified it
is the literal value. Eg. Int16, Int32(42).
is the literal value. Eg. Int16, Int32(42).
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString<Replaceable>n</Replaceable>(<Replaceable>s</Replaceable>)
LimString<Replaceable>n</Replaceable>(<Replaceable>s</Replaceable>)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
A character array of exactly <Replaceable>n</Replaceable> bytes interpreted as a '\0'
A character array of exactly <Replaceable>n</Replaceable> bytes interpreted as a '\0'
terminated string. The '\0' is omitted if there is
terminated string. The '\0' is omitted if there is
insufficient room. If <Replaceable>s</Replaceable> is specified it is the literal value.
insufficient room. If <Replaceable>s</Replaceable> is specified it is the literal value.
Eg. LimString32, LimString64("user").
Eg. LimString32, LimString64("user").
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String(<Replaceable>s</Replaceable>)
String(<Replaceable>s</Replaceable>)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
A conventional C '\0' terminated string with no length
A conventional C '\0' terminated string with no length
limitation.
limitation.
If <Replaceable>s</Replaceable> is specified it is the literal value.
If <Replaceable>s</Replaceable> is specified it is the literal value.
Eg. String, String("user").
Eg. String, String("user").
</Para>
</Para>
<Note>
<Note>
<Para>
<Para>
<Emphasis>There is no predefined limit</Emphasis> on the length of a string
<Emphasis>There is no predefined limit</Emphasis> on the length of a string
...
@@ -677,12 +660,12 @@ characters that don't fit into your fixed-size buffer.
...
@@ -677,12 +660,12 @@ characters that don't fit into your fixed-size buffer.
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>(<Replaceable>c</Replaceable>)
Byte<Replaceable>n</Replaceable>(<Replaceable>c</Replaceable>)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Exactly <Replaceable>n</Replaceable> bytes. If <Replaceable>c</Replaceable> is specified it is the literal
Exactly <Replaceable>n</Replaceable> bytes. If <Replaceable>c</Replaceable> is specified it is the literal
value. Eg. Byte, Byte1('\n').
value. Eg. Byte, Byte1('\n').
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -695,7 +678,7 @@ characters that don't fit into your fixed-size buffer.
...
@@ -695,7 +678,7 @@ characters that don't fit into your fixed-size buffer.
<Para>
<Para>
This section describes the detailed format of each message. Each can be sent
This section describes the detailed format of each message. Each can be sent
by either a frontend (F), a
postmaster/
backend (B), or both (F & B).
by either a frontend (F), a backend (B), or both (F & B).
</para>
</para>
<VariableList>
<VariableList>
...
@@ -708,19 +691,19 @@ AsciiRow (B)
...
@@ -708,19 +691,19 @@ AsciiRow (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('D')
Byte1('D')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an <Acronym>ASCII</Acronym> data row.
Identifies the message as an <Acronym>ASCII</Acronym> data row.
(A prior RowDescription message defines the number of
(A prior RowDescription message defines the number of
fields in the row and their data types.)
fields in the row and their data types.)
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
...
@@ -734,30 +717,30 @@ AsciiRow (B)
...
@@ -734,30 +717,30 @@ AsciiRow (B)
of the last byte in the bit map is wasted.
of the last byte in the bit map is wasted.
</Para>
</Para>
<Para>
<Para>
Then, for each field with a non-NULL value, there is the following:
Then, for each field with a non-NULL value, there is the following:
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the size of the value of the field, including
Specifies the size of the value of the field, including
this size.
this size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the value of the field itself in <Acronym>ASCII</Acronym>
Specifies the value of the field itself in <Acronym>ASCII</Acronym>
characters. <Replaceable>n</Replaceable> is the above
characters. <Replaceable>n</Replaceable> is the above
size minus 4.
size minus 4.
There is no trailing '\0' in the field data; the front
There is no trailing '\0' in the field data; the front
end must add one if it wants one.
end must add one if it wants one.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -781,21 +764,21 @@ AuthenticationOk (B)
...
@@ -781,21 +764,21 @@ AuthenticationOk (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('R')
Byte1('R')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an authentication request.
Identifies the message as an authentication request.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(0)
Int32(0)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that the authentication was successful.
Specifies that the authentication was successful.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -814,21 +797,21 @@ AuthenticationKerberosV4 (B)
...
@@ -814,21 +797,21 @@ AuthenticationKerberosV4 (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('R')
Byte1('R')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an authentication request.
Identifies the message as an authentication request.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(1)
Int32(1)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that Kerberos V4 authentication is required.
Specifies that Kerberos V4 authentication is required.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -848,21 +831,21 @@ AuthenticationKerberosV5 (B)
...
@@ -848,21 +831,21 @@ AuthenticationKerberosV5 (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('R')
Byte1('R')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an authentication request.
Identifies the message as an authentication request.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(2)
Int32(2)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that Kerberos V5 authentication is required.
Specifies that Kerberos V5 authentication is required.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -882,21 +865,21 @@ AuthenticationUnencryptedPassword (B)
...
@@ -882,21 +865,21 @@ AuthenticationUnencryptedPassword (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('R')
Byte1('R')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an authentication request.
Identifies the message as an authentication request.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(3)
Int32(3)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that an unencrypted password is required.
Specifies that an unencrypted password is required.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -916,31 +899,31 @@ AuthenticationEncryptedPassword (B)
...
@@ -916,31 +899,31 @@ AuthenticationEncryptedPassword (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('R')
Byte1('R')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an authentication request.
Identifies the message as an authentication request.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(4)
Int32(4)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that an encrypted password is required.
Specifies that an encrypted password is required.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte2
Byte2
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The salt to use when encrypting the password.
The salt to use when encrypting the password.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -959,33 +942,33 @@ BackendKeyData (B)
...
@@ -959,33 +942,33 @@ BackendKeyData (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('K')
Byte1('K')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as cancellation key data.
Identifies the message as cancellation key data.
The frontend must save these values if it wishes to be
The frontend must save these values if it wishes to be
able to issue CancelRequest messages later.
able to issue CancelRequest messages later.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The process ID of this backend.
The process ID of this backend.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The secret key of this backend.
The secret key of this backend.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1005,19 +988,19 @@ BinaryRow (B)
...
@@ -1005,19 +988,19 @@ BinaryRow (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('B')
Byte1('B')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a binary data row.
Identifies the message as a binary data row.
(A prior RowDescription message defines the number of
(A prior RowDescription message defines the number of
fields in the row and their data types.)
fields in the row and their data types.)
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
...
@@ -1031,27 +1014,27 @@ BinaryRow (B)
...
@@ -1031,27 +1014,27 @@ BinaryRow (B)
of the last byte in the bit map is wasted.
of the last byte in the bit map is wasted.
</Para>
</Para>
<Para>
<Para>
Then, for each field with a non-NULL value, there is the following:
Then, for each field with a non-NULL value, there is the following:
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the size of the value of the field, excluding
Specifies the size of the value of the field, excluding
this size.
this size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the value of the field itself in binary
Specifies the value of the field itself in binary
format. <Replaceable>n</Replaceable> is the above size.
format. <Replaceable>n</Replaceable> is the above size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1075,44 +1058,44 @@ CancelRequest (F)
...
@@ -1075,44 +1058,44 @@ CancelRequest (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(16)
Int32(16)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The size of the packet in bytes.
The size of the packet in bytes.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(80877102)
Int32(80877102)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The cancel request code. The value is chosen to contain
The cancel request code. The value is chosen to contain
"1234" in the most significant 16 bits, and "5678" in the
"1234" in the most significant 16 bits, and "5678" in the
least 16 significant bits. (To avoid confusion, this code
least 16 significant bits. (To avoid confusion, this code
must not be the same as any protocol version number.)
must not be the same as any protocol version number.)
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The process ID of the target backend.
The process ID of the target backend.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The secret key for the target backend.
The secret key for the target backend.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1132,22 +1115,22 @@ CompletedResponse (B)
...
@@ -1132,22 +1115,22 @@ CompletedResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('C')
Byte1('C')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a completed response.
Identifies the message as a completed response.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The command tag. This is usually (but not always) a single
The command tag. This is usually (but not always) a single
word that identifies which SQL command was completed.
word that identifies which SQL command was completed.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1163,9 +1146,9 @@ CopyDataRows (B & F)
...
@@ -1163,9 +1146,9 @@ CopyDataRows (B & F)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
This is a stream of rows where each row is terminated by a Byte1('\n').
This is a stream of rows where each row is terminated by a Byte1('\n').
This is then followed by the sequence Byte1('\\'), Byte1('.'),
This is then followed by the sequence Byte1('\\'), Byte1('.'),
Byte1('\n').
Byte1('\n').
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1179,12 +1162,12 @@ CopyInResponse (B)
...
@@ -1179,12 +1162,12 @@ CopyInResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('G')
Byte1('G')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a Start Copy In response.
Identifies the message as a Start Copy In response.
The frontend must now send a CopyDataRows message.
The frontend must now send a CopyDataRows message.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1204,12 +1187,12 @@ CopyOutResponse (B)
...
@@ -1204,12 +1187,12 @@ CopyOutResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('H')
Byte1('H')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a Start Copy Out response.
Identifies the message as a Start Copy Out response.
This message will be followed by a CopyDataRows message.
This message will be followed by a CopyDataRows message.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1229,22 +1212,22 @@ CursorResponse (B)
...
@@ -1229,22 +1212,22 @@ CursorResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('P')
Byte1('P')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a cursor response.
Identifies the message as a cursor response.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The name of the cursor. This will be "blank" if the cursor is
The name of the cursor. This will be "blank" if the cursor is
implicit.
implicit.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1264,21 +1247,21 @@ EmptyQueryResponse (B)
...
@@ -1264,21 +1247,21 @@ EmptyQueryResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('I')
Byte1('I')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a response to an empty query string.
Identifies the message as a response to an empty query string.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String("")
String("")
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Unused.
Unused.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1298,21 +1281,21 @@ EncryptedPasswordPacket (F)
...
@@ -1298,21 +1281,21 @@ EncryptedPasswordPacket (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The size of the packet in bytes.
The size of the packet in bytes.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The encrypted (using crypt()) password.
The encrypted (using crypt()) password.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1332,21 +1315,21 @@ ErrorResponse (B)
...
@@ -1332,21 +1315,21 @@ ErrorResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('E')
Byte1('E')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as an error.
Identifies the message as an error.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The error message itself.
The error message itself.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1366,65 +1349,65 @@ FunctionCall (F)
...
@@ -1366,65 +1349,65 @@ FunctionCall (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('F')
Byte1('F')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a function call.
Identifies the message as a function call.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String("")
String("")
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Unused.
Unused.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the object ID of the function to call.
Specifies the object ID of the function to call.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the number of arguments being supplied to the
Specifies the number of arguments being supplied to the
function.
function.
</Para>
</Para>
<Para>
<Para>
Then, for each argument, there is the following:
Then, for each argument, there is the following:
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the size of the value of the argument,
Specifies the size of the value of the argument,
excluding this size.
excluding this size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the value of the field itself in binary
Specifies the value of the field itself in binary
format. <Replaceable>n</Replaceable> is the above size.
format. <Replaceable>n</Replaceable> is the above size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1449,55 +1432,55 @@ FunctionResultResponse (B)
...
@@ -1449,55 +1432,55 @@ FunctionResultResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('V')
Byte1('V')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a function call result.
Identifies the message as a function call result.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('G')
Byte1('G')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that a nonempty result was returned.
Specifies that a nonempty result was returned.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the size of the value of the result, excluding this
Specifies the size of the value of the result, excluding this
size.
size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte<Replaceable>n</Replaceable>
Byte<Replaceable>n</Replaceable>
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the value of the result itself in binary format.
Specifies the value of the result itself in binary format.
<Replaceable>n</Replaceable> is the above size.
<Replaceable>n</Replaceable> is the above size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('0')
Byte1('0')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Unused. (Strictly speaking, FunctionResultResponse and
Unused. (Strictly speaking, FunctionResultResponse and
FunctionVoidResponse are the same thing but with some optional
FunctionVoidResponse are the same thing but with some optional
parts to the message.)
parts to the message.)
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1517,21 +1500,21 @@ FunctionVoidResponse (B)
...
@@ -1517,21 +1500,21 @@ FunctionVoidResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('V')
Byte1('V')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a function call result.
Identifies the message as a function call result.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('0')
Byte1('0')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies that an empty result was returned.
Specifies that an empty result was returned.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1551,21 +1534,21 @@ NoticeResponse (B)
...
@@ -1551,21 +1534,21 @@ NoticeResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('N')
Byte1('N')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a notice.
Identifies the message as a notice.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The notice message itself.
The notice message itself.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1585,31 +1568,31 @@ NotificationResponse (B)
...
@@ -1585,31 +1568,31 @@ NotificationResponse (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('A')
Byte1('A')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a notification response.
Identifies the message as a notification response.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The process ID of the notifying backend process.
The process ID of the notifying backend process.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The name of the condition that the notify has been raised on.
The name of the condition that the notify has been raised on.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1629,21 +1612,21 @@ Query (F)
...
@@ -1629,21 +1612,21 @@ Query (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('Q')
Byte1('Q')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a query.
Identifies the message as a query.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The query string itself.
The query string itself.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1663,12 +1646,12 @@ ReadyForQuery (B)
...
@@ -1663,12 +1646,12 @@ ReadyForQuery (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('Z')
Byte1('Z')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message type. ReadyForQuery is sent
Identifies the message type. ReadyForQuery is sent
whenever the backend is ready for a new query cycle.
whenever the backend is ready for a new query cycle.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1688,62 +1671,62 @@ RowDescription (B)
...
@@ -1688,62 +1671,62 @@ RowDescription (B)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('T')
Byte1('T')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a row description.
Identifies the message as a row description.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int16
Int16
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the number of fields in a row (may be zero).
Specifies the number of fields in a row (may be zero).
</Para>
</Para>
<Para>
<Para>
Then, for each field, there is the following:
Then, for each field, there is the following:
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the field name.
Specifies the field name.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the object ID of the field type.
Specifies the object ID of the field type.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int16
Int16
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the type size.
Specifies the type size.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Specifies the type modifier.
Specifies the type modifier.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1768,74 +1751,74 @@ StartupPacket (F)
...
@@ -1768,74 +1751,74 @@ StartupPacket (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32(296)
Int32(296)
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The size of the packet in bytes.
The size of the packet in bytes.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The protocol version number. The most significant 16 bits are
The protocol version number. The most significant 16 bits are
the major version number. The least 16 significant bits are
the major version number. The least 16 significant bits are
the minor version number.
the minor version number.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString64
LimString64
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The database name, defaults to the user name if empty.
The database name, defaults to the user name if empty.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString32
LimString32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The user name.
The user name.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString64
LimString64
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Any additional command line arguments to be passed to the
Any additional command line arguments to be passed to the
backend by the postmast
er.
backend child process by the serv
er.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString64
LimString64
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Unused.
Unused.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
LimString64
LimString64
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The optional tty the backend should use for debugging messages.
The optional tty the backend should use for debugging messages.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1855,11 +1838,11 @@ Terminate (F)
...
@@ -1855,11 +1838,11 @@ Terminate (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Byte1('X')
Byte1('X')
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
Identifies the message as a termination.
Identifies the message as a termination.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
@@ -1879,21 +1862,21 @@ UnencryptedPasswordPacket (F)
...
@@ -1879,21 +1862,21 @@ UnencryptedPasswordPacket (F)
<VariableList>
<VariableList>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
Int32
Int32
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The size of the packet in bytes.
The size of the packet in bytes.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
<VarListEntry>
<VarListEntry>
<Term>
<Term>
String
String
</Term>
</Term>
<ListItem>
<ListItem>
<Para>
<Para>
The unencrypted password.
The unencrypted password.
</Para>
</Para>
</ListItem>
</ListItem>
</VarListEntry>
</VarListEntry>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment