File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -117,13 +117,13 @@ def run
117117 sslmode : ssl_mode ,
118118 connect_timeout : config [ :timeout ] )
119119
120- begin
121- # PostgreSQL 10
122- master = conn_master . exec ( 'SELECT pg_current_wal_lsn()' ) . getvalue ( 0 , 0 )
123- rescue
124- # PostgreSQL <= 9.6
125- master = conn_master . exec ( 'SELECT pg_current_xlog_location()' ) . getvalue ( 0 , 0 )
126- end
120+ pg_vsn = conn_master . exec ( "SELECT current_setting('server_version')" ) . getvalue ( 0 , 0 )
121+ master =
122+ if Gem :: Version . new ( pg_vsn ) > Gem :: Version . new ( '9.6' )
123+ conn_master . exec ( 'SELECT pg_current_wal_lsn()' ) . getvalue ( 0 , 0 )
124+ else
125+ conn_master . exec ( 'SELECT pg_current_xlog_location()' ) . getvalue ( 0 , 0 )
126+ end
127127 m_segbytes = conn_master . exec ( 'SHOW wal_segment_size' ) . getvalue ( 0 , 0 ) . sub ( /\D +/ , '' ) . to_i << 20
128128 conn_master . close
129129
@@ -136,13 +136,12 @@ def run
136136 sslmode : ssl_mode ,
137137 connect_timeout : config [ :timeout ] )
138138
139- begin
140- # PostgreSQL 10
141- slave = conn_slave . exec ( 'SELECT pg_last_wal_replay_lsn()' ) . getvalue ( 0 , 0 )
142- rescue
143- # PostgreSQL <= 9.6
144- slave = conn_slave . exec ( 'SELECT pg_last_xlog_receive_location()' ) . getvalue ( 0 , 0 )
145- end
139+ slave =
140+ if Gem ::Version . new ( pg_vsn ) > Gem ::Version . new ( '9.6' )
141+ conn_slave . exec ( 'SELECT pg_last_wal_replay_lsn()' ) . getvalue ( 0 , 0 )
142+ else
143+ conn_slave . exec ( 'SELECT pg_last_xlog_receive_location()' ) . getvalue ( 0 , 0 )
144+ end
146145 conn_slave . close
147146
148147 # Computing lag
You can’t perform that action at this time.
0 commit comments