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

Commit041ad9a

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 parent6fc2738 commit041ad9a

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
@@ -4571,28 +4571,6 @@ local0.* /var/log/postgresql
45714571

45724572
<variablelist>
45734573

4574-
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
4575-
<term><varname>client_min_messages</varname> (<type>enum</type>)
4576-
<indexterm>
4577-
<primary><varname>client_min_messages</> configuration parameter</primary>
4578-
</indexterm>
4579-
</term>
4580-
<listitem>
4581-
<para>
4582-
Controls which message levels are sent to the client.
4583-
Valid values are <literal>DEBUG5</>,
4584-
<literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
4585-
<literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
4586-
<literal>WARNING</>, <literal>ERROR</>, <literal>FATAL</>,
4587-
and <literal>PANIC</>. Each level
4588-
includes all the levels that follow it. The later the level,
4589-
the fewer messages are sent. The default is
4590-
<literal>NOTICE</>. Note that <literal>LOG</> has a different
4591-
rank here than in <varname>log_min_messages</>.
4592-
</para>
4593-
</listitem>
4594-
</varlistentry>
4595-
45964574
<varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
45974575
<term><varname>log_min_messages</varname> (<type>enum</type>)
45984576
<indexterm>
@@ -4610,7 +4588,7 @@ local0.* /var/log/postgresql
46104588
follow it. The later the level, the fewer messages are sent
46114589
to the log. The default is <literal>WARNING</>. Note that
46124590
<literal>LOG</> has a different rank here than in
4613-
<varname>client_min_messages</>.
4591+
<xref linkend="guc-client-min-messages">.
46144592
Only superusers can change this setting.
46154593
</para>
46164594
</listitem>
@@ -5919,6 +5897,27 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
59195897
<title>Statement Behavior</title>
59205898
<variablelist>
59215899

5900+
<varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
5901+
<term><varname>client_min_messages</varname> (<type>enum</type>)
5902+
<indexterm>
5903+
<primary><varname>client_min_messages</> configuration parameter</primary>
5904+
</indexterm>
5905+
</term>
5906+
<listitem>
5907+
<para>
5908+
Controls which message levels are sent to the client.
5909+
Valid values are <literal>DEBUG5</>,
5910+
<literal>DEBUG4</>, <literal>DEBUG3</>, <literal>DEBUG2</>,
5911+
<literal>DEBUG1</>, <literal>LOG</>, <literal>NOTICE</>,
5912+
<literal>WARNING</>, and <literal>ERROR</>.
5913+
Each level includes all the levels that follow it. The later the level,
5914+
the fewer messages are sent. The default is
5915+
<literal>NOTICE</>. Note that <literal>LOG</> has a different
5916+
rank here than in <xref linkend="guc-log-min-messages">.
5917+
</para>
5918+
</listitem>
5919+
</varlistentry>
5920+
59225921
<varlistentry id="guc-search-path" xreflabel="search_path">
59235922
<term><varname>search_path</varname> (<type>string</type>)
59245923
<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
@@ -153,6 +153,7 @@ static intsyslog_facility = 0;
153153
staticvoidassign_syslog_facility(intnewval,void*extra);
154154
staticvoidassign_syslog_ident(constchar*newval,void*extra);
155155
staticvoidassign_session_replication_role(intnewval,void*extra);
156+
staticboolcheck_client_min_messages(int*newval,void**extra,GucSourcesource);
156157
staticboolcheck_temp_buffers(int*newval,void**extra,GucSourcesource);
157158
staticboolcheck_bonjour(bool*newval,void**extra,GucSourcesource);
158159
staticboolcheck_ssl(bool*newval,void**extra,GucSourcesource);
@@ -3581,14 +3582,14 @@ static struct config_enum ConfigureNamesEnum[] =
35813582
},
35823583

35833584
{
3584-
{"client_min_messages",PGC_USERSET,LOGGING_WHEN,
3585+
{"client_min_messages",PGC_USERSET,CLIENT_CONN_STATEMENT,
35853586
gettext_noop("Sets the message levels that are sent to the client."),
35863587
gettext_noop("Each level includes all the levels that follow it. The later"
35873588
" the level, the fewer messages are sent.")
35883589
},
35893590
&client_min_messages,
35903591
NOTICE,client_message_level_options,
3591-
NULL,NULL,NULL
3592+
check_client_min_messages,NULL,NULL
35923593
},
35933594

35943595
{
@@ -9968,6 +9969,20 @@ assign_session_replication_role(int newval, void *extra)
99689969
ResetPlanCache();
99699970
}
99709971

9972+
staticbool
9973+
check_client_min_messages(int*newval,void**extra,GucSourcesource)
9974+
{
9975+
/*
9976+
* We disallow setting client_min_messages above ERROR, because not
9977+
* sending an ErrorResponse message for an error breaks the FE/BE
9978+
* protocol. However, for backwards compatibility, we still accept FATAL
9979+
* or PANIC as input values, and then adjust here.
9980+
*/
9981+
if (*newval>ERROR)
9982+
*newval=ERROR;
9983+
return true;
9984+
}
9985+
99719986
staticbool
99729987
check_temp_buffers(int*newval,void**extra,GucSourcesource)
99739988
{

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

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

374374
# - When to Log -
375375

376-
#client_min_messages = notice# values in order of decreasing detail:
377-
# debug5
378-
# debug4
379-
# debug3
380-
# debug2
381-
# debug1
382-
# log
383-
# notice
384-
# warning
385-
# error
386-
387376
#log_min_messages = warning# values in order of decreasing detail:
388377
# debug5
389378
# debug4
@@ -527,6 +516,16 @@
527516

528517
# - Statement Behavior -
529518

519+
#client_min_messages = notice# values in order of decreasing detail:
520+
# debug5
521+
# debug4
522+
# debug3
523+
# debug2
524+
# debug1
525+
# log
526+
# notice
527+
# warning
528+
# error
530529
#search_path = '"$user", public'# schema names
531530
#default_tablespace = ''# a tablespace name, '' uses the default
532531
#temp_tablespaces = ''# a list of tablespace names, '' uses

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp