]> granicus.if.org Git - postgresql/commitdiff
In pg_upgrade, fix the -l/log option to work on Windows.
authorBruce Momjian <bruce@momjian.us>
Wed, 20 Jul 2011 22:31:07 +0000 (18:31 -0400)
committerBruce Momjian <bruce@momjian.us>
Wed, 20 Jul 2011 22:31:07 +0000 (18:31 -0400)
Also, double-quote the log file name in all places, to allow (on all
platforms) log file names with spaces.

Back patch to 9.0 and 9.1.

contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/server.c

index e329dc3efe67c6daa952e412ca1e839ebf8ded3c..abd3d5f8a2a12614219098d2041a68c848a7346a 100644 (file)
@@ -193,8 +193,14 @@ prepare_new_cluster(void)
        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,
+#ifndef WIN32
+         log_opts.filename
+#else
+         DEVNULL
+#endif
+         );
        check_ok();
 
        /*
@@ -206,8 +212,14 @@ prepare_new_cluster(void)
        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,
+#ifndef WIN32
+         log_opts.filename
+#else
+         DEVNULL
+#endif
+         );
        check_ok();
 
        get_pg_database_relfilenode(&new_cluster);
@@ -245,7 +257,13 @@ prepare_new_databases(void)
                          "--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,
+#ifndef WIN32
+                         log_opts.filename
+#else
+                         DEVNULL
+#endif
+                         );
        check_ok();
 
        /* we load this to get a current list of databases */
@@ -276,7 +294,13 @@ create_new_objects(void)
                          "--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,
+#ifndef WIN32
+                         log_opts.filename
+#else
+                         DEVNULL
+#endif
+                         );
        check_ok();
 
        /* regenerate now that we have objects in the databases */
@@ -324,7 +348,13 @@ copy_clog_xlog_xid(void)
        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,
+#ifndef WIN32
+                         log_opts.filename
+#else
+                         DEVNULL
+#endif
+                         );
        check_ok();
 }
 
index 58c1234a9482ed5b3f872b60be42f70e39133dc5..e86540b9d79861aac78c000dae1b256a419e9bc4 100644 (file)
@@ -184,7 +184,7 @@ start_postmaster(ClusterInfo *cluster)
                         (cluster->controldata.cat_ver >=
                          BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
                         "-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
-                        log_opts.filename);
+                        output_filename);
 
        /*
         * Don't throw an error right away, let connecting throw the error because