Vao*_*sun 4 postgresql configuration
如果我做对了,设置是分层的:
postgres.conf->
postgres.auto.conf (ALTER SYSTEM)->
ALTER DATABASE(where applicable)->
ALTER USER(where applicable)->
SET SESSION(where applicable)->
SET LOCAL(where applicable)
Run Code Online (Sandbox Code Playgroud)
假设我已经在某个时候enable_seqscan
设置了off
。SHOW
或current_setting(
或pg_settings
将仅显示当前值。但是要检查为什么我关闭它,我必须检查整个链条。例如,我怀疑有人为每个用户或每个数据库设置了它,或者在auto.conf
- 要找到设置的范围,我必须全部检查。否则重置值可能会失败,例如:
vao=# show enable_seqscan;
enable_seqscan
----------------
off
(1 row)
vao=# set enable_seqscan to default;
SET
vao=# show enable_seqscan;
enable_seqscan
----------------
off
(1 row)
Run Code Online (Sandbox Code Playgroud)
因为对于用户vao,或者对于数据库vao,或者更深...
找到当前值的主要来源的捷径是什么? .. 或者最好是设置的所有来源的矩阵。是否有任何界面或猴子黑客?
更新以反映出色的 Abelisto 答案:
source, sourcefile from pg_settings
是一个很好的信息来源,我仍然要求一种猴子的方式来检查这些原因:看到database
或user
在source
我必须重新登录 - 显然。因此,在它们实际应用于会话之前,我无法检查它们。本地和会话集都显示了 SESSION(这也很合理),最后我仍然必须逐步将所有层次结构重置为默认值。例如:
vao=# select setting, source, sourcefile from pg_settings where name = 'enable_seqscan';
setting | source | sourcefile
---------+----------+------------
off | database |
(1 row)
vao=# select * from pg_file_settings where name = 'enable_seqscan';
sourcefile | sourceline | seqno | name | setting | applied | error
---------------------------------------------------+------------+-------+----------------+---------+---------+-------
/etc/postgresql/9.6/main/a | 1 | 1 | enable_seqscan | off | f |
/var/lib/postgresql/9.6/main/postgresql.auto.conf | 3 | 26 | enable_seqscan | on | t |
(2 rows)
Run Code Online (Sandbox Code Playgroud)
所以如果我不检查每个来源,我的更改就不会得到尊重。
pg_settings
- 寻找 source*
例如,经过
alter system set array_nulls to off;
Run Code Online (Sandbox Code Playgroud)
(并重新加载配置)
select * from pg_settings where name = 'array_nulls';
Run Code Online (Sandbox Code Playgroud)
??[ 记录 1 ]????????????????????????????????????????????? ?????????????????????????????????????????????????????? ???????????????????????? ? 姓名 ?数组空值? ? 环境 ?离开 ? ? 单元 ????? ? 类别 ?版本和平台兼容性/以前的 PostgreSQL 版本? ? 短描述?允许在数组中输入 NULL 元素。? ? 额外描述?打开时,数组输入值中未加引号的 NULL 表示空值;否则按字面理解。? ? 语境 ?用户? ? 变量类型?布尔? ? 来源 ?配置文件? ? 最小值????? ? 最大值 ? ???? ? 枚举????? ? 引导值?在 ? ? 重置值?离开 ? ? 源文件 ?/var/lib/postgresql/9.5/main/postgresql.auto.conf ? ? 源线?3 ? ? 挂起_重启?F ? ?????????????????????????????????????????????????????? ?????????????????????????????????????????????????????? ?????????????????????????????????
更新 还有获取数据库/角色设置的查询,无需重新登录:
with
opt_db as (
select s.*, d.datname, opt_name, opt_value from
pg_db_role_setting s join
pg_database d on (s.setdatabase = d.oid) cross join lateral (
select
split_part(opt, '=',1) as opt_name,
split_part(opt, '=', 2) as opt_value
from
unnest(setconfig) as opt) as opt
),
opt_role as (
select s.*, r.rolname, opt_name, opt_value from
pg_db_role_setting s join
pg_roles r on (s.setrole = r.oid) cross join lateral (
select
split_part(opt, '=', 1) as opt_name,
split_part(opt, '=', 2) as opt_value
from
unnest(setconfig) as opt) as opt
)
select
datname,
rolname,
opt_name,
opt_db.opt_value as db_value,
opt_role.opt_value as role_value
from opt_db full join opt_role using(opt_name);
Run Code Online (Sandbox Code Playgroud)
可能的结果:
?????????????????????????????????????????????????????? ??????????????????????????? ? 数据名 ? 姓名 ? 选择名称?数据库值?角色值? ?????????????????????????????????????????????????????? ??????????????????????????? ? 邮政?? 搜索路径?“$user”,公共?“$user”,公共? ? 邮政?邮政?数组空值?离开 ?在 ? ? ???? ? foo.bar ? ???? 3 ? ?????????????????????????????????????????????????????? ???????????????????????????
归档时间: |
|
查看次数: |
845 次 |
最近记录: |