summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2011-04-25 20:17:48 -0400
committerBruce Momjian <bruce@momjian.us>2011-04-25 20:18:23 -0400
commit44091442db7e0d9fd7f0495f09d725fc92d940b5 (patch)
tree32223b6feb446dc2c9a4214f2e1dc83706d14739
parent6dab96abaa8bd6775658d26517e288f4d5f6448f (diff)
In pg_upgrade, avoid one start/stop of the postmaster; use the -w
(wait) flag for pg_ctl start/stop; remove the unused "quiet" flag in the functions for starting/stopping the postmaster.
-rw-r--r--contrib/pg_upgrade/check.c14
-rw-r--r--contrib/pg_upgrade/pg_upgrade.c19
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h4
-rw-r--r--contrib/pg_upgrade/server.c10
4 files changed, 21 insertions, 26 deletions
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index 415f95b616d..a9436ce5b2f 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -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);
}
}
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index e435aaef08c..9f7a5387655 100644
--- a/contrib/pg_upgrade/pg_upgrade.c
+++ b/contrib/pg_upgrade/pg_upgrade.c
@@ -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);
}
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 5865315d9e4..358bf606b18 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -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);
diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c
index ab8d8c73342..0c9914b413e 100644
--- a/contrib/pg_upgrade/server.c
+++ b/contrib/pg_upgrade/server.c
@@ -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