From: Bruce Momjian Date: Mon, 25 Aug 2014 20:30:26 +0000 (-0400) Subject: pg_ctl, pg_upgrade: allow multiple -o/-O options, append them X-Git-Tag: REL9_5_ALPHA1~1571 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebe30ad59bb2d127f576be07e036a473999c4b80;p=postgresql pg_ctl, pg_upgrade: allow multiple -o/-O options, append them Report by Pavel Raiskup --- diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c index bb594dd2f6..cfc88ec03b 100644 --- a/contrib/pg_upgrade/option.c +++ b/contrib/pg_upgrade/option.c @@ -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) diff --git a/doc/src/sgml/pgupgrade.sgml b/doc/src/sgml/pgupgrade.sgml index b79f0db7de..dd57c5ca5a 100644 --- a/doc/src/sgml/pgupgrade.sgml +++ b/doc/src/sgml/pgupgrade.sgml @@ -130,14 +130,16 @@ options options options to be passed directly to the - old postgres command + old postgres command; multiple + option invocations are appended options options options to be passed directly to the - new postgres command + new postgres command; multiple + option invocations are appended diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml index 23681294b8..29f882bd76 100644 --- a/doc/src/sgml/ref/pg_ctl-ref.sgml +++ b/doc/src/sgml/ref/pg_ctl-ref.sgml @@ -302,7 +302,8 @@ PostgreSQL documentation Specifies options to be passed directly to the - postgres command. + postgres command; multiple + option invocations are appended. The options should usually be surrounded by single or double diff --git a/doc/src/sgml/ref/postgres-ref.sgml b/doc/src/sgml/ref/postgres-ref.sgml index cdfdaa0b39..845d96940b 100644 --- a/doc/src/sgml/ref/postgres-ref.sgml +++ b/doc/src/sgml/ref/postgres-ref.sgml @@ -288,7 +288,8 @@ PostgreSQL documentation class="parameter">extra-options are passed to all server processes started by this postgres 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. diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index ad7f36cdd2..a46ca53ba6 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -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);