File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ -- check if "\if" is supported (psql 10+)
2+ \if false
3+ \echo cannot work, you need psql version 10+ (Postgres server can be older)
4+ select 1/0;
5+ \endif
6+
7+ select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 10 as postgres_dba_pgvers_10plus \gset
8+ \if :postgres_dba_pgvers_10plus
9+ \set postgres_dba_last_wal_receive_lsn pg_last_wal_receive_lsn
10+ \set postgres_dba_last_wal_replay_lsn pg_last_wal_replay_lsn
11+ \set postgres_dba_is_wal_replay_paused pg_is_wal_replay_paused
12+ \else
13+ \set postgres_dba_last_wal_receive_lsn pg_last_xlog_receive_location
14+ \set postgres_dba_last_wal_replay_lsn pg_last_xlog_replay_location
15+ \set postgres_dba_is_wal_replay_paused pg_is_xlog_replay_paused
16+ \endif
17+
18+ -- TODO: improve work with custom GUCs for Postgres 9.5 and older
19+ select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 9.6 as postgres_dba_pgvers_96plus \gset
20+ \if :postgres_dba_pgvers_96plus
21+ select coalesce(current_setting('postgres_dba.wide', true), 'off') = 'on' as postgres_dba_wide \gset
22+ \else
23+ set client_min_messages to 'fatal';
24+ select :postgres_dba_wide as postgres_dba_wide \gset
25+ reset client_min_messages;
26+ \endif
You can’t perform that action at this time.
0 commit comments