Skip to content

Commit

Permalink
Query major PG version.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-dp committed Sep 11, 2024
1 parent 307b64b commit 22d9cff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/sync-service/lib/electric/connection_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ defmodule Electric.ConnectionManager do
{:ok, pid} ->
Electric.Timeline.check(get_pg_timeline(pid), state.timeline_opts)

pg_version = query_pg_version(pid)
pg_version = query_pg_major_version(pid)

# Now we have everything ready to start accepting and processing logical messages from
# Postgres.
Expand Down Expand Up @@ -397,11 +397,11 @@ defmodule Electric.ConnectionManager do
end
end

def query_pg_version(conn) do
def query_pg_major_version(conn) do
[[setting]] =
Postgrex.query!(
conn,
"SELECT setting::decimal FROM pg_settings WHERE name = 'server_version'",
"SELECT floor(setting::numeric)::integer FROM pg_settings WHERE name = 'server_version'",
[]
)
|> Map.fetch!(:rows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ defmodule Electric.Postgres.ConfigurationTest do
end

defp list_tables_in_publication(conn, publication) do
pg_version = Electric.ConnectionManager.query_pg_version(conn)
pg_version = Electric.ConnectionManager.query_pg_major_version(conn)
list_tables_in_pub(conn, publication, pg_version)
end

Expand Down
2 changes: 1 addition & 1 deletion packages/sync-service/test/support/db_setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule Support.DbSetup do
end

def with_pg_version(ctx) do
pg_version = Electric.ConnectionManager.query_pg_version(ctx.db_conn)
pg_version = Electric.ConnectionManager.query_pg_major_version(ctx.db_conn)
{:ok, %{get_pg_version: fn -> pg_version end}}
end

Expand Down

0 comments on commit 22d9cff

Please sign in to comment.