On Thu, May 30, 2013 at 08:42:21AM -0400, Ray Stell wrote: > > On May 29, 2013, at 11:07 AM, Bruce Momjian wrote: > > > On Wed, May 29, 2013 at 08:59:42AM -0400, Ray Stell wrote: > >>> [ moved to hacker ] The question is whether hard-wiring these > >>> helps more than it hurts, and which ones should be hard-wired. > > I seems to me that superuser is exactly that special case and that if > an alternate superuser is hardwired in the src cluster then -u/-U and > that specific value will be required on both sides of pg_upgrade, no > variability is needed and perhaps not possible. You're point is well > taken for port.
You have convinced me. The attached, applied patch for PG 9.4 passes the command-line-supplied username into the created analyze script. I have also attached a sample output analyze script. -- Bruce Momjian <[email protected]> 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 1f67e60..0376fcb
*** a/contrib/pg_upgrade/check.c
--- b/contrib/pg_upgrade/check.c
*************** void
*** 459,464 ****
--- 459,471 ----
create_script_for_cluster_analyze(char **analyze_script_file_name)
{
FILE *script = NULL;
+ char *user_specification = "";
+
+ if (os_info.user_specified)
+ {
+ user_specification = pg_malloc(strlen(os_info.user) + 7);
+ sprintf(user_specification, "-U \"%s\" ", os_info.user);
+ }
*analyze_script_file_name = pg_malloc(MAXPGPATH);
*************** create_script_for_cluster_analyze(char *
*** 501,507 ****
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %sthis script and run:%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "echo %s \"%s/vacuumdb\" --all %s%s\n", ECHO_QUOTE, new_cluster.bindir,
/* Did we copy the free space files? */
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
"--analyze-only" : "--analyze", ECHO_QUOTE);
--- 508,515 ----
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %sthis script and run:%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "echo %s \"%s/vacuumdb\" %s--all %s%s\n", ECHO_QUOTE,
! new_cluster.bindir, user_specification,
/* Did we copy the free space files? */
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
"--analyze-only" : "--analyze", ECHO_QUOTE);
*************** create_script_for_cluster_analyze(char *
*** 522,528 ****
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s--------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" --all --analyze-only\n", new_cluster.bindir);
fprintf(script, "echo%s\n", ECHO_BLANK);
fprintf(script, "echo %sThe server is now available with minimal optimizer statistics.%s\n",
ECHO_QUOTE, ECHO_QUOTE);
--- 530,537 ----
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s--------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" %s--all --analyze-only\n",
! new_cluster.bindir, user_specification);
fprintf(script, "echo%s\n", ECHO_BLANK);
fprintf(script, "echo %sThe server is now available with minimal optimizer statistics.%s\n",
ECHO_QUOTE, ECHO_QUOTE);
*************** create_script_for_cluster_analyze(char *
*** 543,549 ****
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s---------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" --all --analyze-only\n", new_cluster.bindir);
fprintf(script, "echo%s\n\n", ECHO_BLANK);
#ifndef WIN32
--- 552,559 ----
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s---------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" %s--all --analyze-only\n",
! new_cluster.bindir, user_specification);
fprintf(script, "echo%s\n\n", ECHO_BLANK);
#ifndef WIN32
*************** create_script_for_cluster_analyze(char *
*** 556,562 ****
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s-------------------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" --all %s\n", new_cluster.bindir,
/* Did we copy the free space files? */
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
"--analyze-only" : "--analyze");
--- 566,573 ----
ECHO_QUOTE, ECHO_QUOTE);
fprintf(script, "echo %s-------------------------------------------------------------%s\n",
ECHO_QUOTE, ECHO_QUOTE);
! fprintf(script, "\"%s/vacuumdb\" %s--all %s\n", new_cluster.bindir,
! user_specification,
/* Did we copy the free space files? */
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
"--analyze-only" : "--analyze");
*************** create_script_for_cluster_analyze(char *
*** 573,578 ****
--- 584,592 ----
*analyze_script_file_name, getErrorText(errno));
#endif
+ if (os_info.user_specified)
+ pg_free(user_specification);
+
check_ok();
}
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
new file mode 100644
index dee58ee..2774b1e
*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
*************** parseCommandLine(int argc, char *argv[])
*** 172,177 ****
--- 172,178 ----
case 'U':
pg_free(os_info.user);
os_info.user = pg_strdup(optarg);
+ os_info.user_specified = true;
/*
* Push the user name into the environment so pre-9.1
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
new file mode 100644
index 0d44f4e..0b3ad20
*** a/contrib/pg_upgrade/pg_upgrade.h
--- b/contrib/pg_upgrade/pg_upgrade.h
*************** typedef struct
*** 291,296 ****
--- 291,297 ----
const char *progname; /* complete pathname for this program */
char *exec_path; /* full path to my executable */
char *user; /* username for clusters */
+ bool user_specified; /* user specified on command-line */
char **old_tablespaces; /* tablespaces */
int num_old_tablespaces;
char **libraries; /* loadable libraries */
analyze_new_cluster.sh
Description: Bourne shell script
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
