@@ -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
94110from 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