aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-04-04 17:22:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-04-04 17:22:02 -0400
commit7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc (patch)
treec6d41d068592bc1d566c035e5f0d52828f738acf /doc/src
parent413ccaa74d9a126b042727c826e65e2844adadac (diff)
downloadpostgresql-7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc.tar.gz
postgresql-7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc.zip
Add a "SQLSTATE-only" error verbosity option to libpq and psql.
This is intended for use mostly in test scripts for external tools, which could do without cross-PG-version variations in error message wording. Of course, the SQLSTATE isn't guaranteed stable either, but it should be more so than the error message text. Note: there's a bit of an ABI change for libpq here, but it seems OK because if somebody compiles against a newer version of libpq-fe.h, and then tries to pass PQERRORS_SQLSTATE to PQsetErrorVerbosity() of an older libpq library, it will be accepted and then act like PQERRORS_DEFAULT, thanks to the way the tests in pqBuildErrorMessage3 have historically been phrased. That seems acceptable. Didier Gautheron, reviewed by Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/CAJRYxuKyj4zA+JGVrtx8OWAuBfE-_wN4sUMK4H49EuPed=mOBw@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/libpq.sgml45
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml8
2 files changed, 35 insertions, 18 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 0863a02411d..a97af98979b 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -6014,21 +6014,30 @@ typedef enum
{
PQERRORS_TERSE,
PQERRORS_DEFAULT,
- PQERRORS_VERBOSE
+ PQERRORS_VERBOSE,
+ PQERRORS_SQLSTATE
} PGVerbosity;
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
</synopsis>
- <function>PQsetErrorVerbosity</function> sets the verbosity mode, returning
- the connection's previous setting. In <firstterm>TERSE</firstterm> mode,
- returned messages include severity, primary text, and position only;
- this will normally fit on a single line. The default mode produces
- messages that include the above plus any detail, hint, or context
- fields (these might span multiple lines). The <firstterm>VERBOSE</firstterm>
- mode includes all available fields. Changing the verbosity does not
- affect the messages available from already-existing
- <structname>PGresult</structname> objects, only subsequently-created ones.
+ <function>PQsetErrorVerbosity</function> sets the verbosity mode,
+ returning the connection's previous setting.
+ In <firstterm>TERSE</firstterm> mode, returned messages include
+ severity, primary text, and position only; this will normally fit on a
+ single line. The default mode produces messages that include the above
+ plus any detail, hint, or context fields (these might span multiple
+ lines). The <firstterm>VERBOSE</firstterm> mode includes all available
+ fields. The <firstterm>SQLSTATE</firstterm> mode includes only the
+ error severity and the <symbol>SQLSTATE</symbol> error code, if one is
+ available (if not, the output is like <firstterm>TERSE</firstterm>
+ mode).
+ </para>
+
+ <para>
+ Changing the verbosity setting does not affect the messages available
+ from already-existing <structname>PGresult</structname> objects, only
+ subsequently-created ones.
(But see <function>PQresultVerboseErrorMessage</function> if you
want to print a previous error with a different verbosity.)
</para>
@@ -6061,13 +6070,19 @@ PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibilit
<function>PQsetErrorContextVisibility</function> sets the context display mode,
returning the connection's previous setting. This mode controls
- whether the <literal>CONTEXT</literal> field is included in messages
- (unless the verbosity setting is <firstterm>TERSE</firstterm>, in which
- case <literal>CONTEXT</literal> is never shown). The <firstterm>NEVER</firstterm> mode
+ whether the <literal>CONTEXT</literal> field is included in messages.
+ The <firstterm>NEVER</firstterm> mode
never includes <literal>CONTEXT</literal>, while <firstterm>ALWAYS</firstterm> always
includes it if available. In <firstterm>ERRORS</firstterm> mode (the
- default), <literal>CONTEXT</literal> fields are included only for error
- messages, not for notices and warnings. Changing this mode does not
+ default), <literal>CONTEXT</literal> fields are included only in error
+ messages, not in notices and warnings.
+ (However, if the verbosity setting is <firstterm>TERSE</firstterm>
+ or <firstterm>SQLSTATE</firstterm>, <literal>CONTEXT</literal> fields
+ are omitted regardless of the context display mode.)
+ </para>
+
+ <para>
+ Changing this mode does not
affect the messages available from
already-existing <structname>PGresult</structname> objects, only
subsequently-created ones.
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index b29e7547c6a..2bc8bbc2a74 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -3892,7 +3892,8 @@ bar
messages from the server. The default is <literal>errors</literal> (meaning
that context will be shown in error messages, but not in notice or
warning messages). This setting has no effect
- when <varname>VERBOSITY</varname> is set to <literal>terse</literal>.
+ when <varname>VERBOSITY</varname> is set to <literal>terse</literal>
+ or <literal>sqlstate</literal>.
(See also <command>\errverbose</command>, for use when you want a verbose
version of the error you just got.)
</para>
@@ -3946,8 +3947,9 @@ bar
<listitem>
<para>
This variable can be set to the values <literal>default</literal>,
- <literal>verbose</literal>, or <literal>terse</literal> to control the verbosity
- of error reports.
+ <literal>verbose</literal>, <literal>terse</literal>,
+ or <literal>sqlstate</literal> to control the verbosity of error
+ reports.
(See also <command>\errverbose</command>, for use when you want a verbose
version of the error you just got.)
</para>