3838\pset expanded auto
3939\setenv PAGER 'less -iMFXSx4R'
4040
41- select -- pg_backend_pid(), -- If we're connecting through pgbouncer, then prompt's %p is not real, so get real PID
41+ select -- pg_backend_pid(), -- if we're connecting through pgbouncer, then prompt's %p is not real, so get real PID
4242
4343 pg_is_in_recovery(), -- primary or standby
4444
4545 current_setting('server_version') as server_version,
46+ current_setting('config_file') as config_file,
47+ current_setting('hba_file') as hba_file,
4648
4749 (select count(*) from pg_stat_replication where state = 'streaming') as streaming_count,
4850
@@ -53,25 +55,27 @@ select -- pg_backend_pid(), -- If we're connecting through pgbouncer, then pr
5355 limit 1), '***LOST***') as primary_dsn,
5456
5557 coalesce(nullif(concat(
56- nullif(extract(day from lag), 0) || 'd',
57- nullif(extract(hour from lag), 0) || 'h',
58- nullif(extract(minute from lag), 0) || 'm',
59- case when epoch < 1.0 then round(extract(second from lag)::numeric * 1000, 0) || 'ms'
60- when epoch < 10.0 then round(extract(second from lag)::numeric, 2) || 's'
61- when epoch < 60.0 then round(extract(second from lag)::numeric, 1) || 's'
62- when epoch < 3600.0 then round(extract(second from lag)::numeric, 0) || 's'
58+ nullif(extract(day from r. lag), 0) || 'd',
59+ nullif(extract(hour from r. lag), 0) || 'h',
60+ nullif(extract(minute from r. lag), 0) || 'm',
61+ case when epoch < 1.0 then round(extract(second from r. lag)::numeric * 1000, 0) || 'ms'
62+ when epoch < 10.0 then round(extract(second from r. lag)::numeric, 2) || 's'
63+ when epoch < 60.0 then round(extract(second from r. lag)::numeric, 1) || 's'
64+ when epoch < 3600.0 then round(extract(second from r. lag)::numeric, 0) || 's'
6365 end
6466 ), ''), '?') as replication_lag,
6567
66- (with t as (
68+ exists( (with t as (
6769 select distinct on (name) *
6870 from pg_file_settings
6971 order by name, seqno desc
7072 )
71- select count(*)
73+ select
7274 from t
7375 join pg_settings as s on t.name = s.name
74- where not applied) as pg_file_settings_error_count
76+ where not applied)) as is_config_file_error,
77+ 78+ exists(select from pg_hba_file_rules where error is not null) as is_hba_file_error
7579
7680from coalesce(case when not pg_is_in_recovery() then null -- not standby
7781 when not exists(select from pg_stat_wal_receiver) then null -- primary lost
@@ -81,29 +85,25 @@ from coalesce(case when not pg_is_in_recovery() then null -- not standby
8185 extract(epoch from r.lag) as e(epoch)
8286\gset
8387
84- \if :pg_file_settings_error_count
85- \echo :red'Errors found in config files: ':reset
88+ \if :is_config_file_error
89+ \echo :red'Errors found in config file "':config_file'" ':reset
8690 with t as (
8791 select distinct on (name) *
8892 from pg_file_settings
8993 order by name, seqno desc
9094 )
91- select t.sourcefile,
92- t.sourceline,
93- t.name,
94- t.setting,
95- t.applied,
96- t.error,
97- s.vartype,
98- s.min_val,
99- s.max_val,
100- s.enumvals,
101- s.extra_desc
95+ select t.sourcefile, t.sourceline, t.name, t.setting, t.applied, t.error,
96+ s.vartype, s.min_val, s.max_val, s.enumvals, s.extra_desc
10297 from t
10398 join pg_settings as s on t.name = s.name
10499 where not applied;
105100\endif
106101
102+ \if :is_hba_file_error
103+ \echo :red'Errors found in hba file "':hba_file'"':reset
104+ select * from pg_hba_file_rules where error is not null;
105+ \endif
106+ 107107/* psql escape codes:
108108%M - full host + domain for db server, or [local] (if over Unix socket), or [local:/dir/name]
109109%m - host name of the db server, truncated at the first dot, or [local] (if over Unix socket)
0 commit comments