diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-04-03 12:29:55 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-04-03 12:29:55 -0400 |
commit | 3cc38ca7d21255721d600eb75d7cc6708c14764b (patch) | |
tree | 0e06239939dd831361a1c248c36db94d5ff1e33d /src/bin/psql/help.c | |
parent | e3161b231cfaadd4b6438eff2fc1f6cd086f41a9 (diff) | |
download | postgresql-3cc38ca7d21255721d600eb75d7cc6708c14764b.tar.gz postgresql-3cc38ca7d21255721d600eb75d7cc6708c14764b.zip |
Add psql \errverbose command to see last server error at full verbosity.
Often, upon getting an unexpected error in psql, one's first wish is that
the verbosity setting had been higher; for example, to be able to see the
schema-name field or the server code location info. Up to now the only way
has been to adjust the VERBOSITY variable and repeat the failing query.
That's a pain, and it doesn't work if the error isn't reproducible.
This commit adds a psql feature that redisplays the most recent server
error at full verbosity, without needing to make any variable changes or
re-execute the failed command. We just need to hang onto the latest error
PGresult in case the user executes \errverbose, and then apply libpq's
new PQresultVerboseErrorMessage() function to it. This will consume
some trivial amount of psql memory, but otherwise the cost when the
feature isn't used should be negligible.
Alex Shulgin, reviewed by Daniel Vérité, some improvements by me
Diffstat (limited to 'src/bin/psql/help.c')
-rw-r--r-- | src/bin/psql/help.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 59f6f259dcd..c6f0993018f 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -168,10 +168,11 @@ slashUsage(unsigned short int pager) * Use "psql --help=commands | wc" to count correctly. It's okay to count * the USE_READLINE line even in builds without that. */ - output = PageOutput(109, pager ? &(pset.popt.topt) : NULL); + output = PageOutput(110, pager ? &(pset.popt.topt) : NULL); fprintf(output, _("General\n")); fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n")); + fprintf(output, _(" \\errverbose show most recent error message at maximum verbosity\n")); fprintf(output, _(" \\g [FILE] or ; execute query (and send results to file or |pipe)\n")); fprintf(output, _(" \\gset [PREFIX] execute query and store results in psql variables\n")); fprintf(output, _(" \\q quit psql\n")); |