summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pg_archivecleanup/pg_archivecleanup.c12
-rw-r--r--contrib/pg_standby/pg_standby.c14
-rw-r--r--contrib/pg_test_fsync/pg_test_fsync.c4
-rw-r--r--contrib/pg_upgrade/check.c36
-rw-r--r--contrib/pg_upgrade/exec.c8
-rw-r--r--contrib/pg_upgrade/file.c2
-rw-r--r--contrib/pg_upgrade/option.c47
-rw-r--r--contrib/pg_upgrade/pg_upgrade.c2
-rw-r--r--contrib/pg_upgrade/server.c10
-rw-r--r--contrib/pg_upgrade/util.c5
-rw-r--r--contrib/pg_upgrade/version.c2
-rw-r--r--contrib/pg_upgrade/version_old_8_3.c12
-rw-r--r--contrib/pgbench/pgbench.c2
13 files changed, 96 insertions, 60 deletions
diff --git a/contrib/pg_archivecleanup/pg_archivecleanup.c b/contrib/pg_archivecleanup/pg_archivecleanup.c
index d96eef2c5a..dd8a45133c 100644
--- a/contrib/pg_archivecleanup/pg_archivecleanup.c
+++ b/contrib/pg_archivecleanup/pg_archivecleanup.c
@@ -203,19 +203,19 @@ usage(void)
printf("%s removes older WAL files from PostgreSQL archives.\n\n", progname);
printf("Usage:\n");
printf(" %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n", progname);
+ printf("\nOptions:\n");
+ printf(" -d generates debug output (verbose mode)\n");
+ printf(" --help show this help, then exit\n");
+ printf(" --version output version information, then exit\n");
printf("\n"
- "for use as an archive_cleanup_command in the recovery.conf when standby_mode = on:\n"
+ "For use as archive_cleanup_command in recovery.conf when standby_mode = on:\n"
" archive_cleanup_command = 'pg_archivecleanup [OPTION]... ARCHIVELOCATION %%r'\n"
"e.g.\n"
" archive_cleanup_command = 'pg_archivecleanup /mnt/server/archiverdir %%r'\n");
printf("\n"
- "or for use as a standalone archive cleaner:\n"
+ "Or for use as a standalone archive cleaner:\n"
"e.g.\n"
" pg_archivecleanup /mnt/server/archiverdir 000000010000000000000010.00000020.backup\n");
- printf("\nOptions:\n");
- printf(" -d generates debug output (verbose mode)\n");
- printf(" --help show this help, then exit\n");
- printf(" --version output version information, then exit\n");
printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n");
}
diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c
index f25015fd14..7204b447da 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/contrib/pg_standby/pg_standby.c
@@ -119,7 +119,7 @@ struct stat stat_buf;
* accessible directory. If you want to make other assumptions,
* such as using a vendor-specific archive and access API, these
* routines are the ones you'll need to change. You're
- * enouraged to submit any changes to pgsql-hackers@postgresql.org
+ * encouraged to submit any changes to pgsql-hackers@postgresql.org
* or personally to the current maintainer. Those changes may be
* folded in to later versions of this program.
*/
@@ -252,7 +252,7 @@ CustomizableCleanupPriorWALFiles(void)
/*
* Assume it's OK to keep failing. The failure situation may change
* over time, so we'd rather keep going on the main processing than
- * fail because we couldnt clean up yet.
+ * fail because we couldn't clean up yet.
*/
if ((xldir = opendir(archiveLocation)) != NULL)
{
@@ -515,11 +515,6 @@ usage(void)
printf("%s allows PostgreSQL warm standby servers to be configured.\n\n", progname);
printf("Usage:\n");
printf(" %s [OPTION]... ARCHIVELOCATION NEXTWALFILE XLOGFILEPATH [RESTARTWALFILE]\n", progname);
- printf("\n"
- "with main intended use as a restore_command in the recovery.conf:\n"
- " restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n"
- "e.g.\n"
- " restore_command = 'pg_standby -l /mnt/server/archiverdir %%f %%p %%r'\n");
printf("\nOptions:\n");
printf(" -c copies file from archive (default)\n");
printf(" -d generate lots of debugging output (testing only)\n");
@@ -534,6 +529,11 @@ usage(void)
printf(" -w MAXWAITTIME max seconds to wait for a file (0=no limit) (default=0)\n");
printf(" --help show this help, then exit\n");
printf(" --version output version information, then exit\n");
+ printf("\n"
+ "Main intended use as restore_command in recovery.conf:\n"
+ " restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n"
+ "e.g.\n"
+ " restore_command = 'pg_standby /mnt/server/archiverdir %%f %%p %%r'\n");
printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n");
}
diff --git a/contrib/pg_test_fsync/pg_test_fsync.c b/contrib/pg_test_fsync/pg_test_fsync.c
index 2b2e292022..3791f5a071 100644
--- a/contrib/pg_test_fsync/pg_test_fsync.c
+++ b/contrib/pg_test_fsync/pg_test_fsync.c
@@ -96,12 +96,12 @@ handle_args(int argc, char *argv[])
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
strcmp(argv[1], "-?") == 0)
{
- fprintf(stderr, "%s [-f filename] [-o ops-per-test]\n", progname);
+ printf("Usage: %s [-f FILENAME] [-o OPS-PER-TEST]\n", progname);
exit(0);
}
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
{
- fprintf(stderr, "%s %s\n", progname, PG_VERSION);
+ puts("pg_test_fsync (PostgreSQL) " PG_VERSION);
exit(0);
}
}
diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c
index a9436ce5b2..ebdc34e188 100644
--- a/contrib/pg_upgrade/check.c
+++ b/contrib/pg_upgrade/check.c
@@ -15,6 +15,7 @@ static void check_new_cluster_is_empty(void);
static void check_old_cluster_has_new_cluster_dbs(void);
static void check_locale_and_encoding(ControlData *oldctrl,
ControlData *newctrl);
+static void check_is_super_user(ClusterInfo *cluster);
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
@@ -63,7 +64,7 @@ check_old_cluster(bool live_check,
/*
* Check for various failure cases
*/
-
+ check_is_super_user(&old_cluster);
check_for_reg_data_type_usage(&old_cluster);
check_for_isn_and_int8_passing_mismatch(&old_cluster);
@@ -253,7 +254,7 @@ check_cluster_compatibility(bool live_check)
if ((lib_test = fopen(libfile, "r")) == NULL)
pg_log(PG_FATAL,
- "\npg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile);
+ "pg_upgrade_support%s must be created and installed in %s\n", DLSUFFIX, libfile);
else
fclose(lib_test);
@@ -473,6 +474,37 @@ create_script_for_old_cluster_deletion(
/*
+ * check_is_super_user()
+ *
+ * Make sure we are the super-user.
+ */
+static void
+check_is_super_user(ClusterInfo *cluster)
+{
+ PGresult *res;
+ PGconn *conn = connectToServer(cluster, "template1");
+
+ prep_status("Checking database user is a superuser");
+
+ /* Can't use pg_authid because only superusers can view it. */
+ res = executeQueryOrDie(conn,
+ "SELECT rolsuper "
+ "FROM pg_catalog.pg_roles "
+ "WHERE rolname = current_user");
+
+ if (PQntuples(res) != 1 || strcmp(PQgetvalue(res, 0, 0), "t") != 0)
+ pg_log(PG_FATAL, "database user \"%s\" is not a superuser\n",
+ os_info.user);
+
+ PQclear(res);
+
+ PQfinish(conn);
+
+ check_ok();
+}
+
+
+/*
* check_for_isn_and_int8_passing_mismatch()
*
* /contrib/isn relies on data type int8, and in 8.4 int8 can now be passed
diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c
index 59a76bc8ae..71e84394e6 100644
--- a/contrib/pg_upgrade/exec.c
+++ b/contrib/pg_upgrade/exec.c
@@ -46,7 +46,7 @@ exec_prog(bool throw_error, const char *fmt,...)
if (result != 0)
{
pg_log(throw_error ? PG_FATAL : PG_INFO,
- "\nThere were problems executing %s\n", cmd);
+ "There were problems executing %s\n", cmd);
return 1;
}
@@ -71,7 +71,7 @@ is_server_running(const char *datadir)
if ((fd = open(path, O_RDONLY, 0)) < 0)
{
if (errno != ENOENT)
- pg_log(PG_FATAL, "\ncould not open file \"%s\" for reading\n",
+ pg_log(PG_FATAL, "could not open file \"%s\" for reading\n",
path);
return false;
@@ -139,10 +139,10 @@ check_data_dir(const char *pg_data)
requiredSubdirs[subdirnum]);
if (stat(subDirName, &statBuf) != 0)
- report_status(PG_FATAL, "check for %s failed: %s",
+ report_status(PG_FATAL, "check for %s failed: %s\n",
requiredSubdirs[subdirnum], getErrorText(errno));
else if (!S_ISDIR(statBuf.st_mode))
- report_status(PG_FATAL, "%s is not a directory",
+ report_status(PG_FATAL, "%s is not a directory\n",
requiredSubdirs[subdirnum]);
}
}
diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c
index 0552541c24..a7e40090e2 100644
--- a/contrib/pg_upgrade/file.c
+++ b/contrib/pg_upgrade/file.c
@@ -287,7 +287,7 @@ pg_scandir_internal(const char *dirname,
size_t entrysize;
if ((dirdesc = opendir(dirname)) == NULL)
- pg_log(PG_FATAL, "Could not open directory \"%s\": %m\n", dirname);
+ pg_log(PG_FATAL, "could not open directory \"%s\": %m\n", dirname);
*namelist = NULL;
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index 857d6528c8..36561b9b4c 100644
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -81,7 +81,7 @@ parseCommandLine(int argc, char *argv[])
}
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
{
- pg_log(PG_REPORT, "pg_upgrade " PG_VERSION "\n");
+ puts("pg_upgrade (PostgreSQL) " PG_VERSION);
exit(0);
}
}
@@ -180,10 +180,10 @@ parseCommandLine(int argc, char *argv[])
*/
/* truncate */
if ((log_opts.fd = fopen(log_opts.filename, "w")) == NULL)
- pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename);
+ pg_log(PG_FATAL, "cannot write to log file %s\n", log_opts.filename);
fclose(log_opts.fd);
if ((log_opts.fd = fopen(log_opts.filename, "a")) == NULL)
- pg_log(PG_FATAL, "Cannot write to log file %s\n", log_opts.filename);
+ pg_log(PG_FATAL, "cannot write to log file %s\n", log_opts.filename);
}
else
log_opts.filename = strdup(DEVNULL);
@@ -193,7 +193,7 @@ parseCommandLine(int argc, char *argv[])
{
log_opts.debug_fd = fopen(DEVTTY, "w");
if (!log_opts.debug_fd)
- pg_log(PG_FATAL, "Cannot write to terminal\n");
+ pg_log(PG_FATAL, "cannot write to terminal\n");
}
/* Get values from env if not already set */
@@ -213,24 +213,26 @@ parseCommandLine(int argc, char *argv[])
static void
usage(void)
{
- printf(_("\nUsage: pg_upgrade [OPTIONS]...\n\
+ printf(_("pg_upgrade upgrades a PostgreSQL cluster to a different major version.\n\
+\nUsage:\n\
+ pg_upgrade [OPTIONS]...\n\
\n\
Options:\n\
- -b, --old-bindir=old_bindir old cluster executable directory\n\
- -B, --new-bindir=new_bindir new cluster executable directory\n\
- -c, --check check clusters only, don't change any data\n\
- -d, --old-datadir=old_datadir old cluster data directory\n\
- -D, --new-datadir=new_datadir new cluster data directory\n\
- -g, --debug enable debugging\n\
- -G, --debugfile=debug_filename output debugging activity to file\n\
- -k, --link link instead of copying files to new cluster\n\
- -l, --logfile=log_filename log session activity to file\n\
- -p, --old-port=old_portnum old cluster port number (default %d)\n\
- -P, --new-port=new_portnum new cluster port number (default %d)\n\
- -u, --user=username clusters superuser (default \"%s\")\n\
- -v, --verbose enable verbose output\n\
- -V, --version display version information, then exit\n\
- -h, --help show this help, then exit\n\
+ -b, --old-bindir=OLDBINDIR old cluster executable directory\n\
+ -B, --new-bindir=NEWBINDIR new cluster executable directory\n\
+ -c, --check check clusters only, don't change any data\n\
+ -d, --old-datadir=OLDDATADIR old cluster data directory\n\
+ -D, --new-datadir=NEWDATADIR new cluster data directory\n\
+ -g, --debug enable debugging\n\
+ -G, --debugfile=FILENAME output debugging activity to file\n\
+ -k, --link link instead of copying files to new cluster\n\
+ -l, --logfile=FILENAME log session activity to file\n\
+ -p, --old-port=OLDPORT old cluster port number (default %d)\n\
+ -P, --new-port=NEWPORT new cluster port number (default %d)\n\
+ -u, --user=NAME clusters superuser (default \"%s\")\n\
+ -v, --verbose enable verbose output\n\
+ -V, --version display version information, then exit\n\
+ -h, --help show this help, then exit\n\
\n\
Before running pg_upgrade you must:\n\
create a new database cluster (using the new version of initdb)\n\
@@ -240,8 +242,8 @@ Before running pg_upgrade you must:\n\
When you run pg_upgrade, you must provide the following information:\n\
the data directory for the old cluster (-d OLDDATADIR)\n\
the data directory for the new cluster (-D NEWDATADIR)\n\
- the 'bin' directory for the old version (-b OLDBINDIR)\n\
- the 'bin' directory for the new version (-B NEWBINDIR)\n\
+ the \"bin\" directory for the old version (-b OLDBINDIR)\n\
+ the \"bin\" directory for the new version (-B NEWBINDIR)\n\
\n\
For example:\n\
pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin\n\
@@ -261,6 +263,7 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user);
C:\\> set NEWBINDIR=newCluster/bin\n\
C:\\> pg_upgrade\n"));
#endif
+ printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
}
diff --git a/contrib/pg_upgrade/pg_upgrade.c b/contrib/pg_upgrade/pg_upgrade.c
index 9f7a538765..857e82901b 100644
--- a/contrib/pg_upgrade/pg_upgrade.c
+++ b/contrib/pg_upgrade/pg_upgrade.c
@@ -302,7 +302,7 @@ copy_clog_xlog_xid(void)
snprintf(old_clog_path, sizeof(old_clog_path), "%s/pg_clog", old_cluster.pgdata);
snprintf(new_clog_path, sizeof(new_clog_path), "%s/pg_clog", new_cluster.pgdata);
if (!rmtree(new_clog_path, true))
- pg_log(PG_FATAL, "Unable to delete directory %s\n", new_clog_path);
+ pg_log(PG_FATAL, "unable to delete directory %s\n", new_clog_path);
check_ok();
prep_status("Copying old commit clogs to new server");
diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c
index 935ce32a61..8fce305d2e 100644
--- a/contrib/pg_upgrade/server.c
+++ b/contrib/pg_upgrade/server.c
@@ -27,7 +27,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name)
if (conn == NULL || PQstatus(conn) != CONNECTION_OK)
{
- pg_log(PG_REPORT, "Connection to database failed: %s\n",
+ pg_log(PG_REPORT, "connection to database failed: %s\n",
PQerrorMessage(conn));
if (conn)
@@ -189,10 +189,11 @@ start_postmaster(ClusterInfo *cluster)
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
PQstatus(conn) != CONNECTION_OK)
{
- if (conn)
+ pg_log(PG_REPORT, "\nconnection to database failed: %s\n",
+ PQerrorMessage(conn));
+ if (conn)
PQfinish(conn);
- pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n"
- "Perhaps pg_hba.conf was not set to \"trust\".",
+ pg_log(PG_FATAL, "unable to connect to %s postmaster started with the command: %s\n",
CLUSTER_NAME(cluster), cmd);
}
PQfinish(conn);
@@ -265,6 +266,7 @@ check_for_libpq_envvars(void)
{
const char *value;
+ /* This allows us to see error messages in the local encoding */
if (strcmp(option->envvar, "PGCLIENTENCODING") == 0)
continue;
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
index 9a6691ce75..9b0bf0f82a 100644
--- a/contrib/pg_upgrade/util.c
+++ b/contrib/pg_upgrade/util.c
@@ -46,7 +46,7 @@ report_status(eLogType type, const char *fmt,...)
* if(( message = flarbFiles(fileCount)) == NULL)
* report_status(PG_REPORT, "ok" );
* else
- * pg_log(PG_FATAL, "failed - %s", message );
+ * pg_log(PG_FATAL, "failed - %s\n", message );
*/
void
prep_status(const char *fmt,...)
@@ -97,8 +97,7 @@ pg_log(eLogType type, char *fmt,...)
break;
case PG_FATAL:
- printf("%s", "\n");
- printf("%s", _(message));
+ printf("\n%s", _(message));
printf("Failure, exiting\n");
exit(1);
break;
diff --git a/contrib/pg_upgrade/version.c b/contrib/pg_upgrade/version.c
index 8ba7e98d92..958bcbb80f 100644
--- a/contrib/pg_upgrade/version.c
+++ b/contrib/pg_upgrade/version.c
@@ -49,7 +49,7 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
if (!check_mode)
{
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
fprintf(script, "\\connect %s\n",
quote_identifier(active_db->db_name));
fprintf(script,
diff --git a/contrib/pg_upgrade/version_old_8_3.c b/contrib/pg_upgrade/version_old_8_3.c
index 0a60eec926..1a31f8d683 100644
--- a/contrib/pg_upgrade/version_old_8_3.c
+++ b/contrib/pg_upgrade/version_old_8_3.c
@@ -70,7 +70,7 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
{
found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "Database: %s\n", active_db->db_name);
@@ -160,7 +160,7 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
{
found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "Database: %s\n", active_db->db_name);
@@ -278,7 +278,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
if (!check_mode)
{
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "\\connect %s\n\n",
@@ -398,7 +398,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
if (!check_mode)
{
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "\\connect %s\n",
@@ -523,7 +523,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
if (!check_mode)
{
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "\\connect %s\n",
@@ -648,7 +648,7 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
found = true;
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
- pg_log(PG_FATAL, "Could not create necessary file: %s\n", output_path);
+ pg_log(PG_FATAL, "could not create necessary file: %s\n", output_path);
if (!db_used)
{
fprintf(script, "\\connect %s\n\n",
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 0a3e5fd928..bb18c8907d 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -341,12 +341,12 @@ usage(const char *progname)
" define variable for use by custom script\n"
" -f FILENAME read transaction script from FILENAME\n"
" -j NUM number of threads (default: 1)\n"
- " -r report average latency per command\n"
" -l write transaction times to log file\n"
" -M {simple|extended|prepared}\n"
" protocol for submitting queries to server (default: simple)\n"
" -n do not run VACUUM before tests\n"
" -N do not update tables \"pgbench_tellers\" and \"pgbench_branches\"\n"
+ " -r report average latency per command\n"
" -s NUM report this scale factor in output\n"
" -S perform SELECT-only transactions\n"
" -t NUM number of transactions each client runs (default: 10)\n"