forked from NikolayS/postgres_dba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
warmup.psql
26 lines (24 loc) · 1.15 KB
/
warmup.psql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- check if "\if" is supported (psql 10+)
\if false
\echo cannot work, you need psql version 10+ (Postgres server can be older)
select 1/0;
\endif
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 10 as postgres_dba_pgvers_10plus \gset
\if :postgres_dba_pgvers_10plus
\set postgres_dba_last_wal_receive_lsn pg_last_wal_receive_lsn
\set postgres_dba_last_wal_replay_lsn pg_last_wal_replay_lsn
\set postgres_dba_is_wal_replay_paused pg_is_wal_replay_paused
\else
\set postgres_dba_last_wal_receive_lsn pg_last_xlog_receive_location
\set postgres_dba_last_wal_replay_lsn pg_last_xlog_replay_location
\set postgres_dba_is_wal_replay_paused pg_is_xlog_replay_paused
\endif
-- TODO: improve work with custom GUCs for Postgres 9.5 and older
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 9.6 as postgres_dba_pgvers_96plus \gset
\if :postgres_dba_pgvers_96plus
select coalesce(current_setting('postgres_dba.wide', true), 'off') = 'on' as postgres_dba_wide \gset
\else
set client_min_messages to 'fatal';
select :postgres_dba_wide as postgres_dba_wide \gset
reset client_min_messages;
\endif