Re: pg_upgrade defaulting to port 25432 - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: pg_upgrade defaulting to port 25432
Date
Msg-id 201106271759.p5RHx7s03904@momjian.us
Whole thread Raw
In response to Re: pg_upgrade defaulting to port 25432  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: pg_upgrade defaulting to port 25432
List pgsql-hackers
Robert Haas wrote:
> On Mon, Jun 27, 2011 at 1:49 PM, Bruce Momjian <bruce@momjian.us> wrote:
> > OK, fair enough. ?Should I apply my ports patch to Postgres 9.2?
>
> I'm not sure which patch you are referring to.

This one which makes 50432 the default port.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
new file mode 100644
index 1ee2aca..5c5ce72
*** a/contrib/pg_upgrade/check.c
--- b/contrib/pg_upgrade/check.c
*************** output_check_banner(bool *live_check)
*** 29,34 ****
--- 29,37 ----
      if (user_opts.check && is_server_running(old_cluster.pgdata))
      {
          *live_check = true;
+         if (old_cluster.port == DEF_PGUPORT)
+             pg_log(PG_FATAL, "When checking a live old server, "
+                    "you must specify the old server's port number.\n");
          if (old_cluster.port == new_cluster.port)
              pg_log(PG_FATAL, "When checking a live server, "
                     "the old and new port numbers must be different.\n");
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
new file mode 100644
index 4401a81..d29aad0
*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
*************** parseCommandLine(int argc, char *argv[])
*** 58,65 ****
      os_info.progname = get_progname(argv[0]);

      /* Process libpq env. variables; load values here for usage() output */
!     old_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;
!     new_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;

      os_user_effective_id = get_user_info(&os_info.user);
      /* we override just the database user name;  we got the OS id above */
--- 58,65 ----
      os_info.progname = get_progname(argv[0]);

      /* Process libpq env. variables; load values here for usage() output */
!     old_cluster.port = getenv("PGPORTOLD") ? atoi(getenv("PGPORTOLD")) : DEF_PGUPORT;
!     new_cluster.port = getenv("PGPORTNEW") ? atoi(getenv("PGPORTNEW")) : DEF_PGUPORT;

      os_user_effective_id = get_user_info(&os_info.user);
      /* we override just the database user name;  we got the OS id above */
*************** parseCommandLine(int argc, char *argv[])
*** 203,215 ****
      }

      /* Get values from env if not already set */
!     check_required_directory(&old_cluster.bindir, "OLDBINDIR", "-b",
                              "old cluster binaries reside");
!     check_required_directory(&new_cluster.bindir, "NEWBINDIR", "-B",
                              "new cluster binaries reside");
!     check_required_directory(&old_cluster.pgdata, "OLDDATADIR", "-d",
                              "old cluster data resides");
!     check_required_directory(&new_cluster.pgdata, "NEWDATADIR", "-D",
                              "new cluster data resides");
  }

--- 203,215 ----
      }

      /* Get values from env if not already set */
!     check_required_directory(&old_cluster.bindir, "PGBINOLD", "-b",
                              "old cluster binaries reside");
!     check_required_directory(&new_cluster.bindir, "PGBINNEW", "-B",
                              "new cluster binaries reside");
!     check_required_directory(&old_cluster.pgdata, "PGDATAOLD", "-d",
                              "old cluster data resides");
!     check_required_directory(&new_cluster.pgdata, "PGDATANEW", "-D",
                              "new cluster data resides");
  }

*************** For example:\n\
*** 254,270 ****
  or\n"), old_cluster.port, new_cluster.port, os_info.user);
  #ifndef WIN32
      printf(_("\
!   $ export OLDDATADIR=oldCluster/data\n\
!   $ export NEWDATADIR=newCluster/data\n\
!   $ export OLDBINDIR=oldCluster/bin\n\
!   $ export NEWBINDIR=newCluster/bin\n\
    $ pg_upgrade\n"));
  #else
      printf(_("\
!   C:\\> set OLDDATADIR=oldCluster/data\n\
!   C:\\> set NEWDATADIR=newCluster/data\n\
!   C:\\> set OLDBINDIR=oldCluster/bin\n\
!   C:\\> set NEWBINDIR=newCluster/bin\n\
    C:\\> pg_upgrade\n"));
  #endif
      printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
--- 254,270 ----
  or\n"), old_cluster.port, new_cluster.port, os_info.user);
  #ifndef WIN32
      printf(_("\
!   $ export PGDATAOLD=oldCluster/data\n\
!   $ export PGDATANEW=newCluster/data\n\
!   $ export PGBINOLD=oldCluster/bin\n\
!   $ export PGBINNEW=newCluster/bin\n\
    $ pg_upgrade\n"));
  #else
      printf(_("\
!   C:\\> set PGDATAOLD=oldCluster/data\n\
!   C:\\> set PGDATANEW=newCluster/data\n\
!   C:\\> set PGBINOLD=oldCluster/bin\n\
!   C:\\> set PGBINNEW=newCluster/bin\n\
    C:\\> pg_upgrade\n"));
  #endif
      printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 613ddbd..4729ac3
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
***************
*** 15,20 ****
--- 15,23 ----

  #include "libpq-fe.h"

+ /* Use port in the private/dynamic port number range */
+ #define DEF_PGUPORT            50432
+
  /* Allocate for null byte */
  #define USER_NAME_SIZE        128

diff --git a/doc/src/sgml/pgupgrade.sgml b/doc/src/sgml/pgupgrade.sgml
new file mode 100644
index b24c1e7..aa633e2
*** a/doc/src/sgml/pgupgrade.sgml
--- b/doc/src/sgml/pgupgrade.sgml
***************
*** 60,73 ****
        <term><option>-b</option> <replaceable>old_bindir</></term>
        <term><option>--old-bindir=</option><replaceable>old_bindir</></term>
        <listitem><para>the old cluster executable directory;
!       environment variable <envar>OLDBINDIR</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-B</option> <replaceable>new_bindir</></term>
        <term><option>--new-bindir=</option><replaceable>new_bindir</></term>
        <listitem><para>the new cluster executable directory;
!       environment variable <envar>NEWBINDIR</></para></listitem>
       </varlistentry>

       <varlistentry>
--- 60,73 ----
        <term><option>-b</option> <replaceable>old_bindir</></term>
        <term><option>--old-bindir=</option><replaceable>old_bindir</></term>
        <listitem><para>the old cluster executable directory;
!       environment variable <envar>PGBINOLD</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-B</option> <replaceable>new_bindir</></term>
        <term><option>--new-bindir=</option><replaceable>new_bindir</></term>
        <listitem><para>the new cluster executable directory;
!       environment variable <envar>PGBINNEW</></para></listitem>
       </varlistentry>

       <varlistentry>
***************
*** 80,93 ****
        <term><option>-d</option> <replaceable>old_datadir</></term>
        <term><option>--old-datadir=</option><replaceable>old_datadir</></term>
        <listitem><para>the old cluster data directory; environment
!       variable <envar>OLDDATADIR</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-D</option> <replaceable>new_datadir</></term>
        <term><option>--new-datadir=</option><replaceable>new_datadir</></term>
        <listitem><para>the new cluster data directory; environment
!       variable <envar>NEWDATADIR</></para></listitem>
       </varlistentry>

       <varlistentry>
--- 80,93 ----
        <term><option>-d</option> <replaceable>old_datadir</></term>
        <term><option>--old-datadir=</option><replaceable>old_datadir</></term>
        <listitem><para>the old cluster data directory; environment
!       variable <envar>PGDATAOLD</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-D</option> <replaceable>new_datadir</></term>
        <term><option>--new-datadir=</option><replaceable>new_datadir</></term>
        <listitem><para>the new cluster data directory; environment
!       variable <envar>PGDATANEW</></para></listitem>
       </varlistentry>

       <varlistentry>
***************
*** 118,131 ****
        <term><option>-p</option> <replaceable>old_port_number</></term>
        <term><option>--old-port=</option><replaceable>old_portnum</></term>
        <listitem><para>the old cluster port number; environment
!       variable <envar>PGPORT</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-P</option> <replaceable>new_port_number</></term>
        <term><option>--new-port=</option><replaceable>new_portnum</></term>
        <listitem><para>the new cluster port number; environment
!       variable <envar>PGPORT</></para></listitem>
       </varlistentry>

       <varlistentry>
--- 118,131 ----
        <term><option>-p</option> <replaceable>old_port_number</></term>
        <term><option>--old-port=</option><replaceable>old_portnum</></term>
        <listitem><para>the old cluster port number; environment
!       variable <envar>PGPORTOLD</></para></listitem>
       </varlistentry>

       <varlistentry>
        <term><option>-P</option> <replaceable>new_port_number</></term>
        <term><option>--new-port=</option><replaceable>new_portnum</></term>
        <listitem><para>the new cluster port number; environment
!       variable <envar>PGPORTNEW</></para></listitem>
       </varlistentry>

       <varlistentry>
*************** gmake prefix=/usr/local/pgsql.new instal
*** 256,263 ****
       so you might want to set authentication to <literal>trust</> in
       <filename>pg_hba.conf</>, or if using <literal>md5</> authentication,
       use a <filename>~/.pgpass</> file (see <xref linkend="libpq-pgpass">)
!      to avoid being prompted repeatedly for a password.  Also make sure
!      pg_upgrade is the only program that can connect to the clusters.
      </para>
     </step>

--- 256,262 ----
       so you might want to set authentication to <literal>trust</> in
       <filename>pg_hba.conf</>, or if using <literal>md5</> authentication,
       use a <filename>~/.pgpass</> file (see <xref linkend="libpq-pgpass">)
!      to avoid being prompted repeatedly for a password.
      </para>
     </step>

*************** NET STOP pgsql-8.3  (<productname>Postgr
*** 303,311 ****
       copying), but you will not be able to access your old cluster
       once you start the new cluster after the upgrade.  Link mode also
       requires that the old and new cluster data directories be in the
!      same file system.  See <literal>pg_upgrade --help</> for a full
!      list of options.
!     </para>

      <para>
       For Windows users, you must be logged into an administrative account, and
--- 302,315 ----
       copying), but you will not be able to access your old cluster
       once you start the new cluster after the upgrade.  Link mode also
       requires that the old and new cluster data directories be in the
!      same file system.
!    </para>
!
!    <para>
!     <application>pg_upgrade</> defaults to running servers on port
!     50432 to avoid unintended client connections.  See <literal>pg_upgrade
!     --help</> for a full list of options.
!    </para>

      <para>
       For Windows users, you must be logged into an administrative account, and

pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: generate_series() Interpretation
Next
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Make the visibility map crash-safe.