"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user,
- sequence_script_file_name, log_opts.filename);
+ sequence_script_file_name, log_opts.filename2);
unlink(sequence_script_file_name);
check_ok();
}
pg_log(PG_FATAL, "cannot write to log file %s\n", log_opts.filename);
}
else
- log_opts.filename = strdup(DEVNULL);
+ log_opts.filename = pg_strdup(DEVNULL);
+ /* WIN32 files do not accept writes from multiple processes */
+#ifndef WIN32
+ log_opts.filename2 = pg_strdup(log_opts.filename);
+#else
+ log_opts.filename2 = pg_strdup(DEVNULL);
+#endif
+
/* if no debug file name, output to the terminal */
if (log_opts.debug && !log_opts.debug_fd)
{
prep_status("Analyzing all rows in the new cluster");
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
- "--all --analyze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+ "--all --analyze >> \"%s\" 2>&1" SYSTEMQUOTE,
+ new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename2);
check_ok();
/*
prep_status("Freezing all rows on the new cluster");
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
- "--all --freeze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+ "--all --freeze >> \"%s\" 2>&1" SYSTEMQUOTE,
+ new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename2);
check_ok();
get_pg_database_relfilenode(&new_cluster);
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
- GLOBALS_DUMP_FILE, log_opts.filename);
+ GLOBALS_DUMP_FILE, log_opts.filename2);
check_ok();
/* we load this to get a current list of databases */
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
- DB_DUMP_FILE, log_opts.filename);
+ DB_DUMP_FILE, log_opts.filename2);
check_ok();
/* regenerate now that we have objects in the databases */
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -l %u,%u,%u \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
new_cluster.bindir, old_cluster.controldata.chkpnt_tli,
old_cluster.controldata.logid, old_cluster.controldata.nxtlogseg,
- new_cluster.pgdata, log_opts.filename);
+ new_cluster.pgdata, log_opts.filename2);
check_ok();
}
typedef struct
{
char *filename; /* name of log file (may be /dev/null) */
+ /*
+ * WIN32 files do not accept writes from multiple processes
+ *
+ * On Win32, we can't send both pg_upgrade output and command 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 all
+ * other output to 'nul'. Therefore, we set this to DEVNULL on Win32, and
+ * it equals 'filename' on all other platforms.
+ */
+ char *filename2;
FILE *fd; /* log FILE */
bool debug; /* TRUE -> log more information */
FILE *debug_fd; /* debug-level log FILE */
bool exit_hook_registered = false;
int pg_ctl_return = 0;
-#ifndef WIN32
- char *output_filename = log_opts.filename;
-#else
-
- /*
- * On Win32, we can't send both pg_upgrade 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 all
- * other output to 'nul'.
- */
- char *output_filename = DEVNULL;
-#endif
-
if (!exit_hook_registered)
{
#ifdef HAVE_ATEXIT
snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" "
"-o \"-p %d %s\" start >> \"%s\" 2>&1" SYSTEMQUOTE,
- cluster->bindir, output_filename, cluster->pgdata, cluster->port,
+ cluster->bindir, log_opts.filename2, cluster->pgdata, cluster->port,
(cluster->controldata.cat_ver >=
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
- log_opts.filename);
+ log_opts.filename2);
/*
* Don't throw an error right away, let connecting throw the error because
const char *bindir;
const char *datadir;
-#ifndef WIN32
- char *output_filename = log_opts.filename;
-#else
- /* See comment in start_postmaster() about why win32 output is ignored. */
- char *output_filename = DEVNULL;
-#endif
-
if (os_info.running_cluster == &old_cluster)
{
bindir = old_cluster.bindir;
snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" %s stop >> "
"\"%s\" 2>&1" SYSTEMQUOTE,
- bindir, output_filename, datadir, fast ? "-m fast" : "",
- output_filename);
+ bindir, log_opts.filename2, datadir, fast ? "-m fast" : "",
+ log_opts.filename2);
exec_prog(fast ? false : true, "%s", cmd);