Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/pg/pglogical/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,17 @@ def subscription_remove_replication_set(name, set_name)
# slot_name
# replication_sets
# forward_origins
# remote_replication_lsn(Log Sequence Number)
# local_replication_lsn(Log Sequence Number)
def subscription_show_status(name)
typed_exec("SELECT * FROM pglogical.show_subscription_status($1)", name).first.tap do |s|
sql = <<-SQL
SELECT sub.*, stat.remote_lsn AS remote_replication_lsn, stat.local_lsn AS local_replication_lsn
FROM pglogical.show_subscription_status($1) sub
JOIN pg_replication_origin_status stat
ON sub.slot_name = stat.external_id
SQL

typed_exec(sql, name).first.tap do |s|
s["replication_sets"] = s["replication_sets"][1..-2].split(",")
s["forward_origins"] = s["forward_origins"][1..-2].split(",")
end
Expand Down
2 changes: 2 additions & 0 deletions spec/replication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def enable_nodes
expect(sub_info["status"]).to eq("replicating")
expect(sub_info["provider_dsn"]).to eq(source_dsn)
expect(sub_info["replication_sets"]).to eq([replication_set_name])
expect(sub_info["remote_replication_lsn"]).to match(%r{\h+/\h+})
expect(sub_info["local_replication_lsn"]).to match(%r{\h+/\h+})

sub_list = target_connection.pglogical.subscriptions
expect(sub_list.first).to eq(sub_info)
Expand Down