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

Commit62d16c7

Browse files
committed
Improve design and implementation of pg_file_settings view.
As first committed, this view reported on the file contents as they wereat the last SIGHUP event. That's not as useful as reporting on the currentcontents, and what's more, it didn't work right on Windows unless thecurrent session had serviced at least one SIGHUP. Therefore, arrange tore-read the files when pg_show_all_settings() is called. This requiresonly minor refactoring so that we can pass changeVal = false toset_config_option() so that it won't actually apply any changes locally.In addition, add error reporting so that errors that would prevent theconfiguration files from being loaded, or would prevent individual settingsfrom being applied, are visible directly in the view. This makes the viewusable for pre-testing whether edits made in the config files will have thedesired effect, before one actually issues a SIGHUP.I also added an "applied" column so that it's easy to identify entries thatare superseded by later entries; this was the main use-case for the originaldesign, but it seemed unnecessarily hard to use for that.Also fix a 9.4.1 regression that allowed multiple entries for aPGC_POSTMASTER variable to cause bogus complaints in the postmaster log.(The issue here was that commitbf007a2 unintentionally reverted3e3f659, which suppressed any duplicate entries withinParseConfigFp. However, since the original coding of the pg_file_settingsview depended on such suppression *not* happening, we couldn't have fixedthis issue now without first doing something with pg_file_settings.Now we suppress duplicates by marking them "ignored" withinProcessConfigFileInternal, which doesn't hide them in the view.)Lesser changes include:Drive the view directly off the ConfigVariable list, instead of making abasically-equivalent second copy of the data. There's no longer any needto hang onto the data permanently, anyway.Convert show_all_file_settings() to do its work in one call and return atuplestore; this avoids risks associated with assuming that the GUC statewill hold still over the course of query execution. (I think there wereprobably latent bugs here, though you might need something like a cursoron the view to expose them.)Arrange to run SIGHUP processing in a short-lived memory context, toforestall process-lifespan memory leaks. (There is one known leak in thiscode, in ProcessConfigDirectory; it seems minor enough to not be worthback-patching a specific fix for.)Remove mistaken assignment to ConfigFileLineno that caused line countingafter an include_dir directive to be completely wrong.Add missed failure check in AlterSystemSetConfigFile(). We don't reallyexpect ParseConfigFp() to fail, but that's not an excuse for not checking.
1 parentd661532 commit62d16c7

File tree

9 files changed

+430
-245
lines changed

9 files changed

+430
-245
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7626,7 +7626,7 @@
76267626

76277627
<row>
76287628
<entry><link linkend="view-pg-file-settings"><structname>pg_file_settings</structname></link></entry>
7629-
<entry>file locationofparameter settings</entry>
7629+
<entry>summaryofconfiguration file contents</entry>
76307630
</row>
76317631

76327632
<row>
@@ -8007,13 +8007,26 @@
80078007
</indexterm>
80088008

80098009
<para>
8010-
The view <structname>pg_file_settings</structname> provides the file
8011-
name, line number and value of all parameters which are set through
8012-
configuration files.
8013-
In contrast to <structname>pg_settings</structname>, a row is provided for
8014-
each occurrence of the parameter across all configuration files. This is helpful
8015-
for discovering why one value may have been used in preference to another
8016-
when the parameters were loaded.
8010+
The view <structname>pg_file_settings</structname> provides a summary of
8011+
the contents of the server's configuration file(s). A row appears in
8012+
this view for each <quote>name = value</> entry appearing in the files,
8013+
with annotations indicating whether the value could be applied
8014+
successfully. Additional row(s) may appear for problems not linked to
8015+
a <quote>name = value</> entry, such as syntax errors in the files.
8016+
</para>
8017+
8018+
<para>
8019+
This view is helpful for checking whether planned changes in the
8020+
configuration files will work, or for diagnosing a previous failure.
8021+
Note that this view reports on the <emphasis>current</> contents of the
8022+
files, not on what was last applied by the server. (The
8023+
<link linkend="view-pg-settings"><structname>pg_settings</structname></link>
8024+
view is usually sufficient to determine that.)
8025+
</para>
8026+
8027+
<para>
8028+
The <structname>pg_file_settings</structname> view can be read only by
8029+
superusers.
80178030
</para>
80188031

80198032
<table>
@@ -8031,43 +8044,64 @@
80318044
<row>
80328045
<entry><structfield>sourcefile</structfield></entry>
80338046
<entry><structfield>text</structfield></entry>
8034-
<entry>Path to and nameof theconfigration file</entry>
8047+
<entry>Full pathnameof theconfiguration file</entry>
80358048
</row>
80368049
<row>
80378050
<entry><structfield>sourceline</structfield></entry>
80388051
<entry><structfield>integer</structfield></entry>
80398052
<entry>
8040-
Line number within the configuration file where thevalue was set
8053+
Line number within the configuration file where theentry appears
80418054
</entry>
80428055
</row>
80438056
<row>
80448057
<entry><structfield>seqno</structfield></entry>
80458058
<entry><structfield>integer</structfield></entry>
8046-
<entry>Order in which thesetting was loaded</entry>
8059+
<entry>Order in which theentries are processed (1..<replaceable>n</>)</entry>
80478060
</row>
80488061
<row>
80498062
<entry><structfield>name</structfield></entry>
80508063
<entry><structfield>text</structfield></entry>
8051-
<entry>Run-time configuration parameter name</entry>
8064+
<entry>Configuration parameter name</entry>
80528065
</row>
80538066
<row>
80548067
<entry><structfield>setting</structfield></entry>
80558068
<entry><structfield>text</structfield></entry>
8056-
<entry>value of the parameter</entry>
8069+
<entry>Value to be assigned to the parameter</entry>
8070+
</row>
8071+
<row>
8072+
<entry><structfield>applied</structfield></entry>
8073+
<entry><structfield>boolean</structfield></entry>
8074+
<entry>True if the value can be applied successfully</entry>
8075+
</row>
8076+
<row>
8077+
<entry><structfield>error</structfield></entry>
8078+
<entry><structfield>text</structfield></entry>
8079+
<entry>If not null, an error message indicating why this entry could
8080+
not be applied</entry>
80578081
</row>
80588082
</tbody>
80598083
</tgroup>
8060-
</table>
8084+
</table>
80618085

80628086
<para>
8063-
See <xref linkend="config-setting"> for more information about the various
8064-
ways to change these parameters.
8087+
If the configuration file contains syntax errors or invalid parameter
8088+
names, the server will not attempt to apply any settings from it, and
8089+
therefore all the <structfield>applied</> fields will read as false.
8090+
In such a case there will be one or more rows with
8091+
non-null <structfield>error</structfield> fields indicating the
8092+
problem(s). Otherwise, individual settings will be applied if possible.
8093+
If an individual setting cannot be applied (e.g., invalid value, or the
8094+
setting cannot be changed after server start) it will have an appropriate
8095+
message in the <structfield>error</structfield> field. Another way that
8096+
an entry might have <structfield>applied</> = false is that it is
8097+
overridden by a later entry for the same parameter name; this case is not
8098+
considered an error so nothing appears in
8099+
the <structfield>error</structfield> field.
80658100
</para>
80668101

80678102
<para>
8068-
The <structname>pg_file_settings</structname> view cannot be modified
8069-
directly as it represents information, as read in at server start or
8070-
reload time, about all parameter settings across all configuration files.
8103+
See <xref linkend="config-setting"> for more information about the various
8104+
ways to change run-time parameters.
80718105
</para>
80728106

80738107
</sect1>

‎doc/src/sgml/config.sgml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ shared_buffers = 128MB
175175
effect in the same way. Settings in <filename>postgresql.auto.conf</>
176176
override those in <filename>postgresql.conf</>.
177177
</para>
178+
179+
<para>
180+
The system view
181+
<link linkend="view-pg-file-settings"><structname>pg_file_settings</structname></link>
182+
can be helpful for pre-testing changes to the configuration file, or for
183+
diagnosing problems if a <systemitem>SIGHUP</> signal did not have the
184+
desired effects.
185+
</para>
178186
</sect2>
179187

180188
<sect2 id="config-setting-sql-command-interaction">

‎doc/src/sgml/release-9.5.sgml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<note>
88
<title>Release Date</title>
9-
<para>AS OF2015-06-01</para>
10-
<simpara>2015-XX-XX</simpara>
9+
<simpara>2015-??-??</simpara>
10+
<simpara>Current as of2015-06-01</simpara>
1111
</note>
1212

1313
<sect2>
@@ -23,6 +23,7 @@
2323

2424
<listitem>
2525
<para>
26+
... to be filled in ...
2627
</para>
2728
</listitem>
2829

@@ -480,10 +481,10 @@
480481

481482
<listitem>
482483
<para>
483-
Addfunction and view <link
484-
linkend="view-pg-file-settings"><function>pg_file_settings</></>
485-
to show thesource of<acronym>GUC</> values set inconfiguration
486-
files(Sawada Masahiko)
484+
Addsystem view <link
485+
linkend="view-pg-file-settings"><structname>pg_file_settings</></>
486+
to show thecontents ofthe server'sconfiguration files
487+
(Sawada Masahiko)
487488
</para>
488489
</listitem>
489490

@@ -503,7 +504,7 @@
503504
</para>
504505

505506
<para>
506-
This removes the setting from <filename>postgresql.auto.conf</>.
507+
Thiscommandremoves the setting from <filename>postgresql.auto.conf</>.
507508
</para>
508509
</listitem>
509510

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp