pgsql: Add libpq support for recreating an error message with different

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Add libpq support for recreating an error message with different
Дата
Msg-id E1amkua-0005NE-F5@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Add psql \errverbose command to see last server error at full ve
Следующее
От: Simon Riggs
Дата:
Сообщение: pgsql: Avoid pin scan for replay of XLOG_BTREE_VACUUM in all cases