aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/pg_upgrade/dump.c6
-rw-r--r--contrib/pg_upgrade/option.c6
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h2
-rw-r--r--contrib/pg_upgrade/server.c27
4 files changed, 28 insertions, 13 deletions
diff --git a/contrib/pg_upgrade/dump.c b/contrib/pg_upgrade/dump.c
index f3060d54d1b..8e92d72e395 100644
--- a/contrib/pg_upgrade/dump.c
+++ b/contrib/pg_upgrade/dump.c
@@ -19,9 +19,9 @@ generate_old_dump(migratorContext *ctx)
* restores the frozenid's for databases and relations.
*/
exec_prog(ctx, true,
- SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --schema-only "
- "--binary-upgrade > \"%s/" ALL_DUMP_FILE "\"" SYSTEMQUOTE,
- ctx->new.bindir, ctx->old.port, ctx->cwd);
+ SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --username \"%s\" "
+ "--schema-only --binary-upgrade > \"%s/" ALL_DUMP_FILE "\""
+ SYSTEMQUOTE, ctx->new.bindir, ctx->old.port, ctx->user, ctx->cwd);
check_ok(ctx);
}
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index a38a9a80fff..58606dd2bf3 100644
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -174,12 +174,10 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
* start.
*/
/* truncate */
- ctx->log_fd = fopen(ctx->logfile, "w");
- if (!ctx->log_fd)
+ if ((ctx->log_fd = fopen(ctx->logfile, "w")) == NULL)
pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
fclose(ctx->log_fd);
- ctx->log_fd = fopen(ctx->logfile, "a");
- if (!ctx->log_fd)
+ if ((ctx->log_fd = fopen(ctx->logfile, "a")) == NULL)
pg_log(ctx, PG_FATAL, "Cannot write to log file %s\n", ctx->logfile);
}
else
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 34376047f7c..51b78a26249 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -48,7 +48,7 @@
#define pg_link_file win32_pghardlink
#define EXE_EXT ".exe"
#define sleep(x) Sleep(x * 1000)
-#define DEVNULL "nul"
+#define DEVNULL "nul"
/* "con" does not work from the Msys 1.0.10 console (part of MinGW). */
#define DEVTTY "con"
/* from pgport */
diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c
index 96a72b68764..9f6c9cb4181 100644
--- a/contrib/pg_upgrade/server.c
+++ b/contrib/pg_upgrade/server.c
@@ -177,12 +177,22 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
port = ctx->new.port;
}
- /* use -l for Win32 */
+ /*
+ * On Win32, we can't send both server output and pg_ctl output
+ * to the same file because we get the error:
+ * "The process cannot access the file because it is being used by another process."
+ * so we have to send pg_ctl output to 'nul'.
+ */
snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
"-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
"start >> \"%s\" 2>&1" SYSTEMQUOTE,
- bindir, ctx->logfile, datadir, port, ctx->logfile);
+ bindir, ctx->logfile, datadir, port,
+#ifndef WIN32
+ ctx->logfile);
+#else
+ DEVNULL);
+#endif
exec_prog(ctx, true, "%s", cmd);
/* wait for the server to start properly */
@@ -200,6 +210,7 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
void
stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
{
+ char cmd[MAXPGPATH];
const char *bindir;
const char *datadir;
@@ -216,10 +227,16 @@ stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
else
return; /* no cluster running */
- /* use -l for Win32 */
- exec_prog(ctx, fast ? false : true,
+ /* See comment in start_postmaster() about why win32 output is ignored. */
+ snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> \"%s\" 2>&1" SYSTEMQUOTE,
- bindir, ctx->logfile, datadir, fast ? "-m fast" : "", ctx->logfile);
+ bindir, ctx->logfile, datadir, fast ? "-m fast" : "",
+#ifndef WIN32
+ ctx->logfile);
+#else
+ DEVNULL);
+#endif
+ exec_prog(ctx, fast ? false : true, "%s", cmd);
ctx->postmasterPID = 0;
ctx->running_cluster = NONE;