pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Add psql \errverbose command to see last server error at full ve
Date: Sun, 03 Apr 2016 16:30:04 +0000
Message-ID: <E1amkua-0005NF-F8@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3cc38ca7d21255721d600eb75d7cc6708c14764b

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 18 +++++++++++++
src/bin/psql/command.c         | 22 ++++++++++++++++
src/bin/psql/common.c          | 57 +++++++++++++++++++++++++++++++-----------
src/bin/psql/help.c            |  3 ++-
src/bin/psql/settings.h        |  2 ++
src/bin/psql/startup.c         |  1 +
src/bin/psql/tab-complete.c    |  2 +-
7 files changed, 88 insertions(+), 17 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1amkua-0005NF-F8@gemulon.postgresql.org>
Permalink:  ../E1amkua-0005NF-F8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1amkua-0005NF-F8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Add psql \errverbose command to see last server error at full ve
  In-Reply-To: <E1amkua-0005NF-F8@gemulon.postgresql.org>
  References: <E1amkua-0005NF-F8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox