mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Remove server and libpq support for old FE/BE protocol version 2.
Protocol version 3 was introduced in PostgreSQL 7.4. There shouldn't be many clients or servers left out there without version 3 support. But as a courtesy, I kept just enough of the old protocol support that we can still send the "unsupported protocol version" error in v2 format, so that old clients can display the message properly. Likewise, libpq still understands v2 ErrorResponse messages when establishing a connection. The impetus to do this now is that I'm working on a patch to COPY FROM, to always prefetch some data. We cannot do that safely with the old protocol, because it requires parsing the input one byte at a time to detect the end-of-copy marker. Reviewed-by: Tom Lane, Alvaro Herrera, John Naylor Discussion: https://www.postgresql.org/message-id/9ec25819-0a8a-d51a-17dc-4150bb3cca3b%40iki.fi
This commit is contained in:
@ -484,9 +484,6 @@ pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
|
||||
* msg_type is the message type byte, or 0 for a message without type byte
|
||||
* (only startup messages have no type byte)
|
||||
*
|
||||
* force_len forces the message to have a length word; otherwise, we add
|
||||
* a length word if protocol 3.
|
||||
*
|
||||
* Returns 0 on success, EOF on error
|
||||
*
|
||||
* The idea here is that we construct the message in conn->outBuffer,
|
||||
@ -497,12 +494,11 @@ pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
|
||||
*
|
||||
* The state variable conn->outMsgStart points to the incomplete message's
|
||||
* length word: it is either outCount or outCount+1 depending on whether
|
||||
* there is a type byte. If we are sending a message without length word
|
||||
* (pre protocol 3.0 only), then outMsgStart is -1. The state variable
|
||||
* conn->outMsgEnd is the end of the data collected so far.
|
||||
* there is a type byte. The state variable conn->outMsgEnd is the end of
|
||||
* the data collected so far.
|
||||
*/
|
||||
int
|
||||
pqPutMsgStart(char msg_type, bool force_len, PGconn *conn)
|
||||
pqPutMsgStart(char msg_type, PGconn *conn)
|
||||
{
|
||||
int lenPos;
|
||||
int endPos;
|
||||
@ -514,14 +510,9 @@ pqPutMsgStart(char msg_type, bool force_len, PGconn *conn)
|
||||
endPos = conn->outCount;
|
||||
|
||||
/* do we want a length word? */
|
||||
if (force_len || PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
|
||||
{
|
||||
lenPos = endPos;
|
||||
/* allow room for message length */
|
||||
endPos += 4;
|
||||
}
|
||||
else
|
||||
lenPos = -1;
|
||||
lenPos = endPos;
|
||||
/* allow room for message length */
|
||||
endPos += 4;
|
||||
|
||||
/* make sure there is room for message header */
|
||||
if (pqCheckOutBufferSpace(endPos, conn))
|
||||
|
Reference in New Issue
Block a user