选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

受支持版本: 当前版本 (18) / 17 / 16 / 15 / 14
测试与开发版本: 19 / devel
不受支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0
历史版本PostgreSQL 9.2 已于 2017 年 11 月结束社区维护,本页译文保留供仍在使用旧版本的读者参考。新系统请看当前版本

45.64. pg_settings #

视图pg_settings提供对服务器运行时参数的访问。 它实质上是SHOWSET命令的替代接口。 它还提供了一些关于每个参数的事实,这些事实无法直接从SHOW中获取,例如最小值和最大值。

表 45.65. pg_settings

Name Type Description
name text Run-time configuration parameter name
setting text Current value of the parameter
unit text Implicit unit of the parameter
category text Logical group of the parameter
short_desc text A brief description of the parameter
extra_desc text Additional, more detailed, description of the parameter
context text Context required to set the parameter's value (see below)
vartype text Parameter type (bool, enum, integer, real, or string)
source text Source of the current parameter value
min_val text Minimum allowed value of the parameter (null for non-numeric values)
max_val text Maximum allowed value of the parameter (null for non-numeric values)
enumvals text[] Allowed values of an enum parameter (null for non-enum values)
boot_val text Parameter value assumed at server startup if the parameter is not otherwise set
reset_val text Value that RESET would reset the parameter to in the current session
sourcefile text Configuration file the current value was set in (null for values set from sources other than configuration files, or when examined by a non-superuser); helpful when using include directives in configuration files
sourceline integer Line number within the configuration file the current value was set at (null for values set from sources other than configuration files, or when examined by a non-superuser)

有几种可能的context值。 按照更改设置的难度递减的顺序,它们是:

internal

这些设置不能直接更改;它们反映了内部确定的值。其中一些可能可通过使用不同的配置选项重新构建服务器,或通过更改提供给initdb的选项来进行调整。

postmaster

这些设置只能在服务器启动时应用,因此任何更改都需要重启服务器。这些设置的值通常存储在 postgresql.conf 文件中,或者在服务器启动时通过命令行传递。当然,任何较低 context 类型的设置也都可以在服务器启动时设置。

sighup

可以在 postgresql.conf 中更改这些设置,而无需重启服务器。 向 postmaster 发送 SIGHUP 信号,会使其重新读取 postgresql.conf 并应用这些更改。 postmaster 还会将 SIGHUP 信号转发给其子进程,以便它们都采用新值。

backend

可以在 postgresql.conf 中更改这些设置,而无需重启服务器。 也可以在连接请求报文中为特定会话设置这些值(例如,通过 libpqPGOPTIONS 环境变量);任何用户都可以为其会话进行此类更改。 但是,在会话启动后,这些设置永远不会更改。 如果在 postgresql.conf 中更改它们,请向 postmaster 发送 SIGHUP 信号,使其重新读取 postgresql.conf。新值只会 影响随后启动的会话。

superuser

这些设置可以从postgresql.conf中设置, 或者通过SET命令在会话中设置;但只有超级用户 可以通过SET更改它们。 如果没有使用SET建立会话本地值,那么在postgresql.conf中的更改也会影响到现有会话。

user

这些设置可以从postgresql.conf中设置, 或通过SET命令在会话中设置。任何用户都可以更改其会话本地值。 如果没有使用SET建立会话本地值,那么在postgresql.conf中的更改也会影响到现有会话。

有关更改这些参数的各种方法,详见第 18.1 节

pg_settings视图不能插入或删除,但可以更新。对 pg_settings 的某一行执行 UPDATE,等同于对该命名参数执行 SET 命令。更改只影响当前会话所用的值。 如果在之后被中止的事务中发出了 UPDATE,那么事务回滚时 UPDATE 命令的效果也会消失。 一旦外围事务提交,这些效果会持续到会话结束,除非被另一个 UPDATESET 覆盖。

提交更正

译文有误、术语不当或页面显示问题,请到译文仓库 pgsty/pgdoc 报告译文问题。 英文原文本身的问题,请在当前版本的对应页面向上游反馈;上游不再修订已结束维护的版本。