Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b08b4a

Browse files
committed
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 messagesto the client. Perhaps that seemed like a useful option in the past, butthe trouble with it is that it breaks guarantees that are explicitly madein our FE/BE protocol spec about how a query cycle can end. While libpqand psql manage to cope with the omission, that's mostly because theyare not very bright; client libraries that have more semantic knowledgeare 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_messagesabove ERROR.In HEAD, just remove the FATAL and PANIC options from the set of allowedenum values for client_min_messages. (This change also affectstrace_recovery_messages, but that's OK since these aren't useful valuesfor that variable either.)In the back branches, there was concern that rejecting these values mightbreak applications that are explicitly setting things that way. I'mpretty skeptical of that argument, but accommodate it by accepting thesevalues and then internally setting the variable to ERROR anyway.In all branches, this allows a couple of tiny simplifications in thelogic in elog.c, so do that.Also respond to the point that was made that client_min_messages hasexactly nothing to do with the server's logging behavior, and thereforedoes 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 LaneDiscussion:https://postgr.es/m/7809.1541521180@sss.pgh.pa.usDiscussion:https://postgr.es/m/15479-ef0f4cc2fd995ca2@postgresql.org
1 parente0c05bf commit7b08b4a

File tree

4 files changed

+51
-45
lines changed

4 files changed

+51
-45
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,28 +5077,6 @@ local0.* /var/log/postgresql
50775077

50785078
<variablelist>
50795079

5080-
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
5081-
<term><varname>client_min_messages</varname> (<type>enum</type>)
5082-
<indexterm>
5083-
<primary><varname>client_min_messages</varname> configuration parameter</primary>
5084-
</indexterm>
5085-
</term>
5086-
<listitem>
5087-
<para>
5088-
Controls which message levels are sent to the client.
5089-
Valid values are <literal>DEBUG5</literal>,
5090-
<literal>DEBUG4</literal>, <literal>DEBUG3</literal>, <literal>DEBUG2</literal>,
5091-
<literal>DEBUG1</literal>, <literal>LOG</literal>, <literal>NOTICE</literal>,
5092-
<literal>WARNING</literal>, <literal>ERROR</literal>, <literal>FATAL</literal>,
5093-
and <literal>PANIC</literal>. Each level
5094-
includes all the levels that follow it. The later the level,
5095-
the fewer messages are sent. The default is
5096-
<literal>NOTICE</literal>. Note that <literal>LOG</literal> has a different
5097-
rank here than in <varname>log_min_messages</varname>.
5098-
</para>
5099-
</listitem>
5100-
</varlistentry>
5101-
51025080
<varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
51035081
<term><varname>log_min_messages</varname> (<type>enum</type>)
51045082
<indexterm>
@@ -5116,7 +5094,7 @@ local0.* /var/log/postgresql
51165094
follow it. The later the level, the fewer messages are sent
51175095
to the log. The default is <literal>WARNING</literal>. Note that
51185096
<literal>LOG</literal> has a different rank here than in
5119-
<varname>client_min_messages</varname>.
5097+
<xref linkend="guc-client-min-messages"/>.
51205098
Only superusers can change this setting.
51215099
</para>
51225100
</listitem>
@@ -6437,6 +6415,27 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
64376415
<title>Statement Behavior</title>
64386416
<variablelist>
64396417

6418+
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
6419+
<term><varname>client_min_messages</varname> (<type>enum</type>)
6420+
<indexterm>
6421+
<primary><varname>client_min_messages</varname> configuration parameter</primary>
6422+
</indexterm>
6423+
</term>
6424+
<listitem>
6425+
<para>
6426+
Controls which message levels are sent to the client.
6427+
Valid values are <literal>DEBUG5</literal>,
6428+
<literal>DEBUG4</literal>, <literal>DEBUG3</literal>, <literal>DEBUG2</literal>,
6429+
<literal>DEBUG1</literal>, <literal>LOG</literal>, <literal>NOTICE</literal>,
6430+
<literal>WARNING</literal>, and <literal>ERROR</literal>.
6431+
Each level includes all the levels that follow it. The later the level,
6432+
the fewer messages are sent. The default is
6433+
<literal>NOTICE</literal>. Note that <literal>LOG</literal> has a different
6434+
rank here than in <xref linkend="guc-log-min-messages"/>.
6435+
</para>
6436+
</listitem>
6437+
</varlistentry>
6438+
64406439
<varlistentry id="guc-search-path" xreflabel="search_path">
64416440
<term><varname>search_path</varname> (<type>string</type>)
64426441
<indexterm>

‎src/backend/utils/error/elog.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ errfinish(int dummy,...)
472472
* progress, so that we can report the message before dying. (Without
473473
* this, pq_putmessage will refuse to send the message at all, which is
474474
* what we want for NOTICE messages, but not for fatal exits.) This hack
475-
* is necessary because of poor design of old-style copy protocol. Note
476-
* we must do this even if client is fool enough to have set
477-
* client_min_messages above FATAL, so don't look at output_to_client.
475+
* is necessary because of poor design of old-style copy protocol.
478476
*/
479477
if (elevel >=FATAL&&whereToSendOutput==DestRemote)
480478
pq_endcopyout(true);
@@ -1758,12 +1756,7 @@ pg_re_throw(void)
17581756
else
17591757
edata->output_to_server= (FATAL >=log_min_messages);
17601758
if (whereToSendOutput==DestRemote)
1761-
{
1762-
if (ClientAuthInProgress)
1763-
edata->output_to_client= true;
1764-
else
1765-
edata->output_to_client= (FATAL >=client_min_messages);
1766-
}
1759+
edata->output_to_client= true;
17671760

17681761
/*
17691762
* We can use errfinish() for the rest, but we don't want it to call

‎src/backend/utils/misc/guc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static intsyslog_facility = 0;
164164
staticvoidassign_syslog_facility(intnewval,void*extra);
165165
staticvoidassign_syslog_ident(constchar*newval,void*extra);
166166
staticvoidassign_session_replication_role(intnewval,void*extra);
167+
staticboolcheck_client_min_messages(int*newval,void**extra,GucSourcesource);
167168
staticboolcheck_temp_buffers(int*newval,void**extra,GucSourcesource);
168169
staticboolcheck_bonjour(bool*newval,void**extra,GucSourcesource);
169170
staticboolcheck_ssl(bool*newval,void**extra,GucSourcesource);
@@ -3912,14 +3913,14 @@ static struct config_enum ConfigureNamesEnum[] =
39123913
},
39133914

39143915
{
3915-
{"client_min_messages",PGC_USERSET,LOGGING_WHEN,
3916+
{"client_min_messages",PGC_USERSET,CLIENT_CONN_STATEMENT,
39163917
gettext_noop("Sets the message levels that are sent to the client."),
39173918
gettext_noop("Each level includes all the levels that follow it. The later"
39183919
" the level, the fewer messages are sent.")
39193920
},
39203921
&client_min_messages,
39213922
NOTICE,client_message_level_options,
3922-
NULL,NULL,NULL
3923+
check_client_min_messages,NULL,NULL
39233924
},
39243925

39253926
{
@@ -10410,6 +10411,20 @@ assign_session_replication_role(int newval, void *extra)
1041010411
ResetPlanCache();
1041110412
}
1041210413

10414+
staticbool
10415+
check_client_min_messages(int*newval,void**extra,GucSourcesource)
10416+
{
10417+
/*
10418+
* We disallow setting client_min_messages above ERROR, because not
10419+
* sending an ErrorResponse message for an error breaks the FE/BE
10420+
* protocol. However, for backwards compatibility, we still accept FATAL
10421+
* or PANIC as input values, and then adjust here.
10422+
*/
10423+
if (*newval>ERROR)
10424+
*newval=ERROR;
10425+
return true;
10426+
}
10427+
1041310428
staticbool
1041410429
check_temp_buffers(int*newval,void**extra,GucSourcesource)
1041510430
{

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -405,17 +405,6 @@
405405

406406
# - When to Log -
407407

408-
#client_min_messages = notice# values in order of decreasing detail:
409-
# debug5
410-
# debug4
411-
# debug3
412-
# debug2
413-
# debug1
414-
# log
415-
# notice
416-
# warning
417-
# error
418-
419408
#log_min_messages = warning# values in order of decreasing detail:
420409
# debug5
421410
# debug4
@@ -560,6 +549,16 @@
560549

561550
# - Statement Behavior -
562551

552+
#client_min_messages = notice# values in order of decreasing detail:
553+
# debug5
554+
# debug4
555+
# debug3
556+
# debug2
557+
# debug1
558+
# log
559+
# notice
560+
# warning
561+
# error
563562
#search_path = '"$user", public'# schema names
564563
#row_security = on
565564
#default_tablespace = ''# a tablespace name, '' uses the default

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp