summaryrefslogtreecommitdiff
path: root/src/bin/psql/help.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-01-15 18:54:03 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-01-15 19:20:15 +0200
commitee0ef989f38c1ac482673766636ba89940977913 (patch)
tree8ee121fc6b10e89c7535524b2e54231423e07f0f /src/bin/psql/help.c
parent0471b013aab87ebfbb767e9456c7b619d5c2b9d3 (diff)
Don't pass NULL to fprintf, if not currently connected to a database.
Backpatch all the way to 8.3. Fixes bug #7811, per report and diagnosis by Meng Qingzhong.
Diffstat (limited to 'src/bin/psql/help.c')
-rw-r--r--src/bin/psql/help.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 717d4cd10cf..58f8a0b0167 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -161,6 +161,11 @@ void
slashUsage(unsigned short int pager)
{
FILE *output;
+ char *currdb;
+
+ currdb = PQdb(pset.db);
+ if (currdb == NULL)
+ currdb = _("none");
output = PageOutput(94, pager);
@@ -253,7 +258,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _("Connection\n"));
fprintf(output, _(" \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
" connect to new database (currently \"%s\")\n"),
- PQdb(pset.db));
+ currdb);
fprintf(output, _(" \\encoding [ENCODING] show or set client encoding\n"));
fprintf(output, _(" \\password [USERNAME] securely change the password for a user\n"));
fprintf(output, _(" \\conninfo display information about current connection\n"));