aboutsummaryrefslogtreecommitdiff
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:23 +0200
commit14fa9805604e829d96531581e71b45ddfddb4fc8 (patch)
tree4cb28521d0b7068603b96e859b3bf27a0f908857
parentd4c78c1811d14b14f47f3611bf2c2c1a35817988 (diff)
downloadpostgresql-14fa9805604e829d96531581e71b45ddfddb4fc8.tar.gz
postgresql-14fa9805604e829d96531581e71b45ddfddb4fc8.zip
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.
-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 ac5edca65dd..ccbd542c617 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -157,6 +157,11 @@ void
slashUsage(unsigned short int pager)
{
FILE *output;
+ char *currdb;
+
+ currdb = PQdb(pset.db);
+ if (currdb == NULL)
+ currdb = _("none");
output = PageOutput(92, pager);
@@ -248,7 +253,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"));