1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Disallow setting client_min_messages higher than ERROR.

Previously it was possible to set client_min_messages to FATAL or PANIC,
which had the effect of suppressing transmission of regular ERROR messages
to the client.  Perhaps that seemed like a useful option in the past, but
the trouble with it is that it breaks guarantees that are explicitly made
in our FE/BE protocol spec about how a query cycle can end.  While libpq
and psql manage to cope with the omission, that's mostly because they
are not very bright; client libraries that have more semantic knowledge
are likely to get confused.  Notably, pgODBC doesn't behave very sanely.
Let's fix this by getting rid of the ability to set client_min_messages
above ERROR.

In HEAD, just remove the FATAL and PANIC options from the set of allowed
enum values for client_min_messages.  (This change also affects
trace_recovery_messages, but that's OK since these aren't useful values
for that variable either.)

In the back branches, there was concern that rejecting these values might
break applications that are explicitly setting things that way.  I'm
pretty skeptical of that argument, but accommodate it by accepting these
values and then internally setting the variable to ERROR anyway.

In all branches, this allows a couple of tiny simplifications in the
logic in elog.c, so do that.

Also respond to the point that was made that client_min_messages has
exactly nothing to do with the server's logging behavior, and therefore
does not belong in the "When To Log" subsection of the documentation.
The "Statement Behavior" subsection is a better match, so move it there.

Jonah Harris and Tom Lane

Discussion: https://postgr.es/m/7809.1541521180@sss.pgh.pa.us
Discussion: https://postgr.es/m/15479-ef0f4cc2fd995ca2@postgresql.org
This commit is contained in:
Tom Lane
2018-11-08 17:33:26 -05:00
parent 21c9e4973c
commit c09daa9104
4 changed files with 51 additions and 45 deletions

View File

@ -4799,28 +4799,6 @@ local0.* /var/log/postgresql
<variablelist>
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
<term><varname>client_min_messages</varname> (<type>enum</type>)
<indexterm>
<primary><varname>client_min_messages</> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Controls which message levels are sent to the client.
Valid values are <literal>DEBUG5</>,
<literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
<literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
<literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
and <literal>PANIC</>. Each level
includes all the levels that follow it. The later the level,
the fewer messages are sent. The default is
<literal>NOTICE</>. Note that <literal>LOG</> has a different
rank here than in <varname>log_min_messages</>.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
<term><varname>log_min_messages</varname> (<type>enum</type>)
<indexterm>
@ -4838,7 +4816,7 @@ local0.* /var/log/postgresql
follow it. The later the level, the fewer messages are sent
to the log. The default is <literal>WARNING</>. Note that
<literal>LOG</> has a different rank here than in
<varname>client_min_messages</>.
<xref linkend="guc-client-min-messages">.
Only superusers can change this setting.
</para>
</listitem>
@ -6159,6 +6137,27 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
<title>Statement Behavior</title>
<variablelist>
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
<term><varname>client_min_messages</varname> (<type>enum</type>)
<indexterm>
<primary><varname>client_min_messages</> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Controls which message levels are sent to the client.
Valid values are <literal>DEBUG5</>,
<literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
<literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
<literal>WARNING</>, and <literal>ERROR</>.
Each level includes all the levels that follow it. The later the level,
the fewer messages are sent. The default is
<literal>NOTICE</>. Note that <literal>LOG</> has a different
rank here than in <xref linkend="guc-log-min-messages">.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-search-path" xreflabel="search_path">
<term><varname>search_path</varname> (<type>string</type>)
<indexterm>