postgres.git / summary / log / commit / refs
commit b04ce529fd38b1d00492d03acf896f9293b6fb28
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 1070bc521e0..ef36583db8b 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);
@@ -254,7 +259,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"));
[parent: 7ac5760fa283]