]> granicus.if.org Git - postgresql/commitdiff
pg_ctl, pg_upgrade: allow multiple -o/-O options, append them
authorBruce Momjian <bruce@momjian.us>
Mon, 25 Aug 2014 20:30:26 +0000 (16:30 -0400)
committerBruce Momjian <bruce@momjian.us>
Mon, 25 Aug 2014 20:30:26 +0000 (16:30 -0400)
Report by Pavel Raiskup

contrib/pg_upgrade/option.c
doc/src/sgml/pgupgrade.sgml
doc/src/sgml/ref/pg_ctl-ref.sgml
doc/src/sgml/ref/postgres-ref.sgml
src/bin/pg_ctl/pg_ctl.c

index bb594dd2f6938c575c776514017ec1ed3d05cdee..cfc88ec03be63daf30480e0fb6e08ed20fa426a3 100644 (file)
@@ -137,17 +137,35 @@ parseCommandLine(int argc, char *argv[])
                                break;
 
                        case 'o':
-                               old_cluster.pgopts = pg_strdup(optarg);
+                               /* append option? */
+                               if (!old_cluster.pgopts)
+                                       old_cluster.pgopts = pg_strdup(optarg);
+                               else
+                               {
+                                       char *old_pgopts = old_cluster.pgopts;
+
+                                       old_cluster.pgopts = psprintf("%s %s", old_pgopts, optarg);
+                                       free(old_pgopts);
+                               }
                                break;
 
                        case 'O':
-                               new_cluster.pgopts = pg_strdup(optarg);
+                               /* append option? */
+                               if (!new_cluster.pgopts)
+                                       new_cluster.pgopts = pg_strdup(optarg);
+                               else
+                               {
+                                       char *new_pgopts = new_cluster.pgopts;
+
+                                       new_cluster.pgopts = psprintf("%s %s", new_pgopts, optarg);
+                                       free(new_pgopts);
+                               }
                                break;
 
                                /*
                                 * Someday, the port number option could be removed and passed
                                 * using -o/-O, but that requires postmaster -C to be
-                                * supported on all old/new versions.
+                                * supported on all old/new versions (added in PG 9.2).
                                 */
                        case 'p':
                                if ((old_cluster.port = atoi(optarg)) <= 0)
index b79f0db7de4d862880cad16440ff9bb00a6bba97..dd57c5ca5ad43fe3975cac3baef27d419c4d1191 100644 (file)
       <term><option>-o</option> <replaceable class="parameter">options</replaceable></term>
       <term><option>--old-options</option> <replaceable class="parameter">options</replaceable></term>
       <listitem><para>options to be passed directly to the
-      old <command>postgres</command> command</para></listitem>
+      old <command>postgres</command> command;  multiple
+      option invocations are appended</para></listitem>
      </varlistentry>
 
      <varlistentry>
       <term><option>-O</option> <replaceable class="parameter">options</replaceable></term>
       <term><option>--new-options</option> <replaceable class="parameter">options</replaceable></term>
       <listitem><para>options to be passed directly to the
-      new <command>postgres</command> command</para></listitem>
+      new <command>postgres</command> command;  multiple
+      option invocations are appended</para></listitem>
      </varlistentry>
 
      <varlistentry>
index 23681294b87d767f5d085936ac482bec743c26d5..29f882bd76e2dfe21257809d80a4324edb98928d 100644 (file)
@@ -302,7 +302,8 @@ PostgreSQL documentation
       <listitem>
        <para>
         Specifies options to be passed directly to the
-        <command>postgres</command> command.
+        <command>postgres</command> command;  multiple
+        option invocations are appended.
        </para>
        <para>
         The options should usually be surrounded by single or double
index cdfdaa0b397ade839cf9274403f7002e5659ff0a..845d96940b045c8bce562862b1f5edf5d99368be 100644 (file)
@@ -288,7 +288,8 @@ PostgreSQL documentation
         class="parameter">extra-options</replaceable> are passed to
         all server processes started by this
         <command>postgres</command> process.  If the option string contains
-        any spaces, the entire string must be quoted.
+        any spaces, the entire string must be quoted;  multiple
+        option invocations are appended.
        </para>
 
        <para>
index ad7f36cdd2bed355848507607cb9758445287a01..a46ca53ba6e16b3916a63b6225077694ee84563c 100644 (file)
@@ -2184,7 +2184,16 @@ main(int argc, char **argv)
                                        register_servicename = pg_strdup(optarg);
                                        break;
                                case 'o':
-                                       post_opts = pg_strdup(optarg);
+                                       /* append option? */
+                                       if (!post_opts)
+                                               post_opts = pg_strdup(optarg);
+                                       else
+                                       {
+                                               char *old_post_opts = post_opts;
+
+                                               post_opts = psprintf("%s %s", old_post_opts, optarg);
+                                               free(old_post_opts);
+                                       }
                                        break;
                                case 'p':
                                        exec_path = pg_strdup(optarg);