Skip to content

Commit 8099bbc

Browse files
JelteFCommitfest Bot
authored andcommitted
docs: Update Protocol Changes checklist page for protocol 3.2
The docs already contained a page with protocol changes made by the introduction of protocol version 3.0 (introduced in Postgres 7.4). This commit adds the changes to this list which are introduced by protocol version 3.2 (introduced in Postgres 18). It also adds protocol changes that were done during the lifetime of protocol version 3.0 but which did not receive an associated version bump.
1 parent 4e23c9e commit 8099bbc

File tree

1 file changed

+138
-84
lines changed

1 file changed

+138
-84
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 138 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -7880,106 +7880,160 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
78807880
</sect1>
78817881

78827882
<sect1 id="protocol-changes">
7883-
<title>Summary of Changes since Protocol 2.0</title>
7883+
<title>Summary of Protocol Changes</title>
78847884

78857885
<para>
78867886
This section provides a quick checklist of changes, for the benefit of
7887-
developers trying to update existing client libraries to protocol 3.0.
7887+
developers trying to update existing client libraries to the most recent
7888+
protocol version.
78887889
</para>
78897890

7890-
<para>
7891-
The initial startup packet uses a flexible list-of-strings format
7892-
instead of a fixed format. Notice that session default values for run-time
7893-
parameters can now be specified directly in the startup packet. (Actually,
7894-
you could do that before using the <literal>options</literal> field, but given the
7895-
limited width of <literal>options</literal> and the lack of any way to quote
7896-
whitespace in the values, it wasn't a very safe technique.)
7897-
</para>
7891+
<sect2 id="protocol-changes-3.2">
7892+
<title>Protocol changes introduced in version 3.2</title>
78987893

7899-
<para>
7900-
All messages now have a length count immediately following the message type
7901-
byte (except for startup packets, which have no type byte). Also note that
7902-
PasswordMessage now has a type byte.
7903-
</para>
7894+
<para>
7895+
Protocol version 3.2 was introduced in <productname>PostgreSQL</productname> 18.
7896+
</para>
79047897

7905-
<para>
7906-
ErrorResponse and NoticeResponse ('<literal>E</literal>' and '<literal>N</literal>')
7907-
messages now contain multiple fields, from which the client code can
7908-
assemble an error message of the desired level of verbosity. Note that
7909-
individual fields will typically not end with a newline, whereas the single
7910-
string sent in the older protocol always did.
7911-
</para>
7898+
<para>
7899+
The BackendKeyData and CancelRequest messages were changed to allow a
7900+
variable size for the secret key instead of the 32-bit fixed size the
7901+
secret had before. The maximum size of the secret is now 256 bytes.
7902+
</para>
7903+
</sect2>
79127904

7913-
<para>
7914-
The ReadyForQuery ('<literal>Z</literal>') message includes a transaction status
7915-
indicator.
7916-
</para>
7905+
<sect2 id="protocol-changes-3.0-no-bump">
7906+
<title>Protocol changes introduced in version 3.0 without a protocol version bump</title>
79177907

7918-
<para>
7919-
The distinction between BinaryRow and DataRow message types is gone; the
7920-
single DataRow message type serves for returning data in all formats.
7921-
Note that the layout of DataRow has changed to make it easier to parse.
7922-
Also, the representation of binary values has changed: it is no longer
7923-
directly tied to the server's internal representation.
7924-
</para>
7908+
<para>
7909+
During the lifetime of protocol version 3.0 some changes to this protocol
7910+
version were made without bumping the protocol version. These changes are
7911+
listed below.
7912+
</para>
79257913

7926-
<para>
7927-
There is a new <quote>extended query</quote> sub-protocol, which adds the frontend
7928-
message types Parse, Bind, Execute, Describe, Close, Flush, and Sync, and the
7929-
backend message types ParseComplete, BindComplete, PortalSuspended,
7930-
ParameterDescription, NoData, and CloseComplete. Existing clients do not
7931-
have to concern themselves with this sub-protocol, but making use of it
7932-
might allow improvements in performance or functionality.
7933-
</para>
7914+
<para>
7915+
In <productname>PostgreSQL</productname> 9.3.21 the
7916+
NegotiateProtocolVersion message was introduced. This allows servers to
7917+
indicate to the client that it does not support the protocol version that
7918+
was requested by the client and that it wants to downgrade to a lower one.
7919+
</para>
79347920

7935-
<para>
7936-
<command>COPY</command> data is now encapsulated into CopyData and CopyDone messages. There
7937-
is a well-defined way to recover from errors during <command>COPY</command>. The special
7938-
<quote><literal>\.</literal></quote> last line is not needed anymore, and is not sent
7939-
during <command>COPY OUT</command>.
7940-
(It is still recognized as a terminator during text-mode <command>COPY
7941-
IN</command>, but not in CSV mode. The text-mode behavior is
7942-
deprecated and may eventually be removed.) Binary <command>COPY</command> is supported.
7943-
The CopyInResponse and CopyOutResponse messages include fields indicating
7944-
the number of columns and the format of each column.
7945-
</para>
7921+
<para>
7922+
In <productname>PostgreSQL</productname> 17 SSL negotiation was modified.
7923+
Before version 17 To initiate an SSL-encrypted connection, the frontend initially
7924+
sends an SSLRequest message rather than a StartupMessage. The server then responds
7925+
with a single byte containing S or N, indicating that it is willing or unwilling
7926+
to perform SSL, respectively. After which the frontend begins SSL negotiation
7927+
Starting in version 17 the server will also recognize connections which
7928+
immediately begin SSL negotiation without any previous SSLRequest packets
7929+
</para>
7930+
</sect2>
79467931

7947-
<para>
7948-
The layout of FunctionCall and FunctionCallResponse messages has changed.
7949-
FunctionCall can now support passing NULL arguments to functions. It also
7950-
can handle passing parameters and retrieving results in either text or
7951-
binary format. There is no longer any reason to consider FunctionCall a
7952-
potential security hole, since it does not offer direct access to internal
7953-
server data representations.
7954-
</para>
7932+
<sect2 id="protocol-changes-3.0">
7933+
<title>Protocol changes introduced in version 3.0</title>
79557934

7956-
<para>
7957-
The backend sends ParameterStatus ('<literal>S</literal>') messages during connection
7958-
startup for all parameters it considers interesting to the client library.
7959-
Subsequently, a ParameterStatus message is sent whenever the active value
7960-
changes for any of these parameters.
7961-
</para>
7935+
<para>
7936+
Protocol version 3.0 was introduced in
7937+
<productname>PostgreSQL</productname> 7.4. It introduced many changes
7938+
compared to the previous 2.0 protocol version. These changes are listed
7939+
below, although mostly for historical reasons, since protocol version 2.0
7940+
has not been supported by servers and clients for quite a long time.
7941+
</para>
79627942

7963-
<para>
7964-
The RowDescription ('<literal>T</literal>') message carries new table OID and column
7965-
number fields for each column of the described row. It also shows the format
7966-
code for each column.
7967-
</para>
7943+
<para>
7944+
The initial startup packet uses a flexible list-of-strings format
7945+
instead of a fixed format. Notice that session default values for run-time
7946+
parameters can now be specified directly in the startup packet. (Actually,
7947+
you could do that before using the <literal>options</literal> field, but given the
7948+
limited width of <literal>options</literal> and the lack of any way to quote
7949+
whitespace in the values, it wasn't a very safe technique.)
7950+
</para>
79687951

7969-
<para>
7970-
The CursorResponse ('<literal>P</literal>') message is no longer generated by
7971-
the backend.
7972-
</para>
7952+
<para>
7953+
All messages now have a length count immediately following the message type
7954+
byte (except for startup packets, which have no type byte). Also note that
7955+
PasswordMessage now has a type byte.
7956+
</para>
79737957

7974-
<para>
7975-
The NotificationResponse ('<literal>A</literal>') message has an additional string
7976-
field, which can carry a <quote>payload</quote> string passed
7977-
from the <command>NOTIFY</command> event sender.
7978-
</para>
7958+
<para>
7959+
ErrorResponse and NoticeResponse ('<literal>E</literal>' and '<literal>N</literal>')
7960+
messages now contain multiple fields, from which the client code can
7961+
assemble an error message of the desired level of verbosity. Note that
7962+
individual fields will typically not end with a newline, whereas the single
7963+
string sent in the older protocol always did.
7964+
</para>
79797965

7980-
<para>
7981-
The EmptyQueryResponse ('<literal>I</literal>') message used to include an empty
7982-
string parameter; this has been removed.
7983-
</para>
7966+
<para>
7967+
The ReadyForQuery ('<literal>Z</literal>') message includes a transaction status
7968+
indicator.
7969+
</para>
7970+
7971+
<para>
7972+
The distinction between BinaryRow and DataRow message types is gone; the
7973+
single DataRow message type serves for returning data in all formats.
7974+
Note that the layout of DataRow has changed to make it easier to parse.
7975+
Also, the representation of binary values has changed: it is no longer
7976+
directly tied to the server's internal representation.
7977+
</para>
7978+
7979+
<para>
7980+
There is a new <quote>extended query</quote> sub-protocol, which adds the frontend
7981+
message types Parse, Bind, Execute, Describe, Close, Flush, and Sync, and the
7982+
backend message types ParseComplete, BindComplete, PortalSuspended,
7983+
ParameterDescription, NoData, and CloseComplete. Existing clients do not
7984+
have to concern themselves with this sub-protocol, but making use of it
7985+
might allow improvements in performance or functionality.
7986+
</para>
7987+
7988+
<para>
7989+
<command>COPY</command> data is now encapsulated into CopyData and CopyDone messages. There
7990+
is a well-defined way to recover from errors during <command>COPY</command>. The special
7991+
<quote><literal>\.</literal></quote> last line is not needed anymore, and is not sent
7992+
during <command>COPY OUT</command>.
7993+
(It is still recognized as a terminator during text-mode <command>COPY
7994+
IN</command>, but not in CSV mode. The text-mode behavior is
7995+
deprecated and may eventually be removed.) Binary <command>COPY</command> is supported.
7996+
The CopyInResponse and CopyOutResponse messages include fields indicating
7997+
the number of columns and the format of each column.
7998+
</para>
7999+
8000+
<para>
8001+
The layout of FunctionCall and FunctionCallResponse messages has changed.
8002+
FunctionCall can now support passing NULL arguments to functions. It also
8003+
can handle passing parameters and retrieving results in either text or
8004+
binary format. There is no longer any reason to consider FunctionCall a
8005+
potential security hole, since it does not offer direct access to internal
8006+
server data representations.
8007+
</para>
8008+
8009+
<para>
8010+
The backend sends ParameterStatus ('<literal>S</literal>') messages during connection
8011+
startup for all parameters it considers interesting to the client library.
8012+
Subsequently, a ParameterStatus message is sent whenever the active value
8013+
changes for any of these parameters.
8014+
</para>
8015+
8016+
<para>
8017+
The RowDescription ('<literal>T</literal>') message carries new table OID and column
8018+
number fields for each column of the described row. It also shows the format
8019+
code for each column.
8020+
</para>
8021+
8022+
<para>
8023+
The CursorResponse ('<literal>P</literal>') message is no longer generated by
8024+
the backend.
8025+
</para>
8026+
8027+
<para>
8028+
The NotificationResponse ('<literal>A</literal>') message has an additional string
8029+
field, which can carry a <quote>payload</quote> string passed
8030+
from the <command>NOTIFY</command> event sender.
8031+
</para>
8032+
8033+
<para>
8034+
The EmptyQueryResponse ('<literal>I</literal>') message used to include an empty
8035+
string parameter; this has been removed.
8036+
</para>
8037+
</sect2>
79848038
</sect1>
79858039
</chapter>

0 commit comments

Comments
 (0)