Skip to content

Commit 42c18ed

Browse files
committed
1: fix for postgres 10, finished
1 parent 717080c commit 42c18ed

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

init/generate.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ cat > "$OUT" <<- VersCheck
1414
1515
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\\\1')::numeric >= 10 as postgres_dba_pgvers_10plus \gset
1616
\if :postgres_dba_pgvers_10plus
17-
\set funcname_last_wal_receive_lsn pg_last_wal_receive_lsn
18-
\set funcname_last_wal_replay_lsn pg_last_wal_replay_lsn
19-
\set funcname_is_wal_replay_paused pg_is_wal_replay_paused
20-
\echo VERSION 10+++
17+
\set postgres_dba_last_wal_receive_lsn pg_last_wal_receive_lsn
18+
\set postgres_dba_last_wal_replay_lsn pg_last_wal_replay_lsn
19+
\set postgres_dba_is_wal_replay_paused pg_is_wal_replay_paused
2120
\else
22-
\set funcname_last_wal_receive_lsn pg_last_xlog_receive_location
23-
\set funcname_last_wal_replay_lsn pg_last_xlog_replay_location
24-
\set funcname_is_wal_replay_paused pg_is_xlog_replay_paused
25-
\echo VERS < 10 !!
21+
\set postgres_dba_last_wal_receive_lsn pg_last_xlog_receive_location
22+
\set postgres_dba_last_wal_replay_lsn pg_last_xlog_replay_location
23+
\set postgres_dba_is_wal_replay_paused pg_is_xlog_replay_paused
2624
\endif
2725
2826
-- TODO: improve work with custom GUCs for Postgres 9.5 and older

sql/1_basic.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ select
1111
case
1212
when pg_is_in_recovery() then 'Replica' || ' (delay: '
1313
|| ((((case
14-
when :funcname_last_xlog_receive_location() = :funcname_last_xlog_replay_location() then 0
14+
when :postgres_dba_last_wal_receive_lsn() = :postgres_dba_last_wal_replay_lsn() then 0
1515
else extract (epoch from now() - pg_last_xact_replay_timestamp())
1616
end)::int)::text || ' second')::interval)::text
17-
|| '; paused: ' || :funcname_is_xlog_replay_paused()::text || ')'
17+
|| '; paused: ' || :postgres_dba_is_wal_replay_paused()::text || ')'
1818
else 'Master'
1919
end as value
2020
union all

start.psql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 10 as postgres_dba_pgvers_10plus \gset
88
\if :postgres_dba_pgvers_10plus
9-
\set funcname_last_wal_receive_lsn pg_last_wal_receive_lsn
10-
\set funcname_last_wal_replay_lsn pg_last_wal_replay_lsn
11-
\set funcname_is_wal_replay_paused pg_is_wal_replay_paused
12-
\echo VERSION 10+++
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
1312
\else
14-
\set funcname_last_wal_receive_lsn pg_last_xlog_receive_location
15-
\set funcname_last_wal_replay_lsn pg_last_xlog_replay_location
16-
\set funcname_is_wal_replay_paused pg_is_xlog_replay_paused
17-
\echo VERS < 10 !!
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
1816
\endif
1917

2018
-- TODO: improve work with custom GUCs for Postgres 9.5 and older

0 commit comments

Comments
 (0)