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

Commit e346dea

Browse files
authored
is_config_file_setting_incorrect
1 parent 5f4908c commit e346dea

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

‎psqlrc/psqlrc‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,23 @@ select -- pg_backend_pid(), -- if we're connecting through pgbouncer, then promp
8989
and fs.setting is distinct from cs.setting
9090
and fs.setting is distinct from s.setting
9191
and fs.applied and not s.pending_restart
92-
) as is_pending_reload
92+
) as is_pending_reload,
93+
94+
exists(
95+
select
96+
from fs
97+
cross join current_setting(fs.name) as cs(setting)
98+
join pg_settings as s on fs.name = lower(s.name)
99+
and fs.setting is distinct from cs.setting
100+
and fs.setting is distinct from s.setting
101+
and fs.applied
102+
and case s.vartype
103+
when 'enum' then fs.setting != any (s.enumvals)
104+
--when 'integer' then fs.setting::int not between s.min_val::int and s.max_val::int
105+
--when 'real' then fs.setting::real not between s.min_val::real and s.max_val::real
106+
else false
107+
end
108+
) as is_config_file_setting_incorrect
93109

94110
from coalesce(
95111
case when not pg_is_in_recovery() then null -- not standby
@@ -104,6 +120,7 @@ from coalesce(
104120

105121
\if :is_config_file_error
106122
\echo :red'Errors found in config file "':config_file'"':reset
123+
107124
with t as (
108125
select distinct on (name) *
109126
from pg_file_settings
@@ -162,6 +179,33 @@ from coalesce(
162179
and fs.applied and not s.pending_restart;
163180
\endif
164181

182+
\if :is_config_file_setting_incorrect
183+
\echo :red'Incorrect tobe setting found in config file "':config_file'"':reset
184+
185+
with fs as (
186+
select distinct on (name) *
187+
from pg_file_settings
188+
order by name, seqno desc
189+
)
190+
select fs.sourcefile, fs.sourceline,
191+
fs.name, s.vartype,
192+
cs.setting as current_setting,
193+
fs.setting as tobe_setting,
194+
s.enumvals, s.min_val, s.max_val
195+
from fs
196+
cross join current_setting(fs.name) as cs(setting)
197+
join pg_settings as s on fs.name = lower(s.name)
198+
and fs.setting is distinct from cs.setting
199+
and fs.setting is distinct from s.setting
200+
and fs.applied
201+
and case s.vartype
202+
when 'enum' then fs.setting != any (s.enumvals)
203+
--when 'integer' then fs.setting::int not between s.min_val::int and s.max_val::int
204+
--when 'real' then fs.setting::real not between s.min_val::real and s.max_val::real
205+
else false
206+
end
207+
\endif
208+
165209
/* psql escape codes:
166210
%M - full host + domain for db server, or [local] (if over Unix socket), or [local:/dir/name]
167211
%m - host name of the db server, truncated at the first dot, or [local] (if over Unix socket)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /