From e50ba34ee36ce12cfa56a0040b90477620324765 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 28 Aug 2009 18:23:53 +0000 Subject: [PATCH] Remove useless code that propagated FrontendProtocol to a backend via a PostgresMain switch. In point of fact, FrontendProtocol is already set in a backend process, since ProcessStartupPacket() is executed inside the backend --- it hasn't been run by the postmaster for many years. And if it were, we'd still certainly want FrontendProtocol to be set before we get as far as PostgresMain, so that startup errors get reported in the right protocol. -v might have some future use in standalone backends, so I didn't go so far as to remove the switch outright. Also, initialize FrontendProtocol to 0 not PG_PROTOCOL_LATEST. The only likely result of presetting it like that is to mask failure-to-set-it mistakes. --- src/backend/postmaster/postmaster.c | 5 ----- src/backend/tcop/postgres.c | 7 +++++++ src/backend/utils/init/globals.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 785668e7f0..5884e2dc07 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3353,7 +3353,6 @@ BackendRun(Port *port) int ac; long secs; int usecs; - char protobuf[32]; int i; /* @@ -3397,10 +3396,6 @@ BackendRun(Port *port) */ split_opts(av, &ac, ExtraOptions); - /* Tell the backend what protocol the frontend is using. */ - snprintf(protobuf, sizeof(protobuf), "-v%u", port->proto); - av[ac++] = protobuf; - /* * Tell the backend it is being called from the postmaster, and which * database to use. -y marks the end of secure switches. diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 2beb148d98..a77abdcfc5 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3075,6 +3075,13 @@ PostgresMain(int argc, char *argv[], const char *username) } case 'v': + /* + * -v is no longer used in normal operation, since + * FrontendProtocol is already set before we get here. + * We keep the switch only for possible use in standalone + * operation, in case we ever support using normal FE/BE + * protocol with a standalone backend. + */ if (secure) FrontendProtocol = (ProtocolVersion) atoi(optarg); break; diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 962f4ba517..a77e5d82bf 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -23,7 +23,7 @@ #include "storage/backendid.h" -ProtocolVersion FrontendProtocol = PG_PROTOCOL_LATEST; +ProtocolVersion FrontendProtocol; volatile bool InterruptPending = false; volatile bool QueryCancelPending = false; -- 2.30.2