Hello,
RFE: Consider that you want to run pg_upgrade via some script with some
default '-o' option. But then you also want to give the script's user a
chance to specify the old-server's options according user's needs.
Then something like the following is not possible:
$ cat script
...
pg_upgrade ... -o 'sth' $PG_UPGRADE_OPT ...
...
I know that this problem is still script-able, but the fix should be
innocent and it would simplify things. Thanks for considering,
Pavel
>From 44ac4867a6fb67ab086ba22db8d0ad2788e9860e Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Tue, 4 Mar 2014 15:58:16 +0100
Subject: [PATCH] pg_upgrade: allow passing multiple -o/-O options
The final options passed to subsequent servers are concatenated
from particular option arguments.
---
contrib/pg_upgrade/option.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
new file mode 100644
index cd9f66d..d3d2460
*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
***************
*** 25,30 ****
--- 25,31 ----
static void usage(void);
static void check_required_directory(char **dirpath, char **configpath,
char *envVarName, char *cmdLineOption, char *description);
+ static void append_opt(char **str, const char *str2);
#define FIX_DEFAULT_READ_ONLY "-c default_transaction_read_only=false"
*************** parseCommandLine(int argc, char *argv[])
*** 138,148 ****
break;
case 'o':
! old_cluster.pgopts = pg_strdup(optarg);
break;
case 'O':
! new_cluster.pgopts = pg_strdup(optarg);
break;
/*
--- 139,149 ----
break;
case 'o':
! append_opt(&old_cluster.pgopts, optarg);
break;
case 'O':
! append_opt(&new_cluster.pgopts, optarg);
break;
/*
*************** parseCommandLine(int argc, char *argv[])
*** 232,237 ****
--- 233,252 ----
}
+ static void
+ append_opt(char **str, const char *str2)
+ {
+ if (!*str)
+ *str = pg_strdup(str2);
+ else
+ {
+ *str = pg_realloc(*str, strlen(*str) + strlen(str2) + 2);
+ strcat(*str, " ");
+ strcat(*str, str2);
+ }
+ }
+
+
static void
usage(void)
{
--
1.8.5.3
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers