Method: ActiveRecord::PGExtensions::PostgreSQLAdapter#wal_lsn_diff
- Defined in:
- lib/active_record/pg_extensions/postgresql_adapter.rb
permalink #wal_lsn_diff(lsn1 = :current, lsn2 = :last_replay) ⇒ Object
see www.postgresql.org/docs/current/functions-admin.html#id-1.5.8.33.5.5.2.2.4.1.1.1 lsns can be literals, or :current, :current_flush, :current_insert, :last_receive, or :last_replay
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/active_record/pg_extensions/postgresql_adapter.rb', line 221 def wal_lsn_diff(lsn1 = :current, lsn2 = :last_replay) return nil unless wal? lsns = [lsn1, lsn2].map do |lsn| case lsn when :current then pre_pg10_wal_function_name("pg_current_wal_lsn()") when :current_flush then pre_pg10_wal_function_name("pg_current_flush_wal_lsn()") when :current_insert then pre_pg10_wal_function_name("pg_current_insert_wal_lsn()") when :last_receive then pre_pg10_wal_function_name("pg_last_wal_receive_lsn()") when :last_replay then pre_pg10_wal_function_name("pg_last_wal_replay_lsn()") else; quote(lsn) end end select_value("SELECT #{pre_pg10_wal_function_name("pg_wal_lsn_diff")}(#{lsns[0]}, #{lsns[1]})") end |