Skip to content

Commit 944b9c6

Browse files
committed
forgotten file
1 parent d1d23f6 commit 944b9c6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

warmup.psql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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

0 commit comments

Comments
 (0)