diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-03-04 10:45:55 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-03-04 10:45:55 +0200 |
commit | 3174d69fb96a66173224e60ec7053b988d5ed4d9 (patch) | |
tree | 2dbeb5e94ccfde05b8d40a15b88e1107220fb9b1 /src/backend/tcop/postgres.c | |
parent | 0a687c8f103d217ff1ca8c34a644b380d89bb0ad (diff) | |
download | postgresql-3174d69fb96a66173224e60ec7053b988d5ed4d9.tar.gz postgresql-3174d69fb96a66173224e60ec7053b988d5ed4d9.zip |
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
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index bb5ccb4578b..8a0332dde9d 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -370,57 +370,10 @@ SocketBackend(StringInfo inBuf) { case 'Q': /* simple query */ doing_extended_query_message = false; - if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) - { - /* old style without length word; convert */ - if (pq_getstring(inBuf)) - { - if (IsTransactionState()) - ereport(COMMERROR, - (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection with an open transaction"))); - else - { - /* - * Can't send DEBUG log messages to client at this - * point. Since we're disconnecting right away, we - * don't need to restore whereToSendOutput. - */ - whereToSendOutput = DestNone; - ereport(DEBUG1, - (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), - errmsg_internal("unexpected EOF on client connection"))); - } - return EOF; - } - } break; case 'F': /* fastpath function call */ doing_extended_query_message = false; - if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) - { - if (GetOldFunctionMessage(inBuf)) - { - if (IsTransactionState()) - ereport(COMMERROR, - (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection with an open transaction"))); - else - { - /* - * Can't send DEBUG log messages to client at this - * point. Since we're disconnecting right away, we - * don't need to restore whereToSendOutput. - */ - whereToSendOutput = DestNone; - ereport(DEBUG1, - (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), - errmsg_internal("unexpected EOF on client connection"))); - } - return EOF; - } - } break; case 'X': /* terminate */ @@ -435,11 +388,6 @@ SocketBackend(StringInfo inBuf) case 'H': /* flush */ case 'P': /* parse */ doing_extended_query_message = true; - /* these are only legal in protocol 3 */ - if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) - ereport(FATAL, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); break; case 'S': /* sync */ @@ -447,22 +395,12 @@ SocketBackend(StringInfo inBuf) ignore_till_sync = false; /* mark not-extended, so that a new error doesn't begin skip */ doing_extended_query_message = false; - /* only legal in protocol 3 */ - if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) - ereport(FATAL, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); break; case 'd': /* copy data */ case 'c': /* copy done */ case 'f': /* copy fail */ doing_extended_query_message = false; - /* these are only legal in protocol 3 */ - if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) - ereport(FATAL, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); break; default: @@ -483,13 +421,8 @@ SocketBackend(StringInfo inBuf) * after the type code; we can read the message contents independently of * the type. */ - if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) - { - if (pq_getmessage(inBuf, 0)) - return EOF; /* suitable message already logged */ - } - else - pq_endmsgread(); + if (pq_getmessage(inBuf, 0)) + return EOF; /* suitable message already logged */ RESUME_CANCEL_INTERRUPTS(); return qtype; |