fix build with latest postgresql

(cherry picked from commit 648d5671aae775053ae19a8e8da41c0857f8c9aa)
This commit is contained in:
Funda Wang 2025-02-28 21:55:35 +08:00 committed by openeuler-sync-bot
parent 9b793d5831
commit 5b979dc2c0
2 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,31 @@
From dd138ecf313274cc6a5481071bf301dc8c5139d8 Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars.kanis@sincnovation.com>
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) )

View File

@ -3,7 +3,7 @@
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 1.2.3 Version: 1.2.3
Release: 2 Release: 3
Summary: A Ruby interface to the PostgreSQL RDBMS Summary: A Ruby interface to the PostgreSQL RDBMS
# Upstream license clarification (https://bitbucket.org/ged/ruby-pg/issue/72/) # Upstream license clarification (https://bitbucket.org/ged/ruby-pg/issue/72/)
# #
@ -17,6 +17,8 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# https://bitbucket.org/ged/ruby-pg/issue/183 # https://bitbucket.org/ged/ruby-pg/issue/183
Patch0: rubygem-pg-0.17.1-remove-rpath.patch Patch0: rubygem-pg-0.17.1-remove-rpath.patch
Patch1: Fix-date-matching-failure.patch Patch1: Fix-date-matching-failure.patch
# https://github.com/ged/ruby-pg/commit/dd138ecf313274cc6a5481071bf301dc8c5139d8
Patch2: backport-Use-a-connection-encoding-compatible-to-Mohre.patch
# Required in ext/pg_text_decoder.c # Required in ext/pg_text_decoder.c
Requires: rubygem(bigdecimal) Requires: rubygem(bigdecimal)
BuildRequires: ruby(release) BuildRequires: ruby(release)
@ -47,8 +49,9 @@ Documentation for %{name}.
%prep %prep
%setup -q -n %{gem_name}-%{version} %setup -q -n %{gem_name}-%{version}
%patch0 -p1 %patch -P0 -p1
%patch1 -p1 %patch -P1 -p1
%patch -P2 -p1
%build %build
# Create the gem as gem install only works on a gem file # Create the gem as gem install only works on a gem file
@ -119,6 +122,9 @@ popd
%{gem_instdir}/spec %{gem_instdir}/spec
%changelog %changelog
* Fri Feb 28 2025 Funda Wang <fundawang@yeah.net> - 1.2.3-3
- fix build with latest postgresql
* Tue Aug 02 2022 jiangxinyu <jiangxinyu@kylinos.cn> - 1.2.3-2 * Tue Aug 02 2022 jiangxinyu <jiangxinyu@kylinos.cn> - 1.2.3-2
- Fix date matching failure - Fix date matching failure