Skip to content

Commit

Permalink
Add binary LSN encoding/decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Aug 13, 2024
1 parent 3cbcb14 commit 315e632
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/postgrex/extensions/int8.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Postgrex.Extensions.Int8 do
@moduledoc false
import Postgrex.BinaryUtils, warn: false
use Postgrex.BinaryExtension, send: "int8send"
use Postgrex.BinaryExtension, send: "int8send", send: "pg_lsn_send"

@int8_range -9_223_372_036_854_775_808..9_223_372_036_854_775_807

Expand Down
6 changes: 6 additions & 0 deletions test/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ defmodule QueryTest do
assert [[Decimal.new("NaN")]] == query("SELECT 'NaN'::numeric", [])
end

@tag min_pg_version: "10.0"
test "decode lsn", context do
assert [[int, text]] = query("SELECT pg_current_wal_lsn(), pg_current_wal_lsn()::text", [])
assert Postgrex.ReplicationConnection.decode_lsn(text) == {:ok, int}
end

@tag min_pg_version: "14.0"
test "decode numeric infinity", context do
assert [[Decimal.new("Inf")]] == query("SELECT NUMERIC 'Infinity'", [])
Expand Down

0 comments on commit 315e632

Please sign in to comment.