diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c
index 0e59cc3afde005560e14260dbbf71d7afda700bc..7b9046bb18b45ccf6e3fc90c9f62ccb9be2c43bd 100644
--- a/contrib/oid2name/oid2name.c
+++ b/contrib/oid2name/oid2name.c
@@ -5,7 +5,7 @@
  * Originally by
  * B. Palmer, bpalmer@crimelabs.net 1-17-2001
  *
- * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.34 2009/02/25 13:24:40 petere Exp $
+ * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.35 2009/02/27 09:30:21 petere Exp $
  */
 #include "postgres_fe.h"
 
@@ -47,6 +47,7 @@ struct options
 };
 
 /* function prototypes */
+static void help(const char *progname);
 void		get_opts(int, char **, struct options *);
 void	   *myalloc(size_t size);
 char	   *mystrdup(const char *str);
@@ -64,6 +65,9 @@ void
 get_opts(int argc, char **argv, struct options * my_opts)
 {
 	int			c;
+	const char *progname;
+
+	progname = get_progname(argv[0]);
 
 	/* set the defaults */
 	my_opts->quiet = false;
@@ -77,8 +81,22 @@ get_opts(int argc, char **argv, struct options * my_opts)
 	my_opts->port = NULL;
 	my_opts->username = NULL;
 
+	if (argc > 1)
+	{
+		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+		{
+			help(progname);
+			exit(0);
+		}
+		if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+		{
+			puts("oid2name (PostgreSQL) " PG_VERSION);
+			exit(0);
+		}
+	}
+
 	/* get opts */
-	while ((c = getopt(argc, argv, "H:p:U:d:t:o:f:qSxish?")) != -1)
+	while ((c = getopt(argc, argv, "H:p:U:d:t:o:f:qSxish")) != -1)
 	{
 		switch (c)
 		{
@@ -142,31 +160,44 @@ get_opts(int argc, char **argv, struct options * my_opts)
 				my_opts->tablespaces = true;
 				break;
 
-				/* help! (ugly in code for easier editing) */
-			case '?':
 			case 'h':
-				fprintf(stderr,
-						"Usage: oid2name [-s|-d database] [-S][-i][-q][-x] [-t table|-o oid|-f file] ...\n"
-					 "        default action        show all database Oids\n"
-					 "        -d database           database to connect to\n"
-						"        -s                    show all tablespaces\n"
-					"        -S                    show system objects too\n"
-						"        -i                    show indexes and sequences too\n"
-						"        -x                    extended (show additional columns)\n"
-				 "        -q                    quiet (don't show headers)\n"
-						"        -t <table>            show info for table named <table>\n"
-						"        -o <oid>              show info for table with Oid <oid>\n"
-						"        -f <filenode>         show info for table with filenode <filenode>\n"
-					 "        -H host               connect to remote host\n"
-					"        -p port               host port to connect to\n"
-				   "        -U username           username to connect with\n"
-					);
-				exit(1);
+				help(progname);
+				exit(0);
 				break;
+
+			default:
+				fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
+				exit(1);
 		}
 	}
 }
 
+static void
+help(const char *progname)
+{
+	printf("%s helps examining the file structure used by PostgreSQL.\n\n"
+		   "Usage:\n"
+		   "  %s [OPTIONS]...\n"
+		   "\nOptions:\n"
+		   "  -d DBNAME    database to connect to\n"
+		   "  -f FILENODE  show info for table with given file node\n"
+		   "  -H HOSTNAME  database server host or socket directory\n"
+		   "  -i           show indexes and sequences too\n"
+		   "  -o OID       show info for table with given OID\n"
+		   "  -p PORT      database server port number\n"
+		   "  -q           quiet (don't show headers)\n"
+		   "  -s           show all tablespaces\n"
+		   "  -S           show system objects too\n"
+		   "  -t TABLE     show info for named table\n"
+		   "  -U NAME      connect as specified database user\n"
+		   "  -x           extended (show additional columns)\n"
+		   "  --help       show this help, then exit\n"
+		   "  --version    output version information, then exit\n"
+		   "\nThe default action is to show all database OIDs.\n\n"
+		   "Report bugs to <pgsql-bugs@postgresql.org>.\n",
+		   progname, progname);
+}
+
 void *
 myalloc(size_t size)
 {
diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c
index fe8b23465000222332ce0ffddc89e6731871414e..eef2e112f3f77c15d6da9692a2bb223bf9fefe57 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/contrib/pg_standby/pg_standby.c
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.17 2009/01/06 17:27:06 tgl Exp $ 
+ * $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.18 2009/02/27 09:30:21 petere Exp $ 
  *
  *
  * pg_standby.c
@@ -42,6 +42,8 @@ int			getopt(int argc, char *const argv[], const char *optstring);
 extern char *optarg;
 extern int	optind;
 
+const char *progname;
+
 /* Options and defaults */
 int			sleeptime = 5;		/* amount of time to sleep between file checks */
 int			waittime = -1;		/* how long we have been waiting, -1 no wait
@@ -146,7 +148,7 @@ CustomizableInitialize(void)
 	 */
 	if (stat(archiveLocation, &stat_buf) != 0)
 	{
-		fprintf(stderr, "pg_standby: archiveLocation \"%s\" does not exist\n", archiveLocation);
+		fprintf(stderr, "%s: archiveLocation \"%s\" does not exist\n", progname, archiveLocation);
 		fflush(stderr);
 		exit(2);
 	}
@@ -261,8 +263,8 @@ CustomizableCleanupPriorWALFiles(void)
 					rc = unlink(WALFilePath);
 					if (rc != 0)
 					{
-						fprintf(stderr, "\npg_standby: ERROR failed to remove \"%s\": %s",
-								WALFilePath, strerror(errno));
+						fprintf(stderr, "\n%s: ERROR failed to remove \"%s\": %s",
+								progname, WALFilePath, strerror(errno));
 						break;
 					}
 				}
@@ -271,7 +273,7 @@ CustomizableCleanupPriorWALFiles(void)
 				fprintf(stderr, "\n");
 		}
 		else
-			fprintf(stderr, "pg_standby: archiveLocation \"%s\" open error\n", archiveLocation);
+			fprintf(stderr, "%s: archiveLocation \"%s\" open error\n", progname, archiveLocation);
 
 		closedir(xldir);
 		fflush(stderr);
@@ -430,23 +432,29 @@ RestoreWALFileForRecovery(void)
 static void
 usage(void)
 {
-	fprintf(stderr, "\npg_standby allows Warm Standby servers to be configured\n");
-	fprintf(stderr, "Usage:\n");
-	fprintf(stderr, "  pg_standby [OPTION]... ARCHIVELOCATION NEXTWALFILE XLOGFILEPATH [RESTARTWALFILE]\n");
-	fprintf(stderr, "				note space between ARCHIVELOCATION and NEXTWALFILE\n");
-	fprintf(stderr, "with main intended use as a restore_command in the recovery.conf\n");
-	fprintf(stderr, "	 restore_command = 'pg_standby [OPTION]... ARCHIVELOCATION %%f %%p %%r'\n");
-	fprintf(stderr, "e.g. restore_command = 'pg_standby -l /mnt/server/archiverdir %%f %%p %%r'\n");
-	fprintf(stderr, "\nOptions:\n");
-	fprintf(stderr, "  -c			copies file from archive (default)\n");
-	fprintf(stderr, "  -d			generate lots of debugging output (testing only)\n");
-	fprintf(stderr, "  -k NUMFILESTOKEEP	if RESTARTWALFILE not used, removes files prior to limit (0 keeps all)\n");
-	fprintf(stderr, "  -l			links into archive (leaves file in archive)\n");
-	fprintf(stderr, "  -r MAXRETRIES		max number of times to retry, with progressive wait (default=3)\n");
-	fprintf(stderr, "  -s SLEEPTIME		seconds to wait between file checks (min=1, max=60, default=5)\n");
-	fprintf(stderr, "  -t TRIGGERFILE	defines a trigger file to initiate failover (no default)\n");
-	fprintf(stderr, "  -w MAXWAITTIME	max seconds to wait for a file (0=no limit)(default=0)\n");
-	fflush(stderr);
+	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");
+	printf("  -k NUMFILESTOKEEP  if RESTARTWALFILE not used, removes files prior to limit\n"
+		   "                     (0 keeps all)\n");
+	printf("  -l                 links into archive (leaves file in archive)\n");
+	printf("  -r MAXRETRIES      max number of times to retry, with progressive wait\n"
+		   "                     (default=3)\n");
+	printf("  -s SLEEPTIME       seconds to wait between file checks (min=1, max=60,\n"
+		   "                     default=5)\n");
+	printf("  -t TRIGGERFILE     defines a trigger file to initiate failover (no default)\n");
+	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("\nReport bugs to <pgsql-bugs@postgresql.org>.\n");
 }
 
 static void
@@ -461,6 +469,22 @@ main(int argc, char **argv)
 {
 	int			c;
 
+	progname = get_progname(argv[0]);
+
+	if (argc > 1)
+	{
+		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+		{
+			usage();
+			exit(0);
+		}
+		if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+		{
+			puts("pg_standby (PostgreSQL) " PG_VERSION);
+			exit(0);
+		}
+	}
+
 	(void) signal(SIGINT, sighandler);
 	(void) signal(SIGQUIT, sighandler);
 
@@ -478,8 +502,7 @@ main(int argc, char **argv)
 				keepfiles = atoi(optarg);
 				if (keepfiles < 0)
 				{
-					fprintf(stderr, "usage: pg_standby -k keepfiles must be >= 0\n");
-					usage();
+					fprintf(stderr, "%s: -k keepfiles must be >= 0\n", progname);
 					exit(2);
 				}
 				break;
@@ -490,8 +513,7 @@ main(int argc, char **argv)
 				maxretries = atoi(optarg);
 				if (maxretries < 0)
 				{
-					fprintf(stderr, "usage: pg_standby -r maxretries must be >= 0\n");
-					usage();
+					fprintf(stderr, "%s: -r maxretries must be >= 0\n", progname);
 					exit(2);
 				}
 				break;
@@ -499,8 +521,7 @@ main(int argc, char **argv)
 				sleeptime = atoi(optarg);
 				if (sleeptime <= 0 || sleeptime > 60)
 				{
-					fprintf(stderr, "usage: pg_standby -s sleeptime incorrectly set\n");
-					usage();
+					fprintf(stderr, "%s: -s sleeptime incorrectly set\n", progname);
 					exit(2);
 				}
 				break;
@@ -513,13 +534,12 @@ main(int argc, char **argv)
 				maxwaittime = atoi(optarg);
 				if (maxwaittime < 0)
 				{
-					fprintf(stderr, "usage: pg_standby -w maxwaittime incorrectly set\n");
-					usage();
+					fprintf(stderr, "%s: -w maxwaittime incorrectly set\n", progname);
 					exit(2);
 				}
 				break;
 			default:
-				usage();
+				fprintf(stderr, "Try \"%s --help\" for more information.\n", progname);
 				exit(2);
 				break;
 		}
@@ -530,7 +550,7 @@ main(int argc, char **argv)
 	 */
 	if (argc == 1)
 	{
-		usage();
+		fprintf(stderr, "%s: not enough command-line arguments\n", progname);
 		exit(2);
 	}
 
@@ -547,8 +567,8 @@ main(int argc, char **argv)
 	}
 	else
 	{
-		fprintf(stderr, "pg_standby: must specify archiveLocation\n");
-		usage();
+		fprintf(stderr, "%s: must specify archive location\n", progname);
+		fprintf(stderr, "Try \"%s --help\" for more information.\n", progname);
 		exit(2);
 	}
 
@@ -559,8 +579,8 @@ main(int argc, char **argv)
 	}
 	else
 	{
-		fprintf(stderr, "pg_standby: use %%f to specify nextWALFileName\n");
-		usage();
+		fprintf(stderr, "%s: use %%f to specify nextWALFileName\n", progname);
+		fprintf(stderr, "Try \"%s --help\" for more information.\n", progname);
 		exit(2);
 	}
 
@@ -571,8 +591,8 @@ main(int argc, char **argv)
 	}
 	else
 	{
-		fprintf(stderr, "pg_standby: use %%p to specify xlogFilePath\n");
-		usage();
+		fprintf(stderr, "%s: use %%p to specify xlogFilePath\n", progname);
+		fprintf(stderr, "Try \"%s --help\" for more information.\n", progname);
 		exit(2);
 	}
 
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 4cc7b8b19ee1aa884a42c17dedc09081f10afd4e..fc77a852d2b538dd856a73ec089391b40cec1e0d 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -4,7 +4,7 @@
  * A simple benchmark program for PostgreSQL
  * Originally written by Tatsuo Ishii and enhanced by many contributors.
  *
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.84 2009/02/25 13:24:40 petere Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.85 2009/02/27 09:30:21 petere Exp $
  * Copyright (c) 2000-2009, PostgreSQL Global Development Group
  * ALL RIGHTS RESERVED;
  *
@@ -250,10 +250,41 @@ diffTime(struct timeval *t1, struct timeval *t2, struct timeval *result)
 }
 
 static void
-usage(void)
+usage(const char *progname)
 {
-	fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions | -T duration][-s scaling_factor][-D varname=value][-n][-C][-v][-S][-N][-M querymode][-f filename][-l][-U login][-d][dbname]\n");
-	fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor] [-F fillfactor] [-U login][-d][dbname]\n");
+	printf("%s is a benchmarking tool for PostgreSQL.\n\n"
+		   "Usage:\n"
+		   "  %s [OPTIONS]... [DBNAME]\n"
+		   "\nInitialization options:\n"
+		   "  -i           invokes initialization mode\n"
+		   "  -F NUM       fill factor\n"
+		   "  -s NUM       scaling factor\n"
+		   "\nBenchmarking options:\n"
+		   "  -c NUM       number of concurrent database clients (default: 1)\n"
+		   "  -C           establish new connection for each transaction\n"
+		   "  -D VARNAME=VALUE\n"
+		   "               define variable for use by custom script\n"
+		   "  -f FILENAME  read transaction script from FILENAME\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 \"tellers\" and \"branches\"\n"
+		   "  -s NUM       report scale factor in output\n"
+		   "  -S           perform SELECT-only transactions\n"
+		   "  -t NUM       number of transactions each client runs (default: 10)\n"
+		   "  -T NUM       duration of benchmark test in seconds\n"
+		   "  -v           vacuum all four standard tables before tests\n"
+		   "\nCommon options:\n"
+		   "  -d           print debugging output\n"
+		   "  -h HOSTNAME  database server host or socket directory\n"
+		   "  -p PORT      database server port number\n"
+		   "  -U USERNAME  connect as specified database user\n"
+		   "  --help       show this help, then exit\n"
+		   "  --version    output version information, then exit\n"
+		   "\n"
+		   "Report bugs to <pgsql-bugs@postgresql.org>.\n",
+		   progname, progname);
 }
 
 /* random number generator: uniform distribution from min to max inclusive */
@@ -1499,6 +1530,24 @@ main(int argc, char **argv)
 
 	char		val[64];
 
+	const char *progname;
+
+	progname = get_progname(argv[0]);
+
+	if (argc > 1)
+	{
+		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+		{
+			usage(progname);
+			exit(0);
+		}
+		if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+		{
+			puts("pgbench (PostgreSQL) " PG_VERSION);
+			exit(0);
+		}
+	}
+
 #ifdef WIN32
 	/* stderr is buffered on Win32. */
 	setvbuf(stderr, NULL, _IONBF, 0);
@@ -1652,7 +1701,7 @@ main(int argc, char **argv)
 			case 'M':
 				if (num_files > 0)
 				{
-					fprintf(stderr, "querymode(-M) should be specifiled before transaction scripts(-f)\n");
+					fprintf(stderr, "query mode (-M) should be specifiled before transaction scripts (-f)\n");
 					exit(1);
 				}
 				for (querymode = 0; querymode < NUM_QUERYMODE; querymode++)
@@ -1660,12 +1709,12 @@ main(int argc, char **argv)
 						break;
 				if (querymode >= NUM_QUERYMODE)
 				{
-					fprintf(stderr, "invalid querymode(-M): %s\n", optarg);
+					fprintf(stderr, "invalid query mode (-M): %s\n", optarg);
 					exit(1);
 				}
 				break;
 			default:
-				usage();
+				fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
 				exit(1);
 				break;
 		}
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index 37a6c229ac423b552113583792d511c9b38c538a..b26b42cf7a908828adcd21b598c454d01a21fd8c 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/contrib/vacuumlo/vacuumlo.c,v 1.40 2009/02/26 16:02:37 petere Exp $
+ *	  $PostgreSQL: pgsql/contrib/vacuumlo/vacuumlo.c,v 1.41 2009/02/27 09:30:21 petere Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,7 +51,7 @@ struct _param
 };
 
 int			vacuumlo(char *, struct _param *);
-void		usage(void);
+void		usage(const char *progname);
 
 
 
@@ -307,10 +307,10 @@ vacuumlo(char *database, struct _param * param)
 }
 
 void
-usage(void)
+usage(const char *progname)
 {
-	printf("vacuumlo removes unreferenced large objects from databases.\n\n");
-	printf("Usage:\n  vacuumlo [OPTION]... DBNAME...\n\n");
+	printf("%s removes unreferenced large objects from databases.\n\n", progname);
+	printf("Usage:\n  %s [OPTION]... DBNAME...\n\n", progname);
 	printf("Options:\n");
 	printf("  -h HOSTNAME  database server host or socket directory\n");
 	printf("  -n           don't remove large objects, just show what would be done\n");
@@ -319,7 +319,10 @@ usage(void)
 	printf("  -w           never prompt for password\n");
 	printf("  -W           force password prompt\n");
 	printf("  -v           write a lot of progress messages\n");
+	printf("  --help       show this help, then exit\n");
+	printf("  --version    output version information, then exit\n");
 	printf("\n");
+	printf("Report bugs to <pgsql-bugs@postgresql.org>.\n");
 }
 
 
@@ -330,6 +333,9 @@ main(int argc, char **argv)
 	struct _param param;
 	int			c;
 	int			port;
+	const char *progname;
+
+	progname = get_progname(argv[0]);
 
 	/* Parameter handling */
 	param.pg_user = NULL;
@@ -339,20 +345,30 @@ main(int argc, char **argv)
 	param.verbose = 0;
 	param.dry_run = 0;
 
+	if (argc > 1)
+	{
+		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
+		{
+			usage(progname);
+			exit(0);
+		}
+		if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+		{
+			puts("vacuumlo (PostgreSQL) " PG_VERSION);
+			exit(0);
+		}
+	}
+
 	while (1)
 	{
-		c = getopt(argc, argv, "?h:U:p:vnwW");
+		c = getopt(argc, argv, "h:U:p:vnwW");
 		if (c == -1)
 			break;
 
 		switch (c)
 		{
 			case '?':
-				if (optopt == '?')
-				{
-					usage();
-					exit(0);
-				}
+				fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
 				exit(1);
 			case ':':
 				exit(1);
@@ -376,7 +392,7 @@ main(int argc, char **argv)
 				port = strtol(optarg, NULL, 10);
 				if ((port < 1) || (port > 65535))
 				{
-					fprintf(stderr, "[%s]: invalid port number '%s'\n", argv[0], optarg);
+					fprintf(stderr, "%s: invalid port number: %s\n", progname, optarg);
 					exit(1);
 				}
 				param.pg_port = strdup(optarg);
diff --git a/doc/src/sgml/pgstandby.sgml b/doc/src/sgml/pgstandby.sgml
index 2b8aad7824d2d89b97c5d94efe1f75621f7ccfd3..6b381c69ac8217a61b8ae8f478299e52a3d5cf91 100644
--- a/doc/src/sgml/pgstandby.sgml
+++ b/doc/src/sgml/pgstandby.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.6 2008/12/15 22:08:35 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.7 2009/02/27 09:30:21 petere Exp $ -->
 
 <sect1 id="pgstandby">
  <title>pg_standby</title>
@@ -199,13 +199,6 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
     </tbody>
    </tgroup>
   </table>
-  <note>
-   <para>
-    <literal>--help</literal> is not supported since
-    <application>pg_standby</application> is not intended for interactive use,
-    except during development and testing.
-   </para>
-  </note>
  </sect2>
 
  <sect2>