From 195f9b5194f0a7f103a52eca13ebe0898f5ca371 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Fri, 28 Feb 2025 21:49:08 +0800 Subject: [PATCH] fix build with latest postgresql (cherry picked from commit 9560ac7ac318a6aa99fa19a0003b51e10efa38f5) --- ...nection-encoding-compatible-to-Mohre.patch | 31 +++++++++++++++++++ rubygem-pg.spec | 13 ++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 backport-Use-a-connection-encoding-compatible-to-Mohre.patch diff --git a/backport-Use-a-connection-encoding-compatible-to-Mohre.patch b/backport-Use-a-connection-encoding-compatible-to-Mohre.patch new file mode 100644 index 0000000..eb97797 --- /dev/null +++ b/backport-Use-a-connection-encoding-compatible-to-Mohre.patch @@ -0,0 +1,31 @@ +From dd138ecf313274cc6a5481071bf301dc8c5139d8 Mon Sep 17 00:00:00 2001 +From: Lars Kanis +Date: Fri, 28 Feb 2025 10:39:07 +0100 +Subject: [PATCH] =?UTF-8?q?Use=20a=20connection=20encoding=20compatible=20?= + =?UTF-8?q?to=20"M=C3=B6hre"?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function PQescapeString was changed in PostgreSQL 17.4, 16.8, 15.12, 14.17, and 13.20. +It now returns a predefined invalid character as a replacement in the connection encoding, if the input text is not valid according to the current connection encoding. +Using a compatible connection encoding avoids this, so that we get the original text out of the singleton escape function. + +Fixes #628 +--- + spec/pg/connection_spec.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb +index 63d3585a..b6460446 100644 +--- a/spec/pg/connection_spec.rb ++++ b/spec/pg/connection_spec.rb +@@ -2325,7 +2325,7 @@ def wait_check_socket(conn) + + it "uses the previous string encoding for escaped string" do + original = "Möhre to 'scape".encode( "iso-8859-1" ) +- @conn.set_client_encoding( "euc_jp" ) ++ @conn.set_client_encoding( "iso-8859-2" ) + escaped = described_class.escape( original ) + expect( escaped.encoding ).to eq( Encoding::ISO8859_1 ) + expect( escaped ).to eq( "Möhre to ''scape".encode(Encoding::ISO8859_1) ) diff --git a/rubygem-pg.spec b/rubygem-pg.spec index 3278f12..dedf883 100644 --- a/rubygem-pg.spec +++ b/rubygem-pg.spec @@ -3,7 +3,7 @@ Name: rubygem-%{gem_name} Version: 1.4.5 -Release: 1 +Release: 2 Summary: A Ruby interface to the PostgreSQL RDBMS License: (BSD or Ruby) and PostgreSQL URL: https://github.com/ged/ruby-pg @@ -14,6 +14,8 @@ Source1: %{gem_name}-%{version}-spec.tar.gz # Disable RPATH. # https://github.com/ged/ruby-pg/issues/183 Patch0: rubygem-pg-1.3.0-remove-rpath.patch +# https://github.com/ged/ruby-pg/commit/dd138ecf313274cc6a5481071bf301dc8c5139d8 +Patch1: backport-Use-a-connection-encoding-compatible-to-Mohre.patch # ext/pg_text_decoder.c Requires: rubygem(bigdecimal) # lib/pg/text_{de,en}coder.rb @@ -45,7 +47,11 @@ Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} -b 1 -%patch0 -p1 +%patch -P0 -p1 + +pushd %{_builddir} +%patch -P1 -p1 +popd %build # Create the gem as gem install only works on a gem file @@ -113,6 +119,9 @@ popd %{gem_instdir}/sample %changelog +* Fri Feb 28 2025 Funda Wang - 1.4.5-2 +- fix build with latest postgresql + * Thu Aug 10 2023 wubijie - 1.4.5-1 - Upgrade to version 1.4.5