pgsql: Improve design and implementation of pg_file_settings view.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve design and implementation of pg_file_settings view.
Дата
Msg-id E1Z9KiZ-0000J0-F3@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve design and implementation of pg_file_settings view.

As first committed, this view reported on the file contents as they were
at the last SIGHUP event.  That's not as useful as reporting on the current
contents, and what's more, it didn't work right on Windows unless the
current session had serviced at least one SIGHUP.  Therefore, arrange to
re-read the files when pg_show_all_settings() is called.  This requires
only minor refactoring so that we can pass changeVal = false to
set_config_option() so that it won't actually apply any changes locally.

In addition, add error reporting so that errors that would prevent the
configuration files from being loaded, or would prevent individual settings
from being applied, are visible directly in the view.  This makes the view
usable for pre-testing whether edits made in the config files will have the
desired effect, before one actually issues a SIGHUP.

I also added an "applied" column so that it's easy to identify entries that
are superseded by later entries; this was the main use-case for the original
design, but it seemed unnecessarily hard to use for that.

Also fix a 9.4.1 regression that allowed multiple entries for a
PGC_POSTMASTER variable to cause bogus complaints in the postmaster log.
(The issue here was that commit bf007a27acd7b2fb unintentionally reverted
3e3f65973a3c94a6, which suppressed any duplicate entries within
ParseConfigFp.  However, since the original coding of the pg_file_settings
view depended on such suppression *not* happening, we couldn't have fixed
this issue now without first doing something with pg_file_settings.
Now we suppress duplicates by marking them "ignored" within
ProcessConfigFileInternal, which doesn't hide them in the view.)

Lesser changes include:

Drive the view directly off the ConfigVariable list, instead of making a
basically-equivalent second copy of the data.  There's no longer any need
to hang onto the data permanently, anyway.

Convert show_all_file_settings() to do its work in one call and return a
tuplestore; this avoids risks associated with assuming that the GUC state
will hold still over the course of query execution.  (I think there were
probably latent bugs here, though you might need something like a cursor
on the view to expose them.)

Arrange to run SIGHUP processing in a short-lived memory context, to
forestall process-lifespan memory leaks.  (There is one known leak in this
code, in ProcessConfigDirectory; it seems minor enough to not be worth
back-patching a specific fix for.)

Remove mistaken assignment to ConfigFileLineno that caused line counting
after an include_dir directive to be completely wrong.

Add missed failure check in AlterSystemSetConfigFile().  We don't really
expect ParseConfigFp() to fail, but that's not an excuse for not checking.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/62d16c7fc5614d9f4d0dd1a9f164b232c273c128

Modified Files
--------------
doc/src/sgml/catalogs.sgml          |   72 +++++--
doc/src/sgml/config.sgml            |    8 +
doc/src/sgml/release-9.5.sgml       |   15 +-
src/backend/utils/misc/guc-file.l   |  369 +++++++++++++++++++++++------------
src/backend/utils/misc/guc.c        |  181 +++++++++--------
src/include/catalog/catversion.h    |    2 +-
src/include/catalog/pg_proc.h       |    2 +-
src/include/utils/guc.h             |   20 +-
src/test/regress/expected/rules.out |    6 +-
9 files changed, 430 insertions(+), 245 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Also trigger restartpoints based on max_wal_size on standby.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Back-patch some minor bug fixes in GUC code.