postgres.git / summary / log / commit / refs
commit 63b0b397c7781b429eda1f4e294dce4cdf12cac7
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Tue Jan 15 16:54:03 2013 +0000
First released in: 9.3.0, 8.3.23, 8.4.16, 9.0.12, 9.1.8, 9.2.3
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.
src/bin/psql/help.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 5e52259df8a..cfe59721376 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -159,6 +159,11 @@ void
slashUsage(unsigned short int pager)
{
FILE *output;
+ char *currdb;
+
+ currdb = PQdb(pset.db);
+ if (currdb == NULL)
+ currdb = _("none");
output = PageOutput(69, pager);
@@ -171,7 +176,7 @@ slashUsage(unsigned short int pager)
fprintf(output, _("General\n"));
fprintf(output, _(" \\c[onnect] [DBNAME|- USER|- HOST|- PORT|-]\n"
" connect to new database (currently \"%s\")\n"),
- PQdb(pset.db));
+ currdb);
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n"));
fprintf(output, _(" \\encoding [ENCODING]\n"
[parent: 0af83bd53020]