In pg_upgrade, avoid one start/stop of the postmaster; use the -w
authorBruce Momjian <bruce@momjian.us>
Tue, 26 Apr 2011 00:17:48 +0000 (20:17 -0400)
committerBruce Momjian <bruce@momjian.us>
Tue, 26 Apr 2011 00:18:23 +0000 (20:18 -0400)
(wait) flag for pg_ctl start/stop;  remove the unused "quiet" flag in
the functions for starting/stopping the postmaster.

contrib/pg_upgrade/check.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/server.c

index 415f95b616d19099bb4a6a301a5aad9d5e82cd79..a9436ce5b2f237730dfc4b9410104d98cfa85512 100644 (file)
@@ -46,7 +46,7 @@ check_old_cluster(bool live_check,
    /* -- OLD -- */
 
    if (!live_check)
-       start_postmaster(&old_cluster, false);
+       start_postmaster(&old_cluster);
 
    set_locale_and_encoding(&old_cluster);
 
@@ -104,7 +104,7 @@ check_old_cluster(bool live_check,
    }
 
    if (!live_check)
-       stop_postmaster(false, false);
+       stop_postmaster(false);
 }
 
 
@@ -134,7 +134,7 @@ report_clusters_compatible(void)
    {
        pg_log(PG_REPORT, "\n*Clusters are compatible*\n");
        /* stops new cluster */
-       stop_postmaster(false, false);
+       stop_postmaster(false);
        exit(0);
    }
 
@@ -152,7 +152,7 @@ issue_warnings(char *sequence_script_file_name)
    /* old = PG 8.3 warnings? */
    if (GET_MAJOR_VERSION(old_cluster.major_version) <= 803)
    {
-       start_postmaster(&new_cluster, true);
+       start_postmaster(&new_cluster);
 
        /* restore proper sequence values using file created from old server */
        if (sequence_script_file_name)
@@ -171,15 +171,15 @@ issue_warnings(char *sequence_script_file_name)
        old_8_3_rebuild_tsvector_tables(&new_cluster, false);
        old_8_3_invalidate_hash_gin_indexes(&new_cluster, false);
        old_8_3_invalidate_bpchar_pattern_ops_indexes(&new_cluster, false);
-       stop_postmaster(false, true);
+       stop_postmaster(false);
    }
 
    /* Create dummy large object permissions for old < PG 9.0? */
    if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
    {
-       start_postmaster(&new_cluster, true);
+       start_postmaster(&new_cluster);
        new_9_0_populate_pg_largeobject_metadata(&new_cluster, false);
-       stop_postmaster(false, true);
+       stop_postmaster(false);
    }
 }
 
index e435aaef08c88a581344bedb6aae67093e3f1450..9f7a5387655db5b30b00f4117597b43a1232d58a 100644 (file)
@@ -77,7 +77,7 @@ main(int argc, char **argv)
 
 
    /* -- NEW -- */
-   start_postmaster(&new_cluster, false);
+   start_postmaster(&new_cluster);
 
    check_new_cluster();
    report_clusters_compatible();
@@ -88,7 +88,7 @@ main(int argc, char **argv)
    disable_old_cluster();
    prepare_new_cluster();
 
-   stop_postmaster(false, false);
+   stop_postmaster(false);
 
    /*
     * Destructive Changes to New Cluster
@@ -98,10 +98,15 @@ main(int argc, char **argv)
 
    /* New now using xids of the old system */
 
+   /* -- NEW -- */
+   start_postmaster(&new_cluster);
+
    prepare_new_databases();
 
    create_new_objects();
 
+   stop_postmaster(false);
+
    transfer_all_new_dbs(&old_cluster.dbarr, &new_cluster.dbarr,
                         old_cluster.pgdata, new_cluster.pgdata);
 
@@ -216,9 +221,6 @@ prepare_new_cluster(void)
 static void
 prepare_new_databases(void)
 {
-   /* -- NEW -- */
-   start_postmaster(&new_cluster, false);
-
    /*
     * We set autovacuum_freeze_max_age to its maximum value so autovacuum
     * does not launch here and delete clog files, before the frozen xids are
@@ -252,8 +254,6 @@ prepare_new_databases(void)
 
    /* we load this to get a current list of databases */
    get_db_and_rel_infos(&new_cluster);
-
-   stop_postmaster(false, false);
 }
 
 
@@ -262,9 +262,6 @@ create_new_objects(void)
 {
    int         dbnum;
 
-   /* -- NEW -- */
-   start_postmaster(&new_cluster, false);
-
    prep_status("Adding support functions to new cluster");
 
    for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
@@ -290,8 +287,6 @@ create_new_objects(void)
    get_db_and_rel_infos(&new_cluster);
 
    uninstall_support_functions_from_new_cluster();
-
-   stop_postmaster(false, false);
 }
 
 
index 5865315d9e4f44afa36d52502f9ab93fda082931..358bf606b187dc5907aaa025025b65e179a55f36 100644 (file)
@@ -359,8 +359,8 @@ void        init_tablespaces(void);
 PGconn    *connectToServer(ClusterInfo *cluster, const char *db_name);
 PGresult   *executeQueryOrDie(PGconn *conn, const char *fmt,...);
 
-void       start_postmaster(ClusterInfo *cluster, bool quiet);
-void       stop_postmaster(bool fast, bool quiet);
+void       start_postmaster(ClusterInfo *cluster);
+void       stop_postmaster(bool fast);
 uint32     get_major_server_version(ClusterInfo *cluster);
 void       check_for_libpq_envvars(void);
 
index ab8d8c73342c634ecc2f30c0780bc696aefc2fa8..0c9914b413e22dea1eae2581a0c33760968945ef 100644 (file)
@@ -160,13 +160,13 @@ stop_postmaster_atexit(void)
 stop_postmaster_on_exit(int exitstatus, void *arg)
 #endif
 {
-   stop_postmaster(true, true);
+   stop_postmaster(true);
 
 }
 
 
 void
-start_postmaster(ClusterInfo *cluster, bool quiet)
+start_postmaster(ClusterInfo *cluster)
 {
    char        cmd[MAXPGPATH];
    const char *bindir;
@@ -205,7 +205,7 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
     * not touch them.
     */
    snprintf(cmd, sizeof(cmd),
-            SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
+            SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" "
             "-o \"-p %d %s\" start >> \"%s\" 2>&1" SYSTEMQUOTE,
             bindir, output_filename, datadir, port,
             (cluster->controldata.cat_ver >=
@@ -228,7 +228,7 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
 
 
 void
-stop_postmaster(bool fast, bool quiet)
+stop_postmaster(bool fast)
 {
    char        cmd[MAXPGPATH];
    const char *bindir;
@@ -249,7 +249,7 @@ stop_postmaster(bool fast, bool quiet)
 
    /* 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 >> "
+            SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" %s stop >> "
             "\"%s\" 2>&1" SYSTEMQUOTE,
             bindir,
 #ifndef WIN32