From 315e632d3fa66a5d3c2f2697da1976da3c28d866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 13 Aug 2024 08:23:58 +0200 Subject: [PATCH] Add binary LSN encoding/decoding --- lib/postgrex/extensions/int8.ex | 2 +- test/query_test.exs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/postgrex/extensions/int8.ex b/lib/postgrex/extensions/int8.ex index 04a554b4..89e5128a 100644 --- a/lib/postgrex/extensions/int8.ex +++ b/lib/postgrex/extensions/int8.ex @@ -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 diff --git a/test/query_test.exs b/test/query_test.exs index eb811db5..1eb4b2c0 100644 --- a/test/query_test.exs +++ b/test/query_test.exs @@ -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'", [])