aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2008-04-04 17:42:43 +0000
committerBruce Momjian <bruce@momjian.us>2008-04-04 17:42:43 +0000
commitdc565af4547389429c3362e34f57c3335f15bd01 (patch)
tree5a8eb6b90db2ead20845be48e06de96435a93adc /src
parenta051ab0a80659be449cd8b3dd9b1931b8213433e (diff)
downloadpostgresql-dc565af4547389429c3362e34f57c3335f15bd01.tar.gz
postgresql-dc565af4547389429c3362e34f57c3335f15bd01.zip
Allow 'help' in psql to show \? help, for novice assistance.
Greg Sabino Mullane
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/help.c3
-rw-r--r--src/bin/psql/mainloop.c13
2 files changed, 14 insertions, 2 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 22ba847a9bc..cb60dd8759d 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.124 2008/03/29 19:40:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.125 2008/04/04 17:42:43 momjian Exp $
*/
#include "postgres_fe.h"
@@ -188,6 +188,7 @@ slashUsage(unsigned short int pager)
ON(pset.timing));
fprintf(output, _(" \\unset NAME unset (delete) internal variable\n"));
fprintf(output, _(" \\! [COMMAND] execute command in shell or start interactive shell\n"));
+ fprintf(output, _(" \\? display this help output\n"));
fprintf(output, "\n");
fprintf(output, _("Query Buffer\n"));
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 613dab0506e..3cdcd2d3cd6 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.87 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.88 2008/04/04 17:42:43 momjian Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -11,6 +11,7 @@
#include "command.h"
#include "common.h"
+#include "help.h"
#include "input.h"
#include "settings.h"
@@ -171,6 +172,16 @@ MainLoop(FILE *source)
continue;
}
+ /* A request for help? Be friendly and show them the slash way of doing things */
+ if (pset.cur_cmd_interactive && query_buf->len == 0 &&
+ pg_strncasecmp(line, "help", 4) == 0 &&
+ (line[4] == '\0' || line[4] == ';' || isspace(line[4])))
+ {
+ free(line);
+ slashUsage(pset.popt.topt.pager);
+ continue;
+ }
+
/* echo back if flag is set */
if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive)
puts(line);