Skip to content

Commit a3c4aa3

Browse files
committed
1: work with postgres 10
1 parent 3636d3d commit a3c4aa3

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

init/generate.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ cat > "$OUT" <<- VersCheck
1212
select 1/0;
1313
\endif
1414
15+
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\\\1')::numeric >= 10 as postgres_dba_pgvers_10plus \gset
16+
\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+++
21+
\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 !!
26+
\endif
27+
1528
-- TODO: improve work with custom GUCs for Postgres 9.5 and older
1629
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\\\1')::numeric >= 9.6 as postgres_dba_pgvers_96plus \gset
1730
\if :postgres_dba_pgvers_96plus

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 pg_last_xlog_receive_location() = pg_last_xlog_replay_location() then 0
14+
when :funcname_last_xlog_receive_location() = :funcname_last_xlog_replay_location() then 0
1515
else extract (epoch from now() - pg_last_xact_replay_timestamp())
1616
end)::int)::text || ' second')::interval)::text
17-
|| '; paused: ' || pg_is_xlog_replay_paused()::text || ')'
17+
|| '; paused: ' || :funcname_is_xlog_replay_paused()::text || ')'
1818
else 'Master'
1919
end as value
2020
union all

start.psql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
select 1/0;
55
\endif
66

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 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+++
13+
\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 !!
18+
\endif
19+
720
-- TODO: improve work with custom GUCs for Postgres 9.5 and older
821
select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >= 9.6 as postgres_dba_pgvers_96plus \gset
922
\if :postgres_dba_pgvers_96plus
@@ -16,7 +29,7 @@ select regexp_replace(version(), '^PostgreSQL (\d+\.\d+).*$', e'\\1')::numeric >
1629
\echo '\033[1;35mMenu:\033[0m'
1730
\echo ' 1 – Basic Node Information (master/replica, lag, DB size, tmp files)'
1831
\echo ' 2 – General Table Size Information'
19-
\echo ' a1 – Alignment Padding Analysis: how many bytes can be saved if columns are ordered better?'
32+
\echo ' a1 – Alignmet Padding Analysis: how many bytes can be saved if columns are ordered better?'
2033
\echo ' b1 – Tables Bloat, rough estimation'
2134
\echo ' b2 – B-tree Indexes Bloat, rough estimation'
2235
\echo ' b3 – Tables Bloat, more precise (requires pgstattuple extension; expensive)'

0 commit comments

Comments
 (0)