Remove useless code that propagated FrontendProtocol to a backend via a
authorTom Lane
Fri, 28 Aug 2009 18:23:53 +0000 (18:23 +0000)
committerTom Lane
Fri, 28 Aug 2009 18:23:53 +0000 (18:23 +0000)
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
src/backend/tcop/postgres.c
src/backend/utils/init/globals.c

index ff2ba13ef0b1b9c2266735d441aaae27fec1d07a..8ea5c18758814f0944a2cd43d169622b4d979b05 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.591 2009/08/28 17:42:54 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.592 2009/08/28 18:23:53 tgl Exp $
  *
  * NOTES
  *
@@ -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.
index 42e7f79f70fcb176df063c63fecfb21d5ded1d7d..79e5aa94204bdd41093dccbc9e1347ff0010939d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.569 2009/07/31 20:26:23 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.570 2009/08/28 18:23:53 tgl Exp $
  *
  * NOTES
  *   this is the "main" module of the postgres backend and
@@ -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;
index 6073e0709ac11e3ace7128dd47d82f8b0a275102..e4f5dfa5849088736c8f91a0ca12a5ae2e58ee81 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.108 2009/05/05 19:59:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.109 2009/08/28 18:23:53 tgl Exp $
  *
  * NOTES
  *   Globals used all over the place should be declared here and not
@@ -23,7 +23,7 @@
 #include "storage/backendid.h"
 
 
-ProtocolVersion FrontendProtocol = PG_PROTOCOL_LATEST;
+ProtocolVersion FrontendProtocol;
 
 volatile bool InterruptPending = false;
 volatile bool QueryCancelPending = false;