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 50c4681

Browse files
authored
Errors found in config files
1 parent 79293e4 commit 50c4681

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

‎psqlrc/psqlrc‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,8 @@
3535
\pset null '¤'
3636

3737
\pset pager always
38-
39-
\if `command -v pspg &> /dev/null && echo 1 || echo 0`
40-
\pset expanded off
41-
\setenv PAGER 'pspg --reprint-on-exit --blackwhite'
42-
\else
43-
\pset expanded auto
44-
\setenv PAGER 'less -iMFXSx4R'
45-
\echo :white'Using alternative psql pager called "pspg" is highly recommended (but not required): https://github.com/okbob/pspg':reset
46-
\endif
38+
\pset expanded auto
39+
\setenv PAGER 'less -iMFXSx4R'
4740

4841
select -- pg_backend_pid(), -- If we're connecting through pgbouncer, then prompt's %p is not real, so get real PID
4942
pg_is_in_recovery(), -- primary or standby
@@ -81,6 +74,29 @@ from coalesce(case when not pg_is_in_recovery() then null -- not standby
8174
extract(epoch from r.lag) as e(epoch)
8275
\gset
8376

77+
\if :pg_file_settings_error_count
78+
\echo :red'Errors found in config files:':reset
79+
with t as (
80+
select distinct on (name) *
81+
from pg_file_settings
82+
order by name, seqno desc
83+
)
84+
select t.sourcefile,
85+
t.sourceline,
86+
t.name,
87+
t.setting,
88+
t.applied,
89+
t.error,
90+
s.vartype,
91+
s.min_val,
92+
s.max_val,
93+
s.enumvals,
94+
s.extra_desc
95+
from t
96+
join pg_settings as s on t.name = s.name
97+
where not applied;
98+
\endif
99+
84100
/* psql escape codes:
85101
%M - full host + domain for db server, or [local] (if over Unix socket), or [local:/dir/name]
86102
%m - host name of the db server, truncated at the first dot, or [local] (if over Unix socket)
@@ -108,6 +124,14 @@ from coalesce(case when not pg_is_in_recovery() then null -- not standby
108124

109125
\set PROMPT2 ''
110126

127+
\if `command -v pspg &> /dev/null && echo 1 || echo 0`
128+
\echo '"pspg" pager is used'
129+
\pset expanded off
130+
\setenv PAGER 'pspg --reprint-on-exit --blackwhite'
131+
\else
132+
\echo :white'Using alternative psql pager called "pspg" is highly recommended (but not required): https://github.com/okbob/pspg':reset
133+
\endif
134+
111135
-- Show query execution time
112136
\timing on
113137

0 commit comments

Comments
(0)

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