The reasoning for why all the message formats are parseable without
the explicit message length field is anachronistic; the real reason is
that protocol version 2 did not have a message length field. There's
nothing wrong with relying on the message length, like we do in the
CopyData messags, even though it often still makes sense to have
length fields for individual parts in messages.
Discussion: https://www.postgresql.org/message-id/
02a4eed2-98f0-4796-9d4f-
12128ff44fe0@iki.fi
indicate that it can be sent by a frontend (F), a backend (B), or both
(F & B).
Notice that although each message includes a byte count at the beginning,
- the message format is defined so that the message end can be found without
- reference to the byte count. This aids validity checking. (The CopyData
- message is an exception, because it forms part of a data stream; the contents
- of any individual CopyData message cannot be interpretable on their own.)
+ most messages are defined so that the message end can be found without
+ reference to the byte count. This is for historical reasons, as the
+ original, now-obsolete protocol version 2 did not have an explicit length
+ field. It also aids validity checking though.
</para>
<variablelist>