From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Add libpq support for recreating an error message with different
Date: Sun, 03 Apr 2016 16:30:04 +0000
Message-ID: <E1amkua-0005NE-F5@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
Add libpq support for recreating an error message with different 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 support in libpq for regenerating the error message for
an existing error PGresult at any desired verbosity level. This is almost
just a matter of refactoring the existing code into a subroutine, but there
is one bit of possibly-needed information that was not getting put into
PGresults: the text of the last query sent to the server. We must add that
string to the contents of an error PGresult. But we only need to save it
if it might be used, which with the existing error-formatting code only
happens if there is a PG_DIAG_STATEMENT_POSITION error field, which is
probably pretty rare for errors in production situations. So really the
overhead 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/e3161b231cfaadd4b6438eff2fc1f6cd086f41a9
Modified Files
--------------
doc/src/sgml/libpq.sgml | 51 +++++++++-
src/interfaces/libpq/exports.txt | 1 +
src/interfaces/libpq/fe-exec.c | 39 +++++++
src/interfaces/libpq/fe-protocol3.c | 197 ++++++++++++++++++++++--------------
src/interfaces/libpq/libpq-fe.h | 3 +
src/interfaces/libpq/libpq-int.h | 3 +
6 files changed, 217 insertions(+), 77 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
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 libpq support for recreating an error message with different
In-Reply-To: <E1amkua-0005NE-F5@gemulon.postgresql.org>
References: <E1amkua-0005NE-F5@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