mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Rearrange the handling of error context reports.
Remove the code in plpgsql that suppressed the innermost line of CONTEXT for messages emitted by RAISE commands. That was never more than a quick backwards-compatibility hack, and it's pretty silly in cases where the RAISE is nested in several levels of function. What's more, it violated our design theory that verbosity of error reports should be controlled on the client side not the server side. To alleviate the resulting noise increase, introduce a feature in libpq and psql whereby the CONTEXT field of messages can be suppressed, either always or only for non-error messages. Printing CONTEXT for errors only is now their default behavior. The actual code changes here are pretty small, but the effects on the regression test outputs are widespread. I had to edit some of the alternative expected outputs by hand; hopefully the buildfarm will soon find anything I fat-fingered. In passing, fix up (again) the output line counts in psql's various help displays. Add some commentary about how to verify them. Pavel Stehule, reviewed by Petr Jelínek, Jeevan Chalke, and others
This commit is contained in:
@ -5582,6 +5582,46 @@ PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="libpq-pqseterrorcontextvisibility">
|
||||
<term>
|
||||
<function>PQsetErrorContextVisibility</function>
|
||||
<indexterm>
|
||||
<primary>PQsetErrorContextVisibility</primary>
|
||||
</indexterm>
|
||||
</term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Determines the handling of <literal>CONTEXT</> fields in messages
|
||||
returned by <function>PQerrorMessage</>
|
||||
and <function>PQresultErrorMessage</>.
|
||||
<synopsis>
|
||||
typedef enum
|
||||
{
|
||||
PQSHOW_CONTEXT_NEVER,
|
||||
PQSHOW_CONTEXT_ERRORS,
|
||||
PQSHOW_CONTEXT_ALWAYS
|
||||
} PGContextVisibility;
|
||||
|
||||
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context);
|
||||
</synopsis>
|
||||
|
||||
<function>PQsetErrorContextVisibility</> 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</>, in which
|
||||
case <literal>CONTEXT</> is never shown). The <firstterm>NEVER</> mode
|
||||
never includes <literal>CONTEXT</>, while <firstterm>ALWAYS</> always
|
||||
includes it if available. In <firstterm>ERRORS</> mode (the
|
||||
default), <literal>CONTEXT</> fields are included only for error
|
||||
messages, not for notices and warnings. Changing this mode does not
|
||||
affect the messages available from
|
||||
already-existing <structname>PGresult</> objects, only
|
||||
subsequently-created ones.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="libpq-pqtrace">
|
||||
<term>
|
||||
<function>PQtrace</function>
|
||||
|
@ -3190,6 +3190,21 @@ bar
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>SHOW_CONTEXT</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
This variable can be set to the
|
||||
values <literal>never</>, <literal>errors</>, or <literal>always</>
|
||||
to control whether <literal>CONTEXT</> fields are displayed in
|
||||
messages from the server. The default is <literal>errors</> (meaning
|
||||
that context will be shown in error messages, but not in notice or
|
||||
warning messages). This setting has no effect
|
||||
when <varname>VERBOSITY</> is set to <literal>terse</>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>SINGLELINE</varname></term>
|
||||
<listitem>
|
||||
|
Reference in New Issue
Block a user